Writings

How should an AI read a 4 MB document?

· 2 min read

Ask an AI assistant about a long document and it usually goes one of two ways: the document doesn't fit, or it fits and the answer still misses the one table that mattered. A big audit report or court record can easily come to 4 MB of text, which is somewhere around a million tokens. No context window holds that comfortably, and even when one does, it's slow and expensive.

I've been thinking about how tools for an assistant, like an MCP server, should hand a document like that to a model.

the usual options

  • Paste the whole thing. Simple, but most long documents don't fit, and the ones that do fill the context and cost the most.
  • Chunk and retrieve. The standard RAG answer. It finds passages well, but the model only sees the pieces retrieval picked, with no sense of what else is in the document.
  • Let the model navigate. Give it tools to see the document's shape and read the part it needs, the way a person skims a contents page.

For a known set of questions, retrieval works well. But when the model is someone else's assistant and the question could be anything, I think navigation wins. People don't read a 400-page report by searching it for similar sentences. They look at the contents, jump to the right section, and read around it.

the tools

A small set of tools, in the order a person would use them:

  • Where it came from: the source, the publisher, the date.
  • An overview: what kind of document it is and how long.
  • Its contents: the pages, tables and charts in it.
  • Read one part: a page, a table, or a range.
  • Search inside it: find which pages mention a word, a name or a number.

not misleading the model

The tools are the easy part. Most of the thought should go into what stops the model from being misled:

  • A fixed cap on every read, which the caller can't raise, and a note every time text was cut. A model should never mistake a cut-off for the end.
  • Pages that couldn't be read are listed up front. A scanned page with no text looks exactly like a blank page, and a model will happily treat it as one.
  • Numbers read off charts are marked as estimates, so they aren't quoted as exact figures.
  • Every read links to its source, so an answer can be cited and checked.
  • Failures come back as failures, not as text. An error message that looks like content gets summarised as if it were true.

reading on demand

If documents need converting to text first, don't wait to convert everything. Let opening a document be what triggers its conversion. The tools then cover everything from the start, and the documents people actually ask about get done first.

what I took from it

  • Design tools for how models fail, not just for what they need. Truncation, blank pages and estimates are where answers go wrong.
  • Hard limits belong on the server. A cap the caller can raise isn't a cap.
  • Citations are part of the interface, not an extra. If a tool can't say where text came from, the answer can't be checked.
book a chat