Periagoge
Concept
3 min readself knowledge

Token Counting and Context Windows for Medical Documents

Large medical documents—radiology reports, surgery summaries, old test results—have size limits in AI systems called context windows; documents longer than the window get cut off or summarized incorrectly. Before you upload a huge stack of medical records to an AI tool, know whether it can actually process all of them, or whether you need to select the most recent and relevant ones.

Hypatia
Why It Matters

Tokens are the basic units language models process. One token ≈ 4 characters for English text. A 10-page medical record is roughly 5,000 tokens. ChatGPT's standard context window is 8,000 tokens. This means a single long medical record plus your question might exceed available space. Understanding token math prevents frustrating "context too long" errors and information loss.

Why this matters: medical documents are verbose. A discharge summary, lab results, imaging reports, and medication list easily exceed typical token budgets. If your context window is full, the AI can't hold your entire medical history while answering questions about it. You need strategies to work within these constraints.

Token Budgets Across Tools

GPT-4 standard: 8,000 tokens input. GPT-4 Turbo: 128,000 tokens. Claude 3 Opus: 200,000 tokens. Google Gemini Pro: 32,000 tokens. Perplexity: varies by model tier, typically 32,000-128,000 tokens.

These budgets split between your input (the medical documents and question) and the model's output (its response). A 128,000-token window doesn't mean you can paste a 128,000-token document and ask a 10,000-token question. You need to reserve space for the response itself. If you ask a complex synthesis question requiring detailed analysis, budget 5,000-10,000 tokens for output, leaving 118,000-123,000 for input.

Practical Token Counting

Most AI platforms display token counts when you paste text. Rough estimates: a single-spaced page of text ≈ 250-300 tokens. A medical lab result with multiple values ≈ 100-200 tokens. A full discharge summary ≈ 1,000-2,000 tokens. Medication lists with details ≈ 200-400 tokens each. These vary based on format and specificity.

Before uploading large medical documents, get a token count. Some tools show this. For others, use third-party token counters (many exist freely online) to paste your text. If a document is 6,000 tokens and your budget is 8,000, you have only 2,000 tokens for your question and AI response—insufficient for meaningful analysis.

Strategies for Large Medical Records

Compression via summarization: Use a first pass with an AI to summarize each document. "Summarize this discharge summary to essential clinical facts only, in under 300 tokens." This lets you fit multiple documents within budget. Quality suffers slightly, but coverage improves.

Chunking and chaining: Analyze one document per AI session. Upload discharge summary, ask questions about it, save the analysis. Then in a new conversation (new context window), upload the next document. Chain the sessions by sharing conclusions from prior sessions.

Selective inclusion: Don't upload entire records. Extract clinically relevant sections. Instead of the full 2,000-token discharge summary, copy only the "Active Problem List," "Current Medications," and "Assessment/Plan" sections—often 500-600 tokens capturing 80% of relevant information.

Use higher-capacity models for complex cases: If you have extensive medical history, use Claude Opus or GPT-4 Turbo instead of standard models. The token budget difference (128,000+ vs. 8,000) lets you include complete medical records without compression.

Quality and Safety Implications

Compressed or chunked information risks clinical inaccuracy. If your summarization process drops a critical medication or allergy, downstream AI analysis based on that summary will miss important safety considerations. Always verify that crucial information survived your compression steps.

Token limits also create strategic choices about what to upload. You might include recent labs but exclude old pathology reports. This makes sense for current care but might miss important historical context. Be intentional about what you omit.

The ideal approach: use the largest context window you have access to, upload complete records without compression, and ask focused questions. If your records exceed available context, negotiate that with a paid tier that offers higher token limits.

Try this: Gather a few pages of your medical records (appointment notes, lab results, medication list). Paste them into a token counter (search "AI token counter" for free tools). Notice how many tokens they consume. Then use ChatGPT's standard 8,000-token context and paste the same documents. Notice how little space remains for questions. Then try the same in Claude, which has vastly higher token limits, and experience the difference in what you can do with complete information intact.

Helpful guides
Hypatia
Daily Life & Decisions
Related Concepts
Peri
Questions about Token Counting and Context Windows for Medical Documents?

Peri can explain this concept, give practical examples, help you decide whether it applies to your situation, or recommend a journey if appropriate.

Ready to work on Token Counting and Context Windows for Medical Documents?

Explore related journeys or tell Peri what you're working through.