Why Migrating From OpenAI 8,191 Tokens to gemini-embedding-001 Silently Drops 75% of Long Chunks
Teams migrating pipelines tuned for text-embedding-3-large (8,191 tokens) or BGE-M3 (8,192 tokens) send 3,000..6,000-token Markdown files and legal sections into gemini-embedding-001. Because autoTruncate defaults to true, zero exceptions appear in logs while indemnify clauses, pricing footnotes, and bottom-of-file functions vanish from your vector index.
Immediate Python Fix: Fail-Closed count_tokens Check + 1,800-Token Sub-Span Pooling
from google import genai
from google.genai import types
client = genai.Client()
def assert_within_gemini_window(text: str, max_tokens: int = 2048) -> int:
tok = client.models.count_tokens(model="gemini-embedding-001", contents=text).total_tokens
if tok > max_tokens:
raise ValueError(f"Chunk has {tok} tokens (> {max_tokens}); split before embedding!")
return tok
Never Lose Tail Clauses: Voxell Forge Structure-Aware Parent-Span Retrieval
Voxell Forge splits long PDFs, contracts, and source files along AST and heading boundaries, conditions every child span with C_corpus (99.04% Recall@20), and returns full cited parent context ($39/mo Builder annual; $199/mo Team annual with 0.8849 nDCG@10 Max reranking).