Skip to content

Contextual embeddings: overview and reading path

The problem. RAG systems split documents into chunks and embed each chunk on its own. A chunk often depends on context it no longer contains:

  • a pronoun that refers to an entity introduced earlier;
  • a heading that says which product or year this section covers;
  • a definition stated three pages before.

Encoding the whole document as one vector is not a fix either: one vector cannot hold every detail of a long document. Contextual embeddings give each chunk its own vector, but compute that vector with the rest of the document, or the corpus, in view.

Four ways to give a chunk embedding its context Four panels. A: each chunk is encoded alone, so context is lost. B: an LLM writes a short context note that is prepended to the chunk before encoding. C: late chunking encodes the whole document once and pools token vectors per chunk span. D: corpus-conditioned embeddings first embed sampled neighbour documents and feed them to a second-stage encoder. A · Naive chunking (baseline) chunk 1 chunk 2 chunk 3 encoder ×3, separately v₁ v₂ v₃ "Its revenue grew 3%" — whose? when? The chunk no longer carries the entity or date. B · LLM-written context prefix whole doc + chunk LLM context note chunk text encoder + BM25 Index-time cost: one LLM call per chunk (prompt caching keeps the document cheap). C · Late chunking (pool after encoding) whole document → one forward pass long-context encoder: token vectors pool → v₁ pool → v₂ pool → v₃ Every token has attended to the whole document. Training add-ons: InSeNT, relevance distillation. D · Corpus-conditioned (CDE) sampled corpus docs stage 1 embed stage 2 doc + context this document Context = the corpus, not the parent document. Adapts term weighting to a new domain.
Original sketch. Four places to inject context: (A) nowhere, (B) in the input text, (C) inside the encoder before pooling, (D) from a sample of the corpus.
FamilyWhere context entersTraining needed?Index-time costAnchor reading
LLM-written context prefixText: a 50–100 token note is prepended before embedding and before BM25NoOne LLM call per chunkAnthropic Contextual Retrieval
Late chunkingEncoder: the whole document goes through one forward pass, then token vectors are pooled per chunkOptionalOne long-context pass per document (attention cost grows with document length, not chunk length)Late Chunking
Late chunking + contextual trainingSame as above, plus a loss that teaches the model to use the contextYesSame as late chunkingConTEB / InSeNT, Beyond the Gold Chunk, SitEmb
Corpus-conditionedEncoder: a sample of other documents conditions the embeddingYesCorpus-sample encoding once per corpus version (cached), plus a conditioned second-stage pass for every document and every queryContextual Document Embeddings (CDE)

A fifth, related idea works after retrieval: return only the relevant spans of a retrieved document. Cohere’s Context Focus does this inside a reranker, and query-aware context compression (Provence) does it as a separate model. Perplexity uses such a compressor as the teacher for its contextual embedder.

  1. Anthropic Contextual Retrieval (Sep 2024). The problem stated cleanly, plus the simplest fix. Fundamental.
  2. Late Chunking (Sep 2024). The architectural fix that most later work builds on. Fundamental.
  3. Contextual Document Embeddings (Oct 2024). The other meaning of context: conditioning on the corpus. Fundamental.
  4. ConTEB and InSeNT (May 2025). The first benchmark for this setting, plus a training recipe that uses same-document negatives.
  5. SitEmb (Aug 2025). Short chunks conditioned on a wider window, tested on long stories. Extended.
  6. Contextual Embeddings Beyond the Gold Chunk (Oct 2026). Distilled chunk relevance, answer-plus-evidence benchmarks, and image chunks. Current frontier.
  7. Cohere Rerank 5 Context Focus (Oct 2026). Span selection moved into the reranker. Extended.

Then read Q2D-Web, the document-level sibling benchmark of Q2D-Chunk.

