What are embeddings?
Mastery check and next steps
You understand embeddings when you can explain their geometry, diagnose retrieval failures, and design an evaluation that could prove your choices wrong.
Before you start
Why this matters
This page combines the full topic. Answer each scenario before reading its explanation. The goal is not to memorize vocabulary. It is to distinguish representation from truth, similarity from relevance, model quality from index quality, and an attractive demo from a system ready for real queries.
1Learn the idea
Read
Question 1: explain the representation
A teammate says, “Dimension 42 is the refund-policy dimension, and its value is 0.87, so this passage is 87% about refunds.” What is wrong?
Answer: Individual coordinates in learned embeddings usually have no stable human-readable label. Meaning is distributed across the vector, and rotating the space could change each coordinate while preserving useful geometry. 0.87 is a coordinate value, not a percentage, probability, confidence, or truth score.
A better explanation is: the model maps each text into a fixed-length vector, and relative positions support comparisons learned from training patterns. To assess refund retrieval, inspect ranked examples and labeled queries rather than one coordinate.
Also record the model version. A vector is meaningful only within the compatible space that produced it.
Read
Question 2: calculate and interpret
For normalized vectors q = [1, 0], a = [0.8, 0.6], and b = [-1, 0], what are the cosine similarities?
Answer: cos(q, a) = 0.8 and cos(q, b) = -1. Because all lengths are one, the dot products are also 0.8 and -1. Candidate a ranks above b under cosine or dot product.
What does 0.8 prove? Only that the vectors are strongly aligned under this toy geometry. In a real system it does not mean 80% relevant, does not prove factual correctness, and does not establish that the passage is safe to use. Interpret scores using a labeled set from the actual model and corpus.
If vectors were not normalized, raw dot product could favor a longer vector. Euclidean distance could produce a different order because it measures endpoint separation. Metric choice must follow the model contract and evaluation.
Read
Question 3: diagnose a retrieval miss
The correct parental-leave rule exists in a 90-page handbook, but search never returns it. List the investigation order.
Answer: First confirm the current handbook is in the allowed corpus. Check parsing to ensure the rule was extracted. Inspect chunk boundaries to see whether eligibility, duration, and heading stayed together. Confirm the correct model, passage mode, normalization, and version were used. Compare exact nearest neighbors to approximate-index output. Inspect metadata filters and reranking. Finally, check whether the interface discarded or misrepresented a good result.
This staged diagnosis matters. Replacing the model cannot recover text that parsing omitted, and loosening similarity cannot override a country filter that correctly excludes the passage.
Turn the failed query into a regression case with a relevant chunk and hard negatives such as an old policy or another country’s rule.
Read
Question 4: design a fair comparison
Model A has 1,536 dimensions and leads a public benchmark. Model B has 384 dimensions and is cheaper. Which should you choose?
Answer: There is not enough information. Build a representative evaluation set, run both with their required modes and metrics, and compare Recall@k, ranking quality, no-answer behavior, language and domain slices, latency, storage, throughput, privacy constraints, and cost.
The larger vector requires roughly four times the raw storage of the smaller vector at the same numeric precision. That may be justified by quality, but dimension count alone does not establish quality. Include lexical and hybrid baselines. Test exact-code queries where embeddings may underperform.
Predefine gates so the decision is not adjusted to favor the most impressive demo. Any permission-filter failure should disqualify a configuration regardless of average recall.
Read
Question 5: choose the retrieval unit
A policy document contains ten unrelated sections. Should you embed the whole document, each sentence, or chunks?
Answer: Start with structure-aware chunks that keep a coherent rule with its heading, conditions, exceptions, and necessary context. Whole-document embedding may dilute a precise rule. Sentence-level embedding may separate “30 days” from the clause it qualifies.
Test multiple chunk sizes and modest overlap. Track source offsets and deduplicate neighboring results. Document embeddings can support broad discovery or hierarchical retrieval, while chunk embeddings support precise evidence. The correct answer depends on measured queries, not a universal token number.
Keep structured constraints—country, policy version, effective date, and access rights—as metadata filters rather than relying on vectors to encode them perfectly.
Read
The build-readiness checklist
Before shipping, confirm:
Representation
- The input unit and purpose are explicit.
- Query and document modes follow the model instructions.
- Model name, version, dimensions, metric, and normalization are recorded.
- Incompatible vectors never share a searchable collection.
Corpus and access
- Sources are current, authorized, parseable, and removable.
- Chunks preserve the context required to judge them.
- Permissions and exact business constraints use structured enforcement.
- Source text, provenance, offsets, and timestamps remain available.
Retrieval and evaluation
- A lexical baseline and hard negatives are included.
- Quality is measured on held-out, representative queries.
- Results are sliced by language, domain, product, and risk.
- Approximate index recall is separated from semantic relevance.
- No-answer behavior and thresholds are validated locally.
Operations
- Latency and cost are tested under realistic load.
- Re-ingestion, deletion, migration, and rollback are rehearsed.
- Live failures feed a versioned regression set.
- Users can inspect evidence and report poor results.
Read
Bridge to vectors, databases, and RAG
An embedding is a vector, so the next mathematical layer is vectors and similarity: coordinates, magnitude, normalization, and nearest-neighbor search. You do not need advanced linear algebra to start, but precise geometric language helps prevent score mistakes.
A vector database stores embeddings with metadata and provides indexes for fast nearest-neighbor retrieval. The database does not create semantic quality by itself. It accelerates the comparisons defined by your model, metric, filters, and index configuration. Small collections may work with an ordinary database extension or exact in-memory search; scale and operations determine whether specialized infrastructure is useful.
Retrieval-augmented generation, or RAG, adds a generator after retrieval. The system embeds a query, retrieves source chunks, and gives those chunks to a language model as evidence. Good embeddings can improve candidate recall, but RAG also needs trustworthy sources, prompt boundaries, citations, context selection, and evaluation of answer faithfulness. Retrieval and generation remain separate failure points.
These layers form a chain:
content → chunks → embeddings → vector index → retrieved evidence → generated or displayed result
When something fails, inspect the chain from left to right. When choosing technology, start from the user’s information need and work backward.