Context is Gold to find the Gold Passage: Evaluating and Training Contextual Document Embeddings

Max Conti, Manuel Faysse, Gautier Viaud, Antoine Bosselut, Céline Hudelot, Pierre Colombo · DOI

Introduction

In modern Retrieval-Augmented Generation (RAG) pipelines, the standard practice is to split long documents into smaller "chunks" to fit within the context windows of embedding models. However, this independent chunking strategy introduces a significant "context gap." When a chunk is embedded in isolation, it loses critical document-wide information, such as coreferences or thematic framing. For instance, a sentence like "He became emperor in 1804" is semantically opaque if the antecedent "Napoleon" appeared in a previous paragraph.

While some solutions involve using Large Language Models (LLMs) to prepend context to every chunk, this approach is computationally expensive and slow. This paper introduces InSeNT (In-Sequence Negative Training) and the ConTEB benchmark to address the evaluation and efficiency gaps in context-aware retrieval.

Methods: Late Chunking and InSeNT

The core of the proposed approach is Late Chunking (LC). Unlike traditional methods that chunk text before encoding, LC passes the entire document through a long-context transformer. This allows every token to attend to every other token in the document. Chunk-level representations are then derived by pooling the contextualized token embeddings at the end.

Overview of the InSeNT training framework and the inference-time advantage of contextualized embeddings over independent embeddings.

To optimize these embeddings, the authors developed InSeNT, a post-training method using a specialized contrastive loss. InSeNT balances two types of negatives:

  1. In-batch negatives: These ensure the chunk absorbs enough document context to be distinguishable from chunks in other documents.
  2. In-sequence negatives: These ensure the chunk retains its specific local meaning, preventing it from collapsing into a generic document-level vector.

The ConTEB Benchmark

To accurately measure the impact of context, the authors curated ConTEB (Contextualized Text Embedding Benchmark). ConTEB includes datasets specifically designed to test coreference resolution, structural understanding, and context disambiguation. It combines repurposed academic sets (e.g., NarrativeQA) with new, custom datasets covering domains like ESG reports and insurance, where document structure is paramount.

Results and Discussion

The results demonstrate that contextualization is essential for robust retrieval. As shown in the figure below, independent embeddings ("Non-Contextual") suffer a sharp decline in performance as the proportion of context-dependent paragraphs increases. In contrast, the contextualized approach remains stable and high-performing.

Retrieval performance (nDCG@10) as a function of the percentage of context-dependent paragraphs in the corpus.

Key performance highlights include:

  • Superior Accuracy: ModernBERT trained with InSeNT achieved an nDCG@10 of 75.6 on ConTEB, significantly outperforming the 52.0 baseline.
  • Efficiency: InSeNT matches the quality of LLM-based contextual retrieval while being approximately 120 times faster at indexing (15.26 ms/doc vs. 1890.94 ms/doc).
  • Model Agnostic: The method also improved multi-vector models like ModernColBERT, raising its performance from 59.1 to 70.6 nDCG@10.

Conclusion

Contextual document embeddings represent a significant step forward for RAG systems. By allowing chunks to "talk" to their neighbors during encoding and training with InSeNT, models can achieve LLM-level retrieval quality without the associated latency and cost. Future work will focus on scaling these methods to million-token context windows and multimodal document understanding.

Summary updated

BibTeX
@misc{conti2025context,
  author = {Max Conti and Manuel Faysse and Gautier Viaud and Antoine Bosselut and Céline Hudelot and Pierre Colombo},
  title = {{Context is Gold to find the Gold Passage: Evaluating and Training Contextual Document Embeddings}},
  year = {2025},
  eprint = {2505.24782},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.24782},
}
Figure