BenchmarkSourceWhat a query is labelled withMain metricLink
ConTEBConti et al., 2025 (2505.24782)One gold chunk that needs document contextnDCG@10HF org
SitEmb book-plot retrievalWu et al., 2025 (2508.01959)Plot-level passages in long storiesRecallHF models
Context-benchEslami et al., 2026 (2610.38854)Answer sentence plus evidence, across 12 context-dependency types (synthetic injection)Answer@K, in-document evidence recallin paper
Q2D-ChunkEslami et al., 2026 (2610.38854)Answer groups plus evidence groups, 6,069 real base queries plus 1,876 paraphrased, 1,888 indirect and 1,886 scenario variants (11,719 wordings)Answer@10leaderboard
  • Granularity before context: Dense X Retrieval: What Retrieval Granularity Should We Use? (2312.06648). Indexes atomic propositions instead of passages.
  • Is chunking itself worth tuning? Is Semantic Chunking Worth the Computational Cost? (2410.13070). Finds semantic chunking’s costs are not justified by consistent gains over fixed-size chunks.
  • Head-to-head: Reconstructing Context: Evaluating Advanced Chunking Strategies for RAG (2504.19754). Compares late chunking with contextual retrieval directly.
  • The teacher idea: Provence: efficient and robust context pruning for RAG (2501.16214, ICLR 2025). Query-aware context pruning.
  • The backbone: pplx-embed-v2-late Technical Report (2610.29523). The vision-language ColBERT model that pplx-embed-v2-context is initialised from.
  • Product posts: voyage-context-3, voyage-context-4, Jina late chunking.
  • Document context plus corpus context. CDE conditions on the corpus; late-chunking methods condition on the document. The sources reviewed here do not show a cheap model that does both. Check related work before claiming novelty.
  • Labels without an LLM annotator per pair. Perplexity removes gold-chunk annotation but needs a strong production compressor as teacher. What is the open-source equivalent?
  • What should an evidence label mean? Context-bench injects evidence synthetically, while Q2D-Chunk derives it from real queries. How well each agrees with human judgments of “needed to verify” is open. This is close to nugget-evaluation territory.
  • Agents read differently. A search agent can fetch the whole document after a hit, so is chunk-level context still worth its index-time cost? Context Focus and Q2D-Chunk’s in-document evidence recall start to measure this.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    A corpus has 100,000 documents of 8,000 tokens each, split into 500-token chunks (16 per document). Estimate the index-time work for (a) naive chunk embedding, (b) Anthropic-style contextual retrieval without prompt caching (each call reads the document, the chunk and a 50-token instruction, and writes 100 tokens), (c) late chunking with an 8,192-token encoder, and (d) CDE with 512 first-stage context embeddings. Count tokens processed and, for the encoders, the quadratic attention term. How big is the index in each case?

    What a strong answer covers
    • (a) 16 passes of 500 tokens: 8,000 encoder tokens per document, 0.8B for the corpus. Attention term 16 × 500² = 4M per document.
    • (b) 16 calls × (8,000 + 500 + 50) = 136,800 LLM input tokens plus 1,600 output tokens per document, about 13.7B input tokens for the corpus, through a model far larger than an embedder. Then about 0.96B embedder tokens, because each chunk grows by its 100-token note.
    • (c) One 8,000-token pass: the same 0.8B tokens through the feed-forward layers, but an attention term of 8,000² = 64M per document, 16× the naive one.
    • (d) 16 second-stage passes of 512 + 500 = 1,012 positions: about 2× the naive token count and about 4× its attention term (16 × 1,012² ≈ 16.4M). The 512 first-stage encodings are a one-off per corpus.
    • All four store one vector per chunk (1.6M vectors), so the index is the same size. They differ in index-time compute and in what must be recomputed when a document, or the corpus, changes.
  2. Connect

    The section uses "contextual" for two different conditioning sets: the parent document (late chunking, InSeNT, pplx-embed-v2-context, SitEmb) and a sample of the corpus (CDE). State precisely what each kind of context lets the encoder compute and which failure it fixes, and construct one query where only document context can help and one where only corpus context can.

    What a strong answer covers
    • Document context resolves within-document dependencies: pronouns, section scope, the entity or period a chunk is about. It is a different input for every document.
    • Corpus context supplies corpus-level statistics, in effect a learned IDF: which features are common, and therefore uninformative, in this collection. It is shared by every document and query in the corpus.
    • Only document context helps: "ACME Q2 2023 revenue growth" against a chunk reading "revenue grew by 3%" whose company is named earlier in the filing. CDE still sees an orphaned chunk.
    • Only corpus context helps: self-contained documents in a sports corpus where a term like "NFL", rare in general training data, appears almost everywhere. A fixed encoder over-weights it.
    • The two compose rather than compete, which is why combining them is listed as open.
  3. Critique

    ConTEB scores one gold chunk per query with nDCG@10. Q2D-Chunk instead labels answer groups and evidence groups and reports Answer@10, evidence recall and tokens to full coverage. Identify the modelling error and the evaluation error the single-gold-chunk assumption causes, and argue whether answer-plus-evidence labels fully fix them.

    What a strong answer covers
    • Training error: a chunk that introduces the entity, date or definition is a negative, so contrastive learning pushes down exactly the chunks a reader needs to verify the answer.
    • Evaluation error: retrieving that evidence earns nothing, so a model that surfaces answer plus evidence ties with one that surfaces only the answer.
    • Answer and evidence groups give credit per group, and α-nDCG rewards covering different groups. This is nugget-style evaluation applied to chunks.
    • Not fully fixed: context-bench is built by synthetic injection and kept private, and Q2D-Chunk's labels come from LLM labelers and an LLM adjudicator, not humans, built by the model's authors from their own traffic. No agreement with human "needed to verify" judgments is reported.
    • A direct test: have humans judge whether the top-k chunks suffice to verify the answer for a sample of queries, and correlate each metric with those judgments.
  4. Design

    You run search for a deep-research agent that can open a full document after a hit, at about 5,000 tokens per read. Should you pay for contextual chunk embeddings at index time, or keep cheap non-contextual chunks and spend tokens at read time (or on reranker span selection such as Context Focus)? Give the trade-off and the experiment that decides it.

    What a strong answer covers
    • Contextual embeddings mainly help the first hit: the right document among look-alikes and the right chunk within it. If the agent never finds the document, no reading budget helps.
    • Once the document is found, in-document evidence recall and reading cost decide the rest. Q2D-Chunk's in-document evidence recall and tokens to full coverage measure exactly this.
    • Index-time cost is paid once per corpus version. Read-time cost is paid per query and per step, and grows when each call re-sends the conversation so far.
    • Experiment: fixed agent and token budget; arms = non-contextual chunks, contextual chunks, non-contextual plus span selection, both. Measure accuracy, tokens per task and searches per task, and classify failures as "document never found" versus "found but not used".
  5. Research idea

    Pitch a project that builds an encoder conditioned on both its parent document and a corpus sample. Give the hypothesis, the cheapest architecture that tests it, the evaluation, and the result that would falsify the idea.

    What a strong answer covers
    • Hypothesis: corpus context (feature informativeness) and document context (antecedents, scope) fix different errors, so their gains add on corpora with both look-alike documents and context-dependent chunks.
    • Cheap architecture: a late-chunking encoder whose input is prefixed with CDE-style cached, position-free corpus-sample embeddings, trained with sequence dropout so it degrades to plain late chunking.
    • Evaluation: a 2×2 (with and without each context) on ConTEB or Q2D-Chunk, an out-of-domain set, and a template-heavy corpus where documents differ in a few fields.
    • Falsified if the joint model is no better than the best single-context model, or if its gain survives replacing the corpus sample with random documents (then it is not using corpus statistics).
    • Practical risk: corpus-sample positions use up the encoder window and shrink document context, so report quality against how the window is split.