Embedding / Retrieval / Reranker Datasheet v1.0¶
Generative models learn to produce states. Embedding models learn to organize a space. Retrieval is geometry + search; reranking is a second, more expensive and more contextual relevance function.
Related: 01_GUT_GENERATIVE_AI_UNIFIED_ENGINEERING, 02_LLM_TRANSFORMER_INFERENCE_DATASHEET, 09_LOCAL_AI_INFERENCE_RUNTIME_DATASHEET.
1. Canonical pipeline¶
RAG is this pipeline, not a single model type.
2. Dense embedding¶
Encoder:
For L2 normalization of a nonzero vector (a zero vector requires an explicit reject/fallback policy):
Cosine similarity:
If both are normalized:
So cosine becomes dot product.
3. Euclidean distance¶
For normalized vectors:
Therefore cosine/dot/L2 can induce the same ranking under specific conditions, but not universally.
4. Pooling¶
A Transformer produces:
We need to obtain \(z\).
CLS pooling¶
Mean pooling¶
Weighted/attention pooling¶
In these sums, mask padding and let \(T\) count included tokens. For convex attention pooling, \(\alpha_t\ge0\) and \(\sum_t\alpha_t=1\) over included tokens; other weighted pooling must specify its coefficients. Pooling is part of the model recipe; it should not be swapped arbitrarily without respecting training.
5. Contrastive objective¶
With positive \(d^+\):
\(\tau\) is contrastive temperature.
Do not confuse¶
One acts on representation learning; the other on categorical decoding.
6. Hard negatives¶
A random negative may be easy:
A hard negative:
forces finer decision boundaries, but false negatives can train the model to push away semantically valid items.
7. Symmetric vs asymmetric retrieval¶
Symmetric¶
Same kind of object:
Asymmetric¶
Some models use different prompts/instructions:
Ignoring this recipe can degrade retrieval even with the correct weights.
8. Matryoshka Representation Learning¶
Training allows the embedding to be truncated:
with smaller dimensions preserving much of the geometry.
Trade-off:
Useful for changing cost without retraining. If scoring relies on unit norms, renormalize the nonzero retained prefix after truncation: a prefix of a unit vector is not generally unit length.
9. Multimodal embeddings¶
Instead of separate spaces:
models can be trained to occupy one shared space:
Qwen3-VL-Embedding in 2026 is an example of text/image/document-image/video retrieval with unified representations and Matryoshka dimensions.
10. Sparse retrieval¶
Classic probabilistic bag-of-words — BM25:
Dense retrieval does not make BM25 obsolete.
Dense captures semantics; sparse preserves exact lexical matching.
11. Learned sparse retrieval¶
A neural model may produce sparse vocabulary weights:
This combines interpretability/inverted indexes with learned semantic expansion.
12. Hybrid retrieval¶
Combine scores:
or combine ranks with Reciprocal Rank Fusion:
Ranks start at 1 and \(k>0\) is a smoothing constant. A document absent from a truncated list contributes zero for that list. RRF avoids directly calibrating score scales.
13. Late interaction¶
Instead of one vector per document:
keep token/subvector embeddings.
ColBERT-like MaxSim, using the normalization and token masks from the training recipe (the original ColBERT uses L2-normalized token embeddings):
This is a middle ground between bi-encoders and cross-encoders.
Trade-off:
14. Bi-encoder vs cross-encoder¶
Bi-encoder¶
Documents can be precomputed.
Cross-encoder¶
Tokens interact inside the same network.
Physical result¶
Bi-encoder:
Here O(1) counts one encoder call per query, independent of corpus size; its compute still depends on query length and the encoder architecture.
Cross-encoder for \(K\) candidates:
Hence the common pattern:
15. Reranker score¶
It may be:
- scalar regression;
- binary relevance logit;
- pairwise ranking;
- generative yes/no/relevance;
- listwise ranking.
Binary logit¶
A raw score is not automatically a calibrated probability.
16. Approximate Nearest Neighbor — ANN¶
Exact search over \(N\) vectors of dimension \(d\):
ANN trades exactness for latency/memory. ANN recall measures recovery of exact-search neighbors under a fixed metric; relevance recall in §22 measures recovery of labeled relevant documents. These are different targets.
17. HNSW¶
Approximate multilayer graph.
Practical variables:
M: degree/connectivity;efConstruction: indexing effort;efSearch: query exploration width.
Trend:
The actual curves are dataset-dependent.
18. IVF¶
Train \(n_{list}\) centroids:
Each vector is assigned to a cell.
At query time, inspect nprobe cells.
19. Product Quantization — PQ¶
Split the vector into \(m\) subvectors:
Quantize each subspace with a codebook.
Memory drops dramatically, but distance becomes approximate.
Do not confuse index PQ with encoder-weight quantization.
20. Chunking is part of the information model¶
Document:
Chunk length \(L\) and overlap \(O\) change the effective corpus.
Too short¶
- loses local context;
- creates ambiguous fragments.
Too long¶
- embedding mixes multiple topics;
- specific recall falls;
- reranker/generator receives noise.
Therefore:
not just the embedding model.
21. Contextual chunk embeddings¶
Problem:
may not know the title or parent document.
Pipeline solution:
or hierarchical retrieval.
This increases semantic specificity, but may inject information that is not present in the chunk itself.
22. Retrieval metrics¶
Use ranks starting at 1 and \(K\ge1\). Let \(Relevant\) be the set of judged relevant documents; specify the evaluated cutoff and treatment of unjudged documents. Missing returned slots count as nonrelevant for Precision@K.
Recall@K¶
Precision@K¶
Reciprocal Rank¶
when a relevant result is found; RR = 0 when none is found within the evaluated ranking/cutoff.
MRR¶
DCG¶
nDCG@K = DCG@K / IDCG@K when IDCG@K is positive. Recall@K is undefined when \(|Relevant|=0\), and this nDCG ratio is undefined when IDCG@K = 0. An evaluation protocol must declare whether these queries are excluded or assigned a stated convention (such as zero), apply it consistently, and report their counts and the aggregation denominator.
23. Retrieval threshold is not universal confidence¶
Similarity score depends on:
- model;
- normalization;
- corpus;
- query distribution;
- index approximation.
There is no universal rule such as:
“cosine > 0.8 = good.”
Calibrate on your own corpus:
24. RAG failure decomposition¶
For a nonempty relevant-document set \(R=Relevant\), the first two cases below describe complete misses. Partial evidence loss may also matter when a task needs multiple documents. Final error may be:
Retrieval miss¶
Reranker miss¶
Context-packing miss¶
Evidence was truncated or ordered badly.
Generator miss¶
Correct evidence reached the LLM, but the LLM still failed.
Separate these classes before “changing the LLM.”
25. Index memory accounting¶
Approximate dense FP32 storage:
FP16:
plus overhead:
1M vectors × 1024 dims × FP32 ≈ 4.096 GB before index/metadata overhead.
Do this calculation before choosing dimensionality.
26. Failure surfaces¶
- embedding anisotropy;
- semantic hubness;
- domain mismatch;
- false negatives during training;
- lexical miss in dense-only;
- semantic miss in sparse-only;
- overchunking;
- wrong query/document recipe;
- low ANN recall;
- reranker overfitting;
- stale index.
27. Snapshot 2026¶
Qwen3-VL-Embedding/Reranker illustrates the convergence of multimodal retrieval:
- text, image, document images, video;
- embedding + cross-encoder reranker as a coordinated pipeline;
- Matryoshka dimensions;
- long context.
The relevant trend is less “which model won a benchmark?” and more:
28. Engineering checklist¶
- Is the task symmetric or asymmetric?
- Does the model require an instruction prefix?
- Are embeddings normalized?
- Which metric does the index use?
- Which dimension is actually necessary?
- Is Matryoshka available?
- Which chunking strategy represents the right semantic unit?
- What is Recall@K before reranking?
- What is the reranker's marginal gain?
- Was the threshold calibrated?
- What is the index footprint?
- What is end-to-end latency, not just ANN latency?
- Dense, sparse, or hybrid?
- Can you distinguish a retrieval miss from a generation miss?
Snapshot references¶
- Qwen3-VL-Embedding and Qwen3-VL-Reranker — https://arxiv.org/abs/2601.04720
- TabPFN/other structured representations are covered separately in 14_TIME_SERIES_TABULAR_FOUNDATION_MODELS.