Athena
Part III ยท Use
Chapter 5

Search, and a memory that is kept up

Why matching words fails when people ask in their own words, how words and meaning are joined into one ranking on a laptop, what a reranker did here, and how a model keeps a memory by adding, confirming, revising and retiring statements that code checks.

After this chapter you should be able to
  • Explain why matching words fails for the way people ask about their own past.
  • Join a ranking by words and a ranking by meaning into one, on a laptop, with nothing sent elsewhere.
  • Choose between models by their score and their cost together.
  • Keep a memory with a language model that adds to it and revises it, and check its work with code.

5.1The problem: people do not ask in the words on the page

Nobody remembers that the file was called invoice_parser.py. They remember "the bug where the sums on a bill did not add up". A search that needs the word "invoice" finds nothing.

The first search in this project required every word of the question to appear in a record. On a made-up fortnight (Chapter 9) it found the right record for 42% of questions that used the record's own words, because a question of three words rarely has all three in one record, and for none of the questions asked in other words. Verified

5.2The concepts

Definition
Ranked word search
Scores each record by the question's words it contains, counting a rare word for more than a common one. Any word may match. The usual scoring is called BM25.
Definition
Embedding
A list of numbers computed from a piece of text by a model, such that texts with similar meanings get similar lists. Searching by meaning is finding the records whose lists are closest to the question's.
Definition
Rank fusion
Joining two rankings into one by position: a record high in either list scores well, and one high in both scores best.

5.3Words and meaning, joined

Every raw record becomes one or more entries in an index: a window (once per distinct title), a file, a typed piece, and screen text cut into passages of about eight lines. The index holds the words, in SQLite's full-text table, and an embedding of each entry.

A question is run both ways, the two rankings are fused, and newer entries are nudged up when two are close:

score: dict[int, float] = {}
for ranking in ranked:              # reciprocal rank fusion
    for pos, rowid in enumerate(ranking):
        score[rowid] = score.get(rowid, 0.0) + 1.0 / (60 + pos)
...
age_days = max(0.0, (now - float(t)) / 86400)
out.append({"score": score[rowid] * (1 + 0.15 * math.exp(-age_days / 3)), ...})

Published comparisons of memory systems put this arrangement, words and meaning with a weight for recency, at or near the top, with graph-based memories as its main rival. Secondary: most of those papers were written by the makers of a system in the comparison. The graph was not tried here; the simpler arrangement was measured first, and the measurement did not ask for more.

5.4Choosing the model

Table 5.1. How often a right record was among the first five results, on 24 keyword questions and 48 asked in other words. Verified, 23 November 2026, one laptop.
SearchQuestion uses the wordsAsked in other wordsTime per question
Every word must appear42%0%45 ms
Ranked words100%46%34 ms
Words and meaning, 30 MB model100%71%31 ms
Words and meaning, 67 MB model100%73%155 ms
Either, then a reranking model100%54 to 60%0.7 to 1.5 s

The small model is the default. The next one up found one more answer in 48 at five times the time. Three other models of similar size were tried and did no better.

The reranker, a second model that reads the question beside each of the best thirty entries, made the results worse while taking twenty times as long. The likely reason is that it was trained on web questions and passages, and the entries here are window titles and scraps of screens. Whatever the reason, the measurement decided.

5.5A memory that is kept up

Search finds what happened. It does not say what the owner is trying to do. Goals, priorities, preferences, commitments and style need a reading of the evidence, and that is the one job here given to a language model.

The pass does not rewrite a summary. It is shown what is already remembered and only the evidence that is new, and it answers with operations:

Table 5.2. The four operations a memory run may return.
OperationMeaningCode accepts it only if
adda new statementit cites evidence it was actually shown, and does not read as an order
confirman existing statement is supported againthe statement exists and still holds
revisean existing statement has changedas for add; the old wording is retired and kept
retirean existing statement no longer holdsthe statement exists, and the reason cites evidence

Nothing is deleted. A retired statement keeps the date it was first seen and the date it ended, so "what was I committed to in October" can still be answered. The evidence shown is limited to what the owner wrote about themselves, where their time went, and what they typed (Chapter 4).

It runs at most every six hours, only when there is new evidence, under a daily spending limit. Not tested: the rules above are covered by tests with a pretend model, and the pass has never been run against a real one.

5.6One person, one record

The same person appears as a full name in a meeting title and a first name in a chat window. Code joins them where that is unambiguous: names are compared without case, punctuation and honorifics, and a lone first name is joined to a full name only when exactly one known full name starts with it. Two people called Priya stay two records and a bare "Priya"; nothing is guessed.

What went wrong

On the real folder, the first ten results of every search were screen text. There is far more of it than of anything else, so it crowded out the windows and typed pieces, which are the records that say what the owner actually did. Search now ranks three families separately (what the owner did, wrote and saw) and takes from each in turn.

Summary
  • Requiring every word found 42% and 0%. Ranked words found 100% and 46%. Words and meaning found 100% and 71%.
  • A model of 30 MB on the processor was enough; a larger one and a reranker did not earn their cost.
  • A memory is kept by operations that code checks, and nothing is deleted from it.
  • Join names only when there is one candidate.
Exercises
  1. In the fusion formula, what does the constant 60 do? Predict the effect of changing it to 1, then to 1,000.
  2. A quarter of questions asked in other words still miss. Look at the test questions in the evaluation and pick three you would expect to fail. What do they have in common?
  3. The memory run is shown only new evidence. Describe a case in which that makes it retire something wrongly, and a change that would prevent it.
  4. Extend the code: add an operation merge for two statements that say the same thing. What must code check before accepting it?