CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 3 · Lesson 22/56

    Embedding model context length: sizing the token window

    Select an embedding model context length based on source documents, expected queries, and optimization strategy

    16 min read
    2.31% of exam
    5 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Explain what an embedding model's context length is and what happens to text beyond it
    • Pick between databricks-bge-large-en and databricks-gte-large-en by measuring your longest chunk and your longest query
    • Explain why one model has to embed both the corpus and the queries, and what that means for the window you choose
    • Choose a set of chunk sizes to test well below the maximum context length instead of filling the window

    Key concept

    Embedding context length — The maximum number of tokens an embedding model reads from one input. Anything past that limit is cut off before the vector is computed, so the vector says nothing about the text that was dropped.

    1.What the token limit does to long inputs

    In a RAG pipeline, every chunk passes through an embedding model, which turns it into a dense vector that captures what the chunk means. Retrieval then compares those vectors with the vector of the user's query. Each embedding model has a context length: the most tokens it will read from a single input. Before you choose a model, find out its limit and compare it with the real text you will send it.

    Truncation fails quietly, and that is the danger. The pipeline runs, the index fills up, and every chunk has a vector. But in a 6,000-token passage embedded by a 512-token model, more than nine tenths of the text never affects the vector. A clause near the end of that passage can't be found by a query about it, because the vector contains nothing about the clause. You usually notice this the way a retrieval test would show it: questions about content late in long chunks keep missing, while questions about their opening lines work fine.

    Databricks Foundation Model APIs serve two embedding models, and their windows are very different. databricks-bge-large-en (BAAI General Embedding) reads up to 512 tokens. databricks-gte-large-en (General Text Embedding) reads up to 8,192. If the passages you need to embed are thousands of tokens long, the fix is a model whose window holds them. Tricks that keep the 512-token model in place don't work. More overlap between neighbouring chunks only copies boundary text into the next chunk, and the over-long chunk is still cut at token 512. Averaging two vectors made from the same truncated input doesn't recover anything either, because both vectors come from the same first 512 tokens.

    Checkpoint 1 of 8· Check yourself

    A team embeds 3,000-token policy chunks with databricks-bge-large-en. In retrieval tests, questions about a chunk's opening lines succeed, but questions about clauses near the end of the same chunks keep missing. What fixes this?

    Sources12

    2.Context length is not vector size or normalization

    A model card lists three numbers that are easy to confuse: how many tokens the model reads, how many dimensions its output vector has, and whether that vector is normalized. Each describes something different. The two Databricks-hosted English embedding models have the same output size and very different input windows.

    The two Foundation Model API embedding endpoints: same output size, different input windows
    EndpointEmbedding window (input)Vector dimension (output)Normalized embeddings
    databricks-bge-large-en512 tokens1024Yes
    databricks-gte-large-en8192 tokens1024No

    The table rules out two tempting arguments. First, a bigger window does not produce a bigger vector. Both models map any text to 1,024 dimensions, so choosing GTE for its 8,192-token window gives you no extra dimensions and no accuracy gain on text that already fits in 512 tokens. Second, normalization is not something you turn on to fix truncation. BGE already returns normalized embeddings, GTE does not, and neither fact changes how many tokens the model reads. When retrieval loses the ends of long chunks, normalized vectors still describe only the truncated text.

    Checkpoint 2 of 8· Match them up

    A model card for a Databricks embedding endpoint lists three properties. Match each property to what it describes.

    Tap a term, then the definition that fits it.

    Checkpoint 3 of 8· Exam question

    A team is building a RAG system over lengthy legal contracts averaging 6,000 tokens per semantically chunked passage. Retrieval quality tests show many chunks are silently truncated before embedding, causing key clauses near the end of long chunks to be dropped from the vector representation. The team is currently using the databricks-bge-large-en embedding model. Which change best addresses the root cause?

    Sources2

    3.Sizing the window for documents and queries

    The corpus is only half of what the window has to fit. At query time the user's question is embedded too, and it has to be embedded by the same model that embedded the chunks. Vectors are only comparable if they come from the same model. A BGE query vector and a GTE chunk vector are not in the same space, even though both have 1,024 dimensions.

    This means you size the context length against the longest input on either side. Start from the source documents: once chunking is done, how long is the longest chunk you will embed? Then look at the expected queries. In a chatbot, a query might be a sentence. In a compliance tool where analysts paste whole regulatory excerpts as the search text, a query can run past 3,000 tokens. The window has to hold the larger of the two, or one side gets truncated.

    Here is what that looks like in practice. The index holds 200-token clause chunks embedded with databricks-bge-large-en, and analysts paste 3,000-token excerpts as queries. The chunks fit comfortably, but every query loses everything after token 512, so relevance drops. Three tempting fixes don't work:

    • Embedding only the queries with GTE puts query vectors in a different space from the BGE corpus vectors, so the similarity scores mean nothing.
    • Cutting each query to 200 tokens to "match" the chunks throws away even more of what the analyst asked. Chunk size and query size don't need to match. Both just need to fit the window.
    • Raising the number of results returned brings back more chunks for the same truncated query vector, but the query vector still lacks the content that was dropped.

    The fix is to move both sides to a model whose window covers the long queries. That means re-embedding the corpus with databricks-gte-large-en, rebuilding the index on those vectors, and embedding incoming queries with the same endpoint.

    Checkpoint 4 of 8· Check yourself

    In an internal audit tool, policy text is split into 300-token chunks and embedded with databricks-bge-large-en. Auditors search by pasting 2,500-token report excerpts as their queries. Retrieval relevance is poor. What should the team do?

    Checkpoint 5 of 8· Exam question

    A compliance search tool lets analysts paste entire multi-paragraph regulatory excerpts, often 3,000+ tokens long, as the search query against a Databricks Vector Search index built over short 200-token clause chunks. The index and its queries both currently use the databricks-bge-large-en embedding model, and because the same model must embed both the corpus and incoming queries for the vector spaces to be comparable, long queries are truncated before embedding, degrading retrieval relevance. What is the best fix?

    Sources1

    4.Why the maximum context length is a ceiling, not a target

    A large window is a reason not to worry about truncation. It is not a reason to fill the window. Databricks' own example pipelines show this. GTE and the OpenAI embedding model used with Databricks both read 8,192 tokens, yet the guidance for each is to split the data into smaller chunks, and the OpenAI example sets its chunker to 1,024 tokens.

    The OpenAI example chunks at 1,024 tokens even though the model reads 8,192python
    max_chunk_tokens = 1024
    encoding = tiktoken.get_encoding("cl100k_base")

    There are two reasons, one on each side of the pipeline. On the retrieval side, one vector has to summarize the whole chunk, and long inputs blur it. Research cited in Databricks' retrieval guide (DeepMind's LIMIT) found that embeddings can miss basic information in long contexts. An 8,000-token chunk covering six topics gets one vector that sits somewhere between all six and matches none of them well. Larger chunks keep more context, but they make it harder to pinpoint the relevant information. On the generation side, the retrieved chunks have to fit in the LLM's context window together. Smaller chunks let the retriever pass the LLM a wider variety of examples instead of a few long blocks.

    In practice, find the limit first, then test several sizes below it. From the embedding side, the rule that chunk length and overlap must fit the model's limits means the chunk has to fit the window, but the window doesn't tell you the best chunk size. Retrieval evaluation does. Databricks gives these starting configurations:

    Starting chunk sizes to test, each well under an 8,192-token windowpython
    # Common configurations to test
    small_chunks = 256   # Better for precise fact retrieval
    medium_chunks = 512  # Balanced approach
    large_chunks = 1024  # More context per chunk

    Sometimes you need precise matching and a lot of surrounding context at once. One long embedding window can't give you both, because the long vector loses the precision. Parent-child chunking (search small, return big) handles this differently: it embeds and searches small child chunks, then returns their larger parent to the LLM. In Databricks' example the child size is 512 tokens, which fits even BGE's window, while the 2,048-token parent is stored as text and never embedded.

    Child chunks are embedded for precision; parent text is returned for contextpython
    # Record child and parent chunks in your source table
    for parent_chunk in create_chunks(doc, size=2048):  # Large for context
        for child_chunk in create_chunks(parent_chunk, size=512):  # Small for precision
            source_table.append({"text": child_chunk, "parent_text": parent_chunk})

    Checkpoint 6 of 8· Fill the gap

    A team on databricks-gte-large-en wants precise matching and enough surrounding context for the LLM. They use parent-child chunking. Which value completes the child chunk size in Databricks' example?

    # Record child and parent chunks in your source table
    for parent_chunk in create_chunks(doc, size=2048):  # Large for context
        for child_chunk in create_chunks(parent_chunk, size= ? ):  # Small for precision
            source_table.append({"text": child_chunk, "parent_text": parent_chunk})

    Sources345

    5.Choosing a context length to match the goal

    Choosing the context length means weighing what you measured (the longest chunk, the longest query) against what you are optimizing for. If the goal is recall over long passages, the window has to cover them. If the goal is low cost and low latency on short text, the window only needs to cover the short text. Model size is part of the same trade-off: larger embedding models generally perform better but use more compute, so you balance performance against efficiency for your use case.

    Take a support-search app over FAQ entries and troubleshooting snippets that average 180 tokens, none longer than 400. BGE's 512-token window holds every snippet whole, so no text is lost and the 1,024-dimension vectors are the same size GTE would produce. GTE's 8,192-token window would not be wrong, but it adds nothing for inputs this short. Since the goal is cost and latency, it isn't worth choosing. Picking the largest window "to be safe against future content" optimizes for a corpus the team doesn't have, at the expense of the one it does.

    Matching the embedding window to the inputs and the goal
    SituationLongest inputChoiceWhy
    Short troubleshooting snippets, minimize cost and latency400-token snippetdatabricks-bge-large-enThe 512-token window holds every snippet; a larger window adds nothing
    Semantically chunked legal contracts6,000-token passagedatabricks-gte-large-enOnly the 8192-token window embeds the whole passage without truncation
    Short clause chunks searched with pasted multi-page excerpts3,000-token querydatabricks-gte-large-en for corpus and queriesThe query is the longest input, and both sides must use the same model

    Checkpoint 7 of 8· Match them up

    Each team has measured its longest input and set a goal. Match each situation to the right embedding window decision.

    Tap a term, then the definition that fits it.

    Checkpoint 8 of 8· Exam question

    A support-ticket search application embeds customer FAQ entries and short troubleshooting snippets that average 180 tokens each, with no snippet exceeding 400 tokens. The team wants to minimize serving cost and query latency while keeping retrieval accuracy on these short passages. Which embedding model choice best fits this optimization strategy?

    Sources1

    Sources

    (5)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “If you pass chunks that exceed this limit, they will be truncated, potentially losing important information.”
      ↩︎ What the token limit does to long inputs
      “The retrieval query will be transformed at query time using the same embedding model used to embed chunks in the data pipeline.”
      ↩︎ Sizing the window for documents and queries
      “Larger embedding models generally perform better but require more computational resources.”
      ↩︎ Choosing a context length to match the goal
      “you will need to balance performance and efficiency”
      ↩︎ Choosing a context length to match the goal
      “If you pass chunks that exceed this limit, they will be truncated, potentially losing important information.”
      ↩︎ Key concept
      “The retrieval query will be transformed at query time using the same embedding model used to embed chunks in the data pipeline.”
      ↩︎ Exam trap 2
      “Know the maximum token limit for your chosen embedding model.”
      ↩︎ Exam trap 4
      “For example, bge-large-en-v1.5 has a maximum token limit of 512.”
      ↩︎ Checkpoint
      “If you pass chunks that exceed this limit, they will be truncated, potentially losing important information.”
      ↩︎ Checkpoint
    2. 2.
      “map any text to a 1024-dimension embedding vector and an embedding window of 8192 tokens”
      ↩︎ What the token limit does to long inputs
      “map any text to a 1024-dimension embedding vector and an embedding window of 512 tokens”
      ↩︎ What the token limit does to long inputs
      “This endpoint serves the English version of the model and generates normalized embeddings.”
      ↩︎ Context length is not vector size or normalization
      “does not generate normalized embeddings”
      ↩︎ Context length is not vector size or normalization
      “map any text to a 1024-dimension embedding vector and an embedding window of 512 tokens”
      ↩︎ Exam trap 1
      “map any text to a 1024-dimension embedding vector and an embedding window of 8192 tokens”
      ↩︎ Checkpoint
    3. 3.
      “Databricks recommends that you split the data into smaller context chunks so that you can feed a wider variety of examples”
      ↩︎ Why the maximum context length is a ceiling, not a target
    4. 5.
      “Recent work from DeepMind (LIMIT) shows embeddings can fail to capture basic information in long contexts, making this a nuanced decision.”
      ↩︎ Why the maximum context length is a ceiling, not a target
      “Larger chunks: More context preserved, but harder to pinpoint relevant information.”
      ↩︎ Why the maximum context length is a ceiling, not a target
      “Recent work from DeepMind (LIMIT) shows embeddings can fail to capture basic information in long contexts, making this a nuanced decision.”
      ↩︎ Exam trap 3

    Spotted a mistake, or was something unclear? Tell us.