Repository navigation
Your retrieval budget may be based on a context window you are not actually being served #23253
Replies: 1 comment 1 reply
|
This matches the boundary I would treat as unsafe for RAG: LlamaIndex can budget against configured metadata, but it cannot discover a provider’s effective KV-cache/concurrency ceiling before the request. A practical fail-closed pattern is:
That makes the retrieval test separable from serving limits: hold the index/query constant, vary only the configured ceiling/provider, and report (a) retrieved evidence, (b) rendered-token count, (c) accepted/rejected, and (d) whether the answer used every cited node. References: https://docs.llamaindex.ai/en/stable/api_reference/service_context/prompt_helper/ and https://docs.llamaindex.ai/en/latest/module_guides/models/llms/usage_custom/ |
Uh oh!
There was an error while loading. Please reload this page.
Disclosure up front: I build Grunz, a hosted chat + coding agent on open-weight models. Nothing to sell here — this is a retrieval-sizing problem I keep hitting and I suspect it affects more LlamaIndex users than realise it.
The number your retrieval budget is based on is probably wrong
Chunk size, top-k and reranking all get tuned against an assumed context budget. That budget is normally taken from the model card.
The model card number is a property of the weights. The number you actually get is a property of whoever serves them — a KV-cache budget the operator traded off against concurrency. Across the hosted endpoints I've tested, most serve around 32K regardless of what the card claims. A few reach 256K. I have not found one actually serving the 1M figures that show up in release posts.
So if you tuned top-k against an assumed 128K and you're being served 32K, you are silently over-retrieving. And the failure is not an error — it's truncation. Your carefully reranked chunks get cut, usually from the front, and what reaches the model is a prefix of what you assembled.
Why this is nastier in RAG than in chat
In chat, losing early context degrades gracefully — the conversation just gets a bit dumber. In RAG it degrades misleadingly:
Worse, it's provider-dependent. The same index and the same query can behave differently across two providers serving the same model, which reads as non-determinism rather than as a configuration difference.
What I'd like to know
Does LlamaIndex have a way to assert or discover the real served context for the LLM in use, rather than reading
context_windowfrom static model metadata? If a node postprocessor or the token counter is already doing something smarter here, I'd like to be pointed at it.Is there a recommended pattern for failing loudly instead of truncating silently? What I want is for an assembled prompt that exceeds the real ceiling to raise, not get quietly cut — even at the cost of a failed query. A silently truncated RAG answer is worse than no answer, because it looks fine.
Has anyone benchmarked retrieval quality across providers holding the index constant? If the served-ceiling effect is as large as I think, provider choice should show up as a retrieval-quality difference, which would be a slightly alarming result worth having.
Practical discovery method in the meantime, in case it's useful to anyone: send a deliberately oversized prompt and read the error text — providers usually leak the true maximum there. Their docs have not been reliable for this.
All reactions