All tools
Context · free, no sign-up

What chunk size and top-k should I use for RAG?

Top-k is not a number you choose freely. It is whatever is left of the context after the system prompt, the question and room to answer — divided by your chunk size.

5 inputs5 questions answeredUpdated for 2026 hardware
RAG Chunk Size Calculator — What chunk size and top-k should I use for RAG?
Answer first

The short answer

Computed from this tool’s default settings — context length and the rest as most people start. Change them below for your own case.

Chunks you can retrievetop-k 13

A 8,192 token window leaves 6,692 tokens for retrieval, so top-k 13 at 512-token chunks. Smaller chunks buy more distinct hits when the answer is spread across documents.

The calculator

RAG Chunk Size Calculator

How many chunks fit in your context once the prompt takes its share.

Your setup
8,192
512
10

Output shares the context window. Forgetting this is the usual cause of truncated answers.

Chunks you can retrievetop-k 13

A 8,192 token window leaves 6,692 tokens for retrieval, so top-k 13 at 512-token chunks. Smaller chunks buy more distinct hits when the answer is spread across documents.

Context free for retrieval6,692 tok
Unique text retrieved5,990 tokAfter overlap duplication
Reserved for output1,000 tok
System prompt500 tok
Chunk sizetop-kTokens usedRecall
128526,656Good recall
256266,656Good recall
512136,656Good recall
1,02466,144Good recall
2,04836,144Tight
Inputs

What each setting changes

Every input moves the result for a reason. This is what each one does and where to find the value for your own machine.

SettingDefaultWhat it changes
Context length8192 tokensAnywhere from 1,024 to 131,072 tokens.
Chunk size512 tokensAnywhere from 64 to 2,048 tokens.
Chunk overlap10 %Anywhere from 0 to 50 %.
System prompt500 tokensYour own figure in tokens, starting from 500. Change it to match what you actually run.
Room for the answer1000 tokensOutput shares the context window. Forgetting this is the usual cause of truncated answers.
Worked examples

Real answers across context length

The same calculation run at a range of settings, with everything else left at its default. These are computed by the tool itself, not written by hand.

Context lengthChunks you can retrieveContext free for retrievalUnique text retrievedReserved for output
1,024top-k 00 tok0 tok1,000 tok
33,536top-k 6232,036 tok28,570 tok1,000 tok
66,048top-k 12664,548 tok58,061 tok1,000 tok
98,560top-k 18997,060 tok87,091 tok1,000 tok
131,072top-k 253129,572 tok116,582 tok1,000 tok

After the system prompt and answer there is barely room for one chunk. Shrink the chunk size, trim the system prompt, or use a longer-context model.

Method

How this is calculated

No lookup tables and no invented constants. Here is the arithmetic, so you can check it against your own numbers.

The context window has to hold the system prompt, the retrieved chunks, the question and the answer. Top-k is whatever is left after the other three, divided by the chunk size — not a number you pick freely.

Overlap buys recall at the cost of retrieving the same text twice. Ten to twenty percent is the usual range; past that you are spending context to read duplicates.

These are well-founded engineering estimates, not benchmark results. Your quantisation, runtime and context length all move the real number, and usable memory is an assumption rather than a specification. See the full methodology for every assumption behind these figures.

Use cases

Who this is for

The three situations that bring people to this calculation.

Use case 01

Building RAG

Size chunks and top-k against a real window.

Use case 02

Truncated answers

Find the room you did not leave for output.

Use case 03

Tuning recall

Trade chunk size against number of hits.

Walkthrough

How to use this calculator

Four steps, no account, nothing leaves your browser.

  1. Set context length

    Start at the top of the panel. Every figure recalculates as you change it — there is no submit button, because watching the number move is the point.

  2. Adjust the rest to match your setup

    4 further settings: chunk size, chunk overlap, system prompt, room for the answer. Defaults are the common case, so change only what differs for you.

  3. Read the headline, then the table

    The large figure answers the question. The table underneath shows how the answer changes across nearby settings, which is usually where the decision actually gets made.

  4. Check it against the method

    The arithmetic is written out above. If a number looks wrong for your hardware, the assumptions are the first place to look — usable memory and quantisation are the two that vary most.

Questions

What chunk size and top-k should I use for RAG: common questions

The questions people ask about this, answered without hedging.

What chunk size is best for RAG?

For prose, 256–512 tokens retrieves precisely without losing the surrounding argument. Larger chunks bring more context per hit but fewer distinct hits, which hurts when the answer is spread across documents.

What is the best chunk size for RAG?

256–512 tokens for prose. Small enough to retrieve precisely, large enough to keep the surrounding argument intact. Code and tables often want larger chunks with structural boundaries rather than fixed sizes.

How much chunk overlap should I use?

Ten to twenty percent. It stops an answer being split across a boundary. Beyond that you are spending context to read the same sentences twice.

How many chunks should I retrieve?

As many as fit after reserving room for the output — usually five to ten. More retrieved context is not automatically better; irrelevant chunks actively distract.

Why are my answers getting cut off?

Because the retrieved context filled the window and left no room to generate. Input and output share the same budget, and reserving output space is the fix.

The rest of the set

All 50 run on the same arithmetic, so answers across them agree.

Coverage

Searches this page answers

Different ways of asking the same question, all resolved above.

rag chunk sizebest chunk size for embeddingstop k ragchunk overlap ragrag context window planninghow many chunks to retrieverag truncated answerswhat chunk size and top-k should i use for ragrag chunk size calculatorrag chunk size calculator onlinefree rag chunk size calculator
Next step

Now find the models that fit

Sizing is only half the problem. Model Radar takes your hardware and shows which models actually run on it, ranked by what they are good at — the same arithmetic as this page, applied to every model worth running.