Glossary
Contextual embeddings
Embeddings whose values depend on the surrounding text, from context-aware word vectors to chunk vectors that carry document context.
Contextual embeddings are vector representations of text that change with the text around them. The term has two common meanings. In language modelling it describes word or token vectors that depend on the sentence, so “bank” gets different vectors in “river bank” and “bank account”. In retrieval augmented generation it describes chunk vectors that carry information from the rest of the document, so a chunk can be found by queries about facts it does not state itself.
Static and contextual word embeddings
Early embedding methods such as word2vec and GloVe gave each word one fixed vector, learned from which words tend to appear together. That vector is the same in every sentence, so a word with several meanings is averaged into one point. ELMo and BERT, both published in 2018, compute a vector for each token from the whole input instead. BERT and later transformer models do this through the attention mechanism, and every modern embedding model used for search is contextual in this sense.
Contextual chunk embeddings in RAG
The retrieval meaning goes one level up. A document is split by chunking and each chunk is embedded on its own, so its vector reflects only the words inside it. A passage that says “the agreement terminates after 12 months” does not say which agreement, and its vector cannot either. Contextual chunk embeddings give each chunk’s vector some knowledge of its document, so it ranks for queries that mention the document’s subject. As a corpus grows, many chunks start to look equally similar to a query, the semantic collapse problem, and document context is one way to tell them apart.
How contextual chunk embeddings are made
Approach | How context gets in | Extra cost |
|---|---|---|
Prepended context | A language model writes a short description of the chunk’s place in the document, added before embedding | A model call per chunk at indexing |
Late chunking | The whole document is embedded in one pass, then token vectors are pooled into chunk vectors | Needs a long-context embedding model |
Contextualised chunk models | The model receives a chunk and its document together and returns a chunk vector | A specialised embedding model |
Metadata prefixes | The document title, section heading or path is added to each chunk’s text | Little, but the context is shallow |
Contextual retrieval is the best-known version of the first approach: Anthropic reported that contextual embeddings alone cut top-20 retrieval failures by 35% in its tests. Late chunking, described by Jina AI in 2024, uses an embedding model with a long context window to read the full document before splitting. Voyage AI’s voyage-context-3 is an example of the third approach. The fourth is the simplest and often worth doing first, since a heading such as “Termination” placed before a clause gives the vector something useful to match.
Trade-offs
Every approach makes indexing slower or more expensive than embedding chunks on their own, and the cost returns with each re-indexing run. Late chunking and contextualised models tie you to particular embedding models, so a model change means re-embedding everything to avoid embedding drift. Generated context can contain mistakes that then sit in the index. Contextual embeddings also do little for exact terms such as product codes or names, which is why they are usually paired with hybrid search. BM25 vs embeddings covers what each side of that pairing catches.
Contextual embeddings and Exabase
Deep Search indexes content stored as Resources automatically when it is written, with no embedding model to choose or chunking pipeline to run, and every text query combines semantic search with typo-tolerant keyword matching. Each matched chunk comes back attached to its source document with page numbers or timestamps, which handles much of the lost-context problem at answer time. Exabase does not document which embedding technique it uses internally or offer a setting for contextual chunk embeddings, so a specific method would sit in your own pipeline, for example on chunks from Extract.
For agent memory, Exabase Memory stores facts, preferences and events extracted from conversations rather than raw chunks. The end of the embedding pipeline argues for indexing at write time, RAG accuracy covers the sub-document approach, the searching resources guide explains the precision setting, and Exabase vs Pinecone compares a managed search layer with running your own vector index. The RAG pipelines use case shows the pieces together.
FAQs
What are contextual embeddings?
Contextual embeddings are vectors that reflect the text around a word or passage. For words, the vector depends on the sentence. For RAG chunks, the vector carries information from the rest of the document.
What is the difference between static and contextual embeddings?
Static embeddings give each word one vector in every sentence. Contextual embeddings compute a new vector for each occurrence based on the surrounding text, so different meanings of a word get different vectors.
Are BERT embeddings contextual?
Yes. BERT computes each token’s vector from the whole input, so the same word gets different vectors in different sentences.
How do contextual embeddings improve RAG?
They let a chunk match queries about its document’s subject even when the chunk never names it, which reduces missed retrievals. Measure the gain with recall@k on your own questions.
What is the difference between contextual embeddings and late chunking?
Late chunking is one way to produce contextual chunk embeddings. It embeds the whole document first and then splits the token vectors into chunks, with no extra model call.
Does Exabase use contextual embeddings?
Exabase does not document the embedding method behind Deep Search. It indexes stored content automatically and returns each matched chunk with its source document and page numbers or timestamps.
Related pages: Contextual retrieval, Late chunking, Embedding, Embedding model, Chunking, Semantic chunking, Dense retrieval, Hybrid search, Deep Search, RAG accuracy, Embedding drift.