Engineering · AI
Getting Page Numbers Right: Checking Citations Against the Full File
How aggressive compression and accurate citations came to work at the same time.
A student asks Cereby to explain cellular respiration from a 100-page biology textbook. The model has seen pages 45 and 46 in full and summaries of the chapters around them, and its answer quotes the book: "converts glucose into ATP energy." Which page is that on?
The model cannot know for sure: it never saw pages 1 to 44 or 47 to 100 in full. And a wrong citation in an educational product is not a small thing. It can support an accusation of academic dishonesty, send a student to the wrong source for a paper, or end their trust in the product the first time they check.
Our compression work (Compressing Files So File Chat Uses 92% Fewer Tokens and Trimming Huge Pages Without Cutting Out the Answer) took a 150,000-token document down to around 8,000 tokens without meaningfully hurting answers, which solved cost and latency and created this problem. This post describes citation verification, a second pass that finds every quote in the full original and attaches its real location.
The model could only cite what it was shown
Without a second stage, the only page numbers on offer are the ones the model infers from 5 to 8% of the book:
The obvious fix, giving the model the full document, would undo the compression entirely.
Verify against the source, not against what the model saw
So we split the job in two. The model answers from the compressed content and is instructed to mark its quotes explicitly, which makes them easier to find. A separate pass pulls those quotes out and searches the full original, which stays in the database, recording a page number for a PDF, a timestamp for a video, and a section heading for a web article. The answer goes out only after every quote has been looked up, and a quote the system cannot locate is marked unverified rather than dropped or given a made-up location:
The opening's quote, through both stages:
question "explain cellular respiration" (synthetic)
document a 100-page biology textbook, about 150,000 tokens
the model saw pages 45 and 46 in full, summaries of the chapters around them
its answer ... "converts glucose into ATP energy" ...
stage 2
quote "converts glucose into ATP energy"
searched the full original, pages 1 to 100
found on page 45
→ citation page 45
When the quote is not where the model put it
Matching the quoted text exactly works most of the time. When it does not, a normalization pass first reconciles small punctuation and whitespace differences. If there is still no exact match, the system falls back to phrases: key phrases from the answer are searched against the full document, and the best matches become citations with a lower confidence score, so downstream features and students can see the difference. Only a quote that survives none of these is marked unverified:
Opening a citation today shows the source text with the cited words found and marked:
A cited passage opened from an answer today, on a synthetic document.
How often it was right
We checked citations on 5,000 responses. Extraction finished in under a second, even for 200-page documents:
Page numbers were right 96.3% of the time, timestamps 94.8%, sections 97.1%, and the quotes themselves 98.2%. False citations that the check did not catch were 0.3%: cases where the phrase is in the document, but in a different context from the one the answer implied.
What this taught us
Never verify against what the model saw; verify against the source of truth. Compression is a rendering concern, not a storage concern: the full document stays in the database, and citation search always reads from there.
The fallbacks mattered more than we expected. A small share of answers do not mark quotes the way the instructions ask, and phrase matching with an honest confidence score means those answers still get citations instead of none.