Every embedding model has a context window, and input longer than that window is truncated before it is embedded. OpenAI third-generation embedding models accept at most 8192 input tokens, and Pinecone warns that exceeding a model context window means the excess tokens are thrown away, which can remove important context from the representation. A document that is silently truncated can never be retrieved for the facts in its missing part.
What you need
- The embedding model name and its max input in tokens
- The documents you plan to embed
- A tokenizer that counts tokens the way the model does
Step 1: Look up the max input for your model
Check the provider documentation for the max input tokens. For OpenAI text-embedding-3-small and text-embedding-3-large, the limit is 8192 tokens. Do not guess: different models have different limits.
Step 2: Count the tokens in each document
Count the tokens in every document before embedding, using the model own tokenizer, for example tiktoken with the cl100k_base encoding for third-generation OpenAI embedding models. Flag every document over the limit.
Step 3: Split the flagged documents before embedding
Split each flagged document into chunks that fit inside the limit, with a small overlap, and embed the chunks instead of the whole document. Never send a long document and hope the truncation kept the important part.
Worked example: synthetic truncation check for 4 documents
The table below is a synthetic example. It shows the expected result of checking document lengths; no documents were embedded.
| Document | Tokens | Action |
|---|---|---|
| Short FAQ | 400 | Embed whole |
| User guide | 7,500 | Embed whole |
| Long manual | 12,000 | Split into chunks |
| Annual report | 30,000 | Split into chunks |
Expected result (UNTESTED). the two documents under 8192 tokens are embedded whole, and the two over the limit are split first. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Truncation is silent: the API returns a vector with no warning that part of the input was dropped.
- Different models tokenize text differently, so a token count from one tokenizer does not apply to another model.
- Splitting a document changes what each chunk means, so re-check retrieval quality after splitting.
- A chunk that is too small can also hurt: it may lack the context a human would need to judge it.
