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
| Choice | What the docs say | What to do with it |
|---|---|---|
| Dimension | Most current Voyage models default to 1024 and also offer 256, 512 and 20481 | Smaller vectors take less storage and search faster. Whether quality drops enough to matter is something to test on your own data |
| Document vs query | The quickstart embeds the corpus with input_type="document" and the question with input_type="query"1 | Set it the same way at index time and at search time |
| Similarity | Voyage embeddings are normalised to length 1, so dot product and cosine similarity are the same1 | Check 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
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 freeMore from the blog
- Forward Deployed Engineer jobs in 2026: what the data says
- What is RAG? Retrieval-augmented generation, explained with working code
- What is an AI agent? The agent loop, explained with code
- AI engineer roadmap 2026: what to learn, and in what order
- Will AI replace software engineers? What the data says in 2026
- Forward Deployed Engineer courses in India (2026): fees, format and how they compare
- Forward Deployed Engineer vs ML engineer: which AI role fits you?
- Forward Deployed Engineer salary in India: what the 2026 data says for 2027
- Forward Deployed Engineer interview questions: the six rounds and how to answer
- Why Forward Deployed Engineer is a smart next move for a software engineer
- Forward Deployed Engineer certification in 2026: what exists, what it costs, and what employers check
- Forward Deployed Engineer skills: what 1,000 job posts ask for
- Forward Deployed Engineer vs Solutions Engineer: the real difference
- Forward Deployed Engineer resume: what to put on one page
- Forward Deployed Software Engineer (FDSE): what the Palantir title means
- Forward deployed AI engineer, AI deployment engineer, FDE: the titles explained
- Prompt injection explained: what it is and how to defend against it
- Context engineering explained: beyond prompt engineering
- RAG vs fine-tuning: which one to use, and when
- LLM evals explained: how to test a system that gives different answers
- LLM observability explained: traces, cost and what to log
- Tool calling explained: how an LLM uses your functions
- What is MCP? The Model Context Protocol explained
- AI agent vs workflow: which one does your problem need?
- AI engineer vs ML engineer: what each one does
- AI engineer interview questions: 25 that test whether you have built anything
- What is a vector database? Explained with a 30-line example
- EY now hires Forward Deployed Engineers for audit. The role is leaving the AI labs
- LangGraph explained: state, nodes and edges, with a 30-line example
- Randstad: 90% of Indian employers are growing tech teams for AI. What it means for engineers
- AI agent memory explained: short-term vs long-term, with a tested example
- LLM cost optimization: prompt caching, batching and model routing, with the numbers
- Structured outputs from an LLM: JSON schema, validation and retries
- Data engineer to AI engineer: what carries over and what to learn
- AWS launches a Forward Deployed Engineering Competency, with Infosys, TCS and Coforge among 22 launch partners
- Forward Deployed Architect: what the role is, certifications and courses
- Persistent launches a Forward Deployed Engineering program with Microsoft, a day after NIIT's FDE talent blueprint
- How to become an AI engineer in India: the route depends on where you start
- Self-paced Forward Deployed Engineer courses in India under ₹10,000 (and under ₹3,000)
- AWS and OpenAI will jointly staff forward deployed engineering teams inside customer environments
- Backend developer to AI engineer: what carries over and what to learn
- Claude now runs on premises in customers' own data centers through AWS AI Factories
- Agentic AI courses compared: four free options, and what a course must make you build
- AWS: attacks on AI systems grew about 800% in 2026, and an AI agent broke into a decoy MCP server in 12.7 minutes