Engineering · AI · Performance

Auditing Cereby's File Compressor: Why Answers Came From the Preface

14 min read

What eight months of real textbooks did to the file compression we wrote about in February, and how a public-domain book helped us fix it.


A student attaches a textbook hundreds of pages long and asks how natural selection could produce an organ as complex as the eye. The answer is good: it quotes the right chapter and explains the argument. Then comes the most natural follow-up there is: "explain more."

When we replayed that exchange against Charles Darwin's On the Origin of Species, the follow-up was answered from the wrong end of the book. The model had been handed 26 of the first 48 pages and one page from the middle: the title page, a note on the ebook edition, two epigraphs, the contents, the introduction and parts of the first two chapters. Not the chapter about the eye. The model wrote something fluent, polite and beside the point, which looks less like a bug than like the AI being a little dim, so nobody reports it.

This is part 3 of our series on fitting a large file into one answer, after Compressing Files So File Chat Uses 92% Fewer Tokens and Trimming Huge Pages Without Cutting Out the Answer, both from February. This time we audited the file compressor, the step that picks which parts of an attached file the model reads with each question, against a real book, and found 22 flaws.

The system we described was not the system running

By October, part 1's page ranking had no callers, and the page summaries some files still got at upload were never read. An upload-time prefetch also embedded every paragraph under keys nothing read. What ran was part 2's chunk approach stretched over the whole file: score every chunk against the question's keywords, then let embeddings (vectors that capture meaning, so "body parts they no longer use" can match "rudimentary organs") re-rank the 50 best keyword matches. When a question shares no words with its answer, there are no matches, and "the 50 best" is the first 50 chunks in file order. The embeddings were added for exactly the case where vocabulary does not line up, and in exactly that case they were shown only the preface:

We had never measured this on a real book, so we built an eval: the real compressor over Darwin (public domain, 412 pages) and ten questions, among them a paraphrase, a question in Spanish, one that hinges on a three-letter word, two bare follow-ups and two requests about the whole book. Eight have a known answer passage. Before any change, that passage reached the model in 3 of the 8, with or without embeddings.

Decide what was asked, then rank

The new compressor works out what kind of request it has before it ranks anything:

"Make notes on this", "summarize this book" and our Create Note button's message name nothing to search for (ranked by its words, "make notes" searched the book for "notes"), so they now get coverage: as many chunks as the budget holds, spaced evenly across the file. A bare follow-up like "explain more" borrows the last question that named something. Here is the book as the eval saw it, front matter on the left and the index on the right. The last row is "summarize this book", which before the change got much the same pages as the first. Red was sent only because of where it sits in the file, green was chosen for what was asked, and grey was not sent:

The ranking changed twice. The embeddings' pool adds 50 chunks spaced across the file to the best keyword matches and, when keywords found little, the neighbors of the chunks closest in meaning: the answer often sits beside the nearest page the spread landed on. And ranks are fused, not scores. The old blend of 40% keyword score and 60% similarity mixed keyword scores that bonuses could push past 1 with similarities that sit in a narrow band; reciprocal rank fusion (each ranking adds one over a constant plus the chunk's position in it) puts both on one scale. Each run of text in the excerpt now starts with its page label, each gap names the pages it skips, and a header line lists the pages shown.

Smaller flaws sat on the same path, and were just as silent. The embedding call had no timeout (one took 31 seconds in our eval); now, after four seconds, the excerpt is built from keywords alone. Headings and one-line formulas were dropped before scoring. A 50-chunk cap left a vague question on a book with short paragraphs using about half its budget. And a quadratic keyword deduplication blocked the server for 2.3 seconds on 4.5 MB of synthetic text.

The index pages in the diagram above came last. Once the cache and the prompt were fixed (both below), the back-of-book index started winning almost every question. "Galapagos Archipelago, birds of, 390, 398" is dense with a question's words, answers nothing, and points at the printed edition's pages, not ours; one excerpt carried seven index pages. A chunk where most lines end in page references now counts as an index or a contents page, and ranked excerpts leave it out unless nothing else matches.

The cache that answered the wrong question

A compressed book is cached for ten minutes, and the key was the file plus the question's keywords. Only words longer than three letters counted, so "What is DNA?" and "What is RNA?" both had none, and the second, asked within ten minutes on the same server, got the first one's pages:

The same rule meant "dna", "atp" and "bee" were never searched for. The key is now the whole question, and a stoplist in four languages, not word length, decides which short words count.

We told the model it had the whole book

