TokenPad
RAG

RAG Context Packer

Fit the best chunks into a fixed budget, and see what got dropped.

Retrieved chunks: text | relevance score

241 characters5 lines0 tokensor drop a file

Context PackerExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

Budget first, then fill it

Most systems retrieve a fixed k and hope it fits. That produces prompts that vary in size by a factor of three depending on chunk length, which makes cost unpredictable and occasionally overruns the window.

Packing to a budget inverts it: decide what you can afford, then fill that space with the best available chunks. Cost becomes a constant you chose rather than an outcome you observe.

The score threshold does more than the budget

A chunk scoring 0.22 is not weakly relevant, it is irrelevant — and including it makes the answer worse as well as more expensive. A minimum score is the cheapest quality improvement in a RAG pipeline.

If the threshold is dropping chunks you needed, the problem is upstream in retrieval or chunking. Packing cannot fix bad candidates.

Frequently asked questions

What score threshold should I use?
It depends on your embedding model and scoring scale, so calibrate rather than copy a number. Retrieve for twenty known queries, look at where relevance visibly stops, and set the threshold there.
Why number the chunks?
So the model can cite by index. It is the cheapest form of attribution — no URLs or source paths enter the prompt, and your application resolves the numbers.

More rag tools