Part VII ยท Harnesses
Ch 25. Search and memory
Words or meaning
In Ch 24, retrieval found the cat rhyme by meaning. Search engines have long worked another way: a keyword searchkeyword search: Finding texts that contain the same words as the question.Ranking texts by which of the questionโs own words they contain, giving more weight to rare words. It finds exact names and codes but not the same idea in other words. Ch 25 looks for the questionโs own words. Each finds things the other misses. Try a few questions about the same chat:
In Ch 24, retrieval found the cat rhyme by meaning. Search engines have long worked another way: a keyword searchkeyword search: Finding texts that contain the same words as the question.Ranking texts by which of the questionโs own words they contain, giving more weight to rare words. It finds exact names and codes but not the same idea in other words. Ch 25 scores each text by the questionโs own words it contains, after dropping common ones like โtheโ and โwhichโ. The usual method, BM25, gives more credit for words that are rare among all the texts and for using them more often, and less for long texts.[1][1] It is exact: it finds a name, or a code like an error number, that an embedding blurs. Anthropicโs example is a search for โError code TS-999โ, where embeddings may find pages about error codes in general and miss the one about TS-999.[2][2] But it knows nothing of meaning: โkittyโ doesnโt match โcatโ. Try a few questions about the same chat:
Words found Sam, Leo, and the crown, which meaning missed, but found nothing for โkittyโ, which meaning got right. So many systems run both searches and combine the two lists, giving each text points for how high it comes in each.[1] Here that picked the right exchange for 4 of the 5 questions; words alone got 4 and meaning alone 2.
Words found Sam, Leo, and the crown, which meaning missed: names carry little meaning, and the crown pulled meaning toward Humpty Dumpty and the kingโs men. Meaning found โkittyโ, a word in no exchange. So many systems run both searches and merge the two lists by rank: each text gets points for how high it comes in each list, so one near the top of either does well.[3][3] Anthropic found that adding keyword search to embeddings missed fewer of the right passages.[2][2] Here the merged list put the right exchange first for 4 of the 5 questions, words alone for 4, and meaning alone for 2. It still missed Leo: meaning ranked the star rhyme first and words second, which beat Leoโs rhyme, first by words but only third by meaning.
Scoring words and ranks
For a question with words , BM25 scores a text as
where counts the word in the text, is the textโs length in words, avgdl the average length, and and are the usual settings.[1] The count saturates: a word used five times scores less than five times one use. The weight , for a word in of the texts, is highest for words in only one; the 1 inside the logarithm keeps a word found in every text from counting against a match.
Reciprocal rank fusion merges the lists using only ranks, so it neednโt compare BM25 scores with cosines: each text scores over the lists that rank it, at rank , with .[3] For Leoโs question the star rhyme gets and Leoโs rhyme .
Remembering between chats
All of that happens inside one chat. A new chat starts with an empty prompt, and the model remembers nothing of the last one. Apps with a memory feature save notes outside the model and put them into the next chatโs prompt.[2] Here the harness ends the long chat by asking the model to write notes, in two ways:
All of that happens inside one conversation. A new chat starts with an empty prompt, and the model, whose weights donโt change as you talk, remembers nothing of the last one. Memory features fill the gap the way the strategies in Ch 24 do: the harness saves notes outside the model and puts them into the next chatโs prompt. ChatGPT, for example, saves things you ask it to remember and details it picks up itself, and later began drawing on past chats too.[4][4] Here the harness ends the long chat by asking the model to write notes, in two ways:
Asked openly, the model wrote only about the last child, Mei, and made up the rest, such as plans for an astronomy camp. With those notes, the new chat couldnโt answer any question. Asked for each child and their rhyme, it did better but mixed up Samโs and Meiโs rhymes, so the new chat said Sam loves โTwinkle, twinkleโ without any doubt. A wrong note is repeated in every chat after, which is why apps let you see and delete what they remember.[2]
Without notes, the new chat knows nothing and says so. Asked openly for notes about the user, the model wrote only about the last child, Mei, and filled the rest with things that never came up: an interest in astronomy, books about space, an astronomy camp next summer. With those notes it still couldnโt answer any of the three questions. Asked for each child and the rhyme they love, it got three right but gave Sam the star rhyme, which was Meiโs, gave Mei Leoโs clock rhyme, and left out Humpty Dumpty. The new chat then said Sam loves โTwinkle, twinkleโ, with no sign of doubt.
So what gets written down matters, and a wrong note is worse than a wrong reply: it is repeated in every chat after. Thatโs why apps let you see what is remembered, delete it, turn memory off, or chat without it, and try not to save sensitive details, such as health, unless asked.[4][4] Some systems go further and let the model decide what to move in and out of its prompt as it works, the way a computer moves data between fast memory and disk.[5][5]
What notes cost
The notes were 193 tokens from the open request and 221 from the specific one, against 616 for the whole chat. With the specific notes, the new chatโs prompt for Omarโs question grew from 25 tokens to 254. Every later chat pays for its notes, so they have to stay short, and notes saved after every chat pile up into the same problem as a long chat. The same three answers apply: drop old notes, summarize them, or retrieve only those that match the question.
Recipe card
Recap
- Keyword search finds exact words such as names; search by meaning finds the same idea in other words. Many systems run both and merge the results.
- A new chat starts empty. Memory features save notes and put them into later prompts, and a wrong note is repeated in every chat after.
- BM25 rewards rare words and repeated use, with diminishing returns; rank fusion adds from each list.
Next question: every call re-sends the whole conversation, and the model reads all of it again. Does it really redo all that work every time?
Sources
- Gordon V. Cormack et al. (2009). Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods. SIGIR 2009.
- OpenAI (2024). Memory and new controls for ChatGPT. OpenAI. Accessed October 25, 2026.
Sources
- Stephen Robertson and Hugo Zaragoza (2009). The Probabilistic Relevance Framework: BM25 and Beyond. Foundations and Trends in Information Retrieval.
- Daniel Ford (2024). Introducing Contextual Retrieval. Anthropic. Accessed October 25, 2026.
- Gordon V. Cormack et al. (2009). Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods. SIGIR 2009.
- OpenAI (2024). Memory and new controls for ChatGPT. OpenAI. Accessed October 25, 2026.
- Charles Packer et al. (2023). MemGPT: Towards LLMs as Operating Systems. arXiv.
Sources
- Stephen Robertson and Hugo Zaragoza (2009). The Probabilistic Relevance Framework: BM25 and Beyond. Foundations and Trends in Information Retrieval.
- Daniel Ford (2024). Introducing Contextual Retrieval. Anthropic. Accessed October 25, 2026.
- Gordon V. Cormack et al. (2009). Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods. SIGIR 2009.
- OpenAI (2024). Memory and new controls for ChatGPT. OpenAI. Accessed October 25, 2026.
- Charles Packer et al. (2023). MemGPT: Towards LLMs as Operating Systems. arXiv.