New Tool Radar

AI Concepts

How to Budget the Context Window Before Summarizing a Long Document

Count tokens and plan the summary in chunks before a long document overflows the context window.

Schematic with three numbered boxes: count the tokens, compare with the window, split and combine.

A context window is the total text a model can see at once, counted in tokens, and a long document can easily exceed it. Ollama 0.10.0 made ollama ps show the context length of loaded models, which helps you see the limit you are working with. Budget the tokens before you send anything, so the model sees the whole document or a planned part of it.

Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.

Prerequisites

  • The document and its word count
  • The model context window size in tokens
  • A token counter or the rule of thumb that one token is about four characters of English text

Steps

1. Count the document tokens

Count the tokens with a counter, or estimate by dividing the character count by four. Write the number down.

Expected result: A token count exists, for example about 60,000 tokens.

2. Compare with the window

Compare the count with the model context window, minus room for the prompt and the reply. If the document is bigger, plan to split it.

Expected result: The document fits, or a split plan exists with a chunk count.

3. Split into chunks with overlap

If it does not fit, split the document into chunks that each fit, with a small overlap so nothing is lost at the joins.

Expected result: A chunk list exists, each chunk under the window size.

4. Summarize each chunk, then combine

Summarize each chunk on its own, then summarize the chunk summaries into one final summary.

Expected result: One final summary exists, built from the chunk summaries.

Worked example

A practice report has about 60,000 tokens and the model window is 32,768 tokens, so it was split into three chunks.

Chunk Tokens Summary lines
Part 1 21000 6
Part 2 20000 5
Part 3 19000 6
Totals 60000 17

Expected result: Three chunks total 60,000 tokens and produce 17 summary lines, which combine into one final summary (UNTESTED – confirm it yourself.)

Verdict table

Check Expected result Pass?
Count the document tokens A token count exists, for example about 60,000 tokens. –
Compare with the window The document fits, or a split plan exists with a chunk count. –
Split into chunks with overlap A chunk list exists, each chunk under the window size. –
Summarize each chunk, then combine One final summary exists, built from the chunk summaries. –

Limits

  • A rough token estimate can be off by a tenth or more; use a real counter before a long job.
  • Chunk summaries can lose links between sections, so read the final summary against the original headings.

Sources

See all