New Tool Radar

AI Concepts

How to Check the Context Window Before You Paste a Long Document into Ollama

Find out how many tokens the running model can actually hold before you paste a long document into it, so a summary that silently drops the first half is not mistaken for a weak model.

Schematic showing a long document being cut off by a small context window, with only the tail end reaching the model.

Before pasting a long document into a local Ollama chat, find out how many tokens the running model can actually hold. A document longer than the window is cut without warning, and the answer is then written from only part of what was pasted.

Ollama’s own pages disagree. The FAQ states: “By default, Ollama uses a context window size of 4096 tokens.” The Modelfile reference lists num_ctx with “(Default: 2048)”. Independent guides report that Ollama’s context-length documentation scales the default by available graphics memory — 4,096 tokens under 24 GiB, 32,768 from 24 to 48 GiB, 262,144 at 48 GiB or more — and that over-long prompts are truncated silently, with no error in the response. None of those numbers is the number that matters. The number that matters is the one the running model is actually using, and that is what ollama ps shows.

Use the practice check

A local chat with llama3.1:8b, and a fictional document of about 3,000 English words — roughly 4,000 tokens, right at the 4,096-token default window. The document opens with the sentence: “The lighthouse is checked at noon.”

Check the window before you paste

Expected result. We checked the Ollama FAQ, the Modelfile reference, the troubleshooting page, and two independent guides. We did not run Ollama. The checks below are what to expect if the window is as stated; run them yourself on your own machine.

1. Look for a num_ctx line in the model’s Modelfile

Run:

ollama show --modelfile llama3.1:8b

Expected result: no PARAMETER num_ctx line is present. Absence means the model uses the runtime default, not the large window advertised on the library page.

2. Read the CONTEXT column while the model is loaded

Send the model any message, then run:

ollama ps

Expected result: the CONTEXT column reads 4096 on a machine with under 24 GiB of graphics memory. That number — not any documentation page — is the window in effect. (Models stay loaded for 5 minutes after the last request by default, so run ollama ps inside that window.)

3. Compare the document with the window before pasting

Count the words in the document. About 3,000 English words is roughly 4,000 tokens, so a 3,000-word document fills a 4,096-token window on its own, before the question and the answer take their share.

Expected result: a document far longer than the CONTEXT number in tokens does not fit, and the model will answer from only part of it. Split a long document before pasting, or raise the window first.

4. Raise the window for one chat, then verify it took effect

Inside ollama run, use:

>>> /set parameter num_ctx 32768

Or, when using the API, pass "options": {"num_ctx": 16384} to /api/chat. Then send a message and run ollama ps again.

Expected result: the CONTEXT column shows the new number. If it does not, the setting did not take effect — check the spelling (num_ctx, with an underscore) and try again.

5. Check whether the larger window still fits in graphics memory

Read the PROCESSOR column in the same ollama ps output. The FAQ lists the three cases: 100% GPU means the model loaded entirely into the GPU, 100% CPU means entirely into system memory, and a split such as 48%/52% CPU/GPU means it loaded partly onto both.

Expected result: if the processor column shows a CPU/GPU split after raising num_ctx, the larger window no longer fits in graphics memory — reduce num_ctx again.

6. Test whether the start of the document survived

Paste the document, then ask the model to quote the sentence from its first paragraph: “The lighthouse is checked at noon.”

Expected result: the model quotes the sentence. If it cannot, or answers from the end of the document only, the beginning was cut — the window is still too small for this document.

Verdict table

Check Expected result Pass?
Modelfile has no num_ctx line Model uses the runtime default —
ollama ps CONTEXT column 4096 on a machine with under 24 GiB graphics memory —
Document vs window ~3,000 words ≈ 4,000 tokens, fills a 4,096-token window —
After /set parameter num_ctx 32768 CONTEXT column reads 32768 —
PROCESSOR column after raising Still 100% GPU; a split means reduce num_ctx —
Quote test Model quotes the first-paragraph sentence —

Related guides: How to Pick a Local Model Size That Fits Your RAM — choose a model that fits your memory. How to Check Whether Ollama Is Using Your GPU or CPU — read the Processor column in the same ollama ps output. Check if a PDF needs OCR — the same “check before you trust it” pattern, for scanned documents. Scanned PDF tables to Excel — another check-first workflow for long documents.

Limits

  • Raising the window costs memory: the context cache grows with the window, and a window that spills onto the CPU runs slower. This guide also does not cover cloud-hosted models, which have their own limits.
  • UNTESTED — Ollama was not run; all results above are expected results. The document in the practice check is fictional.

Sources

See all