A PDF longer than the context window cannot be sent whole, and a prompt longer than the window is cut before the model reads it. The fix is to split the PDF into chunks that fit, cutting on section breaks so each chunk is a complete idea, and to ask your question of each chunk in turn. The answers are then combined, instead of trusting one truncated read.
Prerequisites
- The PDF as text, with its section structure.
- The token count of the whole PDF and your context window size.
- A clear question that each chunk can answer in part.
Steps
Step 1: Count the PDF tokens
Count the PDF’s tokens and compare them with the window. A 12,000-token PDF does not fit an 8,192-token window, so it needs splitting into at least 2 chunks.
Step 2: Cut on section breaks
Split the PDF at its section headings into chunks of about 6,000 tokens each, leaving room for the question and the answer in the same request. Keep each chunk’s heading with it, so the model knows which section it is reading.
Step 3: Ask per chunk
Send each chunk with the same question and collect the answers. Then combine them into one answer, noting which chunk each part came from, so a missing part can be traced.
Worked example: Northgate Clinic 12,000-token handbook
The fictional Northgate Clinic splits its 12,000-token staff handbook into 2 chunks to answer a question about leave rules.
| Chunk | Tokens | Sections | Answer found |
|---|---|---|---|
| Chunk 1 | 6000 | Leave rules, part 1 | Annual leave: 25 days |
| Chunk 2 | 6000 | Leave rules, part 2 | Sick leave: 10 days |
| Combined | 12000 | Both parts | 25 days annual, 10 days sick |
The handbook becomes 2 chunks of 6,000 tokens each, and the combined answer gives 25 days of annual leave and 10 days of sick leave, each traced to its chunk.
Expected result. Every chunk fits the window with its heading, and the combined answer covers all the chunks. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.
Limits
- Splitting loses the connections between sections; a question spanning two sections needs both answers combined.
- A chunk that is itself longer than the window must be split again.
- This guide starts from PDF text; converting a scanned PDF to text is a separate step.