The prompt said, in capital letters, that the content was the complete file and should be searched thoroughly before anything was called missing. It was a few percent of the file, so an answer on a page the model had not been shown came back as "the document does not cover this". A filter then replaced any reply containing "not mentioned", "no information" or the like with a canned "I couldn't find a clear answer", uncharged, even a full, correct answer that happened to say "the text doesn't specify the year":

Excerpts are now called excerpts, with their pages listed, and the model is asked to say what those pages leave out. Only a short reply that opens with a refusal is replaced.

Cutting from the top, one layer down

Part 2 was about a cut that kept a page's first N tokens and threw away the answer, and it had come back one layer down. Five features (the video scene planner, the podcast script writer, the podcast's content analysis, the topic picker every file action uses and the study-sheet generator) kept the first 3,000 to 28,000 characters of the excerpt they were handed. Excerpts are in page order, so those cuts kept the earliest picks, not the best:

All five now share one helper that fits text by relevance to the request, or as an even spread when there is no topic.

Voice mode lost the excerpt further down still: it compressed the attached file, then answered from a context that never received it.

"Explain more", traced

The two turns from the opening. The eye passage is on page 155, in chapter six.

conversation
  turn 1    "How could natural selection produce an organ as perfect as the eye?"
  turn 2    "explain more"

Before, for turn 2:

query to the compressor    "explain more"
search terms               none ("explain" and "more" are stop words)
keyword pool               no scores, so file order: the first chunks, the middle one and the last
embedding re-rank          reorders those 50
excerpt                    27 of 412 sections
pages shown                1 to 48 (26 pages) and 207
front matter               title page, ebook notes, epigraphs, contents, introduction
page 155                   not sent

After, for the same turn:

query to the compressor    turn 1, then "explain more" (turn 2 names nothing, so it borrows)
search terms               natural, selection, produce, organ, perfect, eye
pool                       best keyword matches + 50 chunks spaced across the book
ranking                    keyword rank and semantic rank, fused
excerpt                    28 of 421 sections, with a "pages shown" line
pages shown                2, 70, 72-73, 93, 108, 115, 125, 128-129, 142, 144, 155-158, 160-161, ...
page 155                   sent, under its own page label

The model is also told that turn 2 follows up on turn 1, since earlier questions are otherwise kept out of a file answer's messages so that it answers the current one.

The same two turns as the student sees them, the follow-up answered from Chapter VI:

A Cereby chat with On the Origin of Species attached: the student asks how natural selection could produce the eye and Cereby points to Chapter VI, "Difficulties on Theory"; the student writes "explain more" and Cereby walks through Darwin's gradations of eyes, quoting the passage on numerous gradations each useful to its possessor.

The two turns in chat, on the public-domain book and synthetic questions.

Before and after

All figures come from the eval: Darwin, 412 pages, at the budget a file question gets.

MeasureBeforeAfter
Answering passage reaches the model, keywords only3 of 86 of 8
Answering passage reaches the model, with embeddings3 of 87 of 8
"Explain more" after the eye questionpages 1 to 48 and 207, no answerthe eye's chapter, answer included
"Summarize this book"4 of 16 sections, 8 pages of front matterall 16 sections, 1 page of front matter
Budget a vague question used, book with short paragraphs54%95%
Index pages in a ranked excerptup to 30
Ranking by meaning, cold, median0.77 s1.0 to 1.2 s

The last row is the price of showing the embeddings twice as many chunks, and a warm server has the spread's vectors cached. The miss left in each layout is a sampling miss: the Spanish question and the paraphrase each land in only one of our two layouts, where the spread happens to fall near the answer.

What this taught us

Every failure here produced a fluent answer, with no crash, timeout or error, so only someone who already knew the answer could find it. The eval with known answer passages did more for us than any review.

The fallback is the product. "Rank anyway" with nothing to rank by means file order, and for a textbook, file order means the preface. Deciding what a request is fixed more cases than any change to the ranking.

Our tests had a synthetic book in which every page but one said the same thing, and they passed. A public-domain book with an index, a contents page and a vocabulary of its own showed the preface problem, the lost three-letter words and the 50-chunk ceiling on its first run.

Telling the model what it was given is a quality fix, not a disclaimer: "the pages I was given don't cover this, ask me about that chapter" is more honest and more useful.

What's next

The remaining misses come from sampling: on each question, the embeddings see about a hundred chunks of a four-hundred-chunk book. Next we store chunk embeddings at upload, so every passage is searchable by meaning on every turn, and retire the page summaries we write at upload and never read.

All engineering posts