Start free

Zero to FDE / Blog / Embeddings explained: vectors, cosine similarity and dimensions

Blog

Embeddings explained: vectors, cosine similarity and dimensions

An embedding is a list of numbers, produced by a model, that places a piece of text so that texts with similar meaning end up close together. Searching by meaning then becomes a distance problem: embed the question, embed your documents once, and return the documents nearest the question.

Where embeddings fit

Embeddings are the retrieval half of RAG and the lookup behind agent memory. The vectors are stored and searched in a vector database, which handles the filtering and the speed. This page is about the vectors themselves.

Who makes them

Anthropic's documentation says Anthropic does not offer its own embedding model, and names Voyage AI as one provider with a wide range, while advising you to assess several vendors for your use case.1 The same page lists the current Voyage models, for example voyage-4, voyage-4-large, voyage-4-lite and a code model voyage-code-4, each with a 32,000 token context length and a default vector size of 1024 numbers.1 You can also request 256, 512 or 2048 for most of them.1

ChoiceWhat the docs sayWhat to do with it
DimensionMost current Voyage models default to 1024 and also offer 256, 512 and 20481Smaller vectors take less storage and search faster. Whether quality drops enough to matter is something to test on your own data
Document vs queryThe quickstart embeds the corpus with input_type="document" and the question with input_type="query"1Set it the same way at index time and at search time
SimilarityVoyage embeddings are normalised to length 1, so dot product and cosine similarity are the same1Check this before you use another vendor's vectors

Why cosine, and when a dot product misleads

Cosine similarity compares the direction of two vectors and ignores their length. A raw dot product also rewards length, so a long vector can outrank a closer match. The example below uses two-number vectors so you can check the sums by hand: a query, one long vector pointing a different way, and one short vector pointing nearly the same way.

import math

def dot(a, b):
    return sum(x * y for x, y in zip(a, b))

def cosine(a, b):
    return dot(a, b) / (math.sqrt(dot(a, a)) * math.sqrt(dot(b, b)))

def unit(v):
    length = math.sqrt(dot(v, v))
    return [x / length for x in v]

query = [1.0, 1.0]
docs = {
    "long, off-topic": [10.0, 2.0],
    "short, on-topic": [1.0, 1.2],
}

print("raw dot product:")
for name, v in docs.items():
    print("  ", name, round(dot(query, v), 2))
print("cosine similarity:")
for name, v in docs.items():
    print("  ", name, round(cosine(query, v), 2))
print("dot product after scaling every vector to length 1:")
for name, v in docs.items():
    print("  ", name, round(dot(unit(query), unit(v)), 2))

Output:

raw dot product:
   long, off-topic 12.0
   short, on-topic 2.2
cosine similarity:
   long, off-topic 0.83
   short, on-topic 1.0
dot product after scaling every vector to length 1:
   long, off-topic 0.83
   short, on-topic 1.0

The raw dot product picks the off-topic document, 12.0 against 2.2. Cosine picks the right one. Once every vector is scaled to length 1, the plain dot product gives the same ranking as cosine, which is why a provider that normalises its vectors lets you use the cheaper dot product.

Mistakes that quietly hurt search

  • Mixing models. Vectors from different models live in different spaces. Re-embed everything when you switch.
  • Skipping the document and query setting where the provider offers one.
  • Never testing retrieval on its own. Check that the right chunk comes back for real questions before blaming the language model. A small eval set does this, and the way you split text matters as much as the model, as covered in context engineering.

What this does not tell you

  • The model names, sizes and the normalisation statement are from Anthropic's embeddings page as read on 29 November 2026. Vendors update their lists often, so check the current page.
  • The page gives no prices and no quality benchmarks, so this article does not either.
  • The example uses two numbers to show a principle. Real embeddings have hundreds or thousands of numbers.

Embeddings are one of the first building blocks in a retrieval project for a client. Zero to FDE builds a document Q&A tool that cites its sources; it is self-paced and written, and the course does not include live classes, mentors or a certificate.

Zero to FDE is a self-paced 16-week course, ₹2,999 once, with a 7-day full refund. Week 1 is free, and one Week 4 lesson is free if you already write backend code. It has no live classes, no mentors and no accredited certificate.

Sources

  1. Anthropic, “Embeddings” (Claude Platform docs)

Zero to FDE is a 16-week path, for working engineers and AIML graduates, to the work Forward Deployed Engineers do: backend basics, LLMs, RAG, agents, evaluation and deployment, with a shipped deliverable every week. Week 1 is free and complete, no card needed.

Start Week 1 free

More from the blog