Module 2 · Tools, Knowledge, Memory & Research Design · scripted
Searching by Meaning
A debt from earlier
When we designed tool results, we left a wound open. The agent needed the night-delivery rules; we gave it search; watch again what happened:
⟨tool_use⟩
search_document(doc = "doc-77", pattern = "night deliver")⟨tool_result⟩
0 matches.⟨tool_use⟩
search_document(doc = "doc-77", pattern = "night")⟨tool_result⟩
2 matches: p. 12 "overnight mooring"; p. 98 "night watch staffing".Meaning has a geography
Take a document everyone in a university knows: the undergraduate catalog — hundreds of pages of majors, requirements, prerequisites, and policies. Pull out a few statements and ask which ones are similar in meaning:
Similar in meaning — no strings attached
B. "Calculus II is a prerequisite for upper-division work."
C. "The dining halls offer three meal-plan tiers."
A and B share almost no words — different course name, different vocabulary, different sentence shape. Yet every reader knows: A and B are nearly the SAME statement, and C is from another world entirely.
That judgment — same meaning, different words — is what we need the machine to make. An embedding is the device that makes it: a machine that reads a piece of text and produces its address — a point in a space arranged so that one rule holds everywhere:
The one rule of the space
Near in MEANING = near in SPACE. Not similar spelling. Not shared words. Similar meaning.
We can't draw the real space — it has thousands of dimensions — but we can look at its shadow in two, and even the shadow shows the structure:
A two-dimensional shadow of the space
The requirement statements cluster; the campus-life statements cluster elsewhere; A and B sit nearly on top of each other despite sharing no words. (This is the apple again, from the outside: the word connects to a rich learned representation, and the embedding gives that interior structure an address. It even crosses languages — eple lands beside apple on this map, because Norwegian text about eple behaves like English text about apples. Nobody told the space that. It was drawn by reading.)
What is the meaning of an entire catalog?
Now the question that makes this practical. The embedding machine will accept any text you hand it — a sentence, a page, the whole catalog — and hand back one point. So: embed the entire catalog. What does that point mean?
One point, three sizes of text
It isn't literally an average, but it behaves like one: one address must stand for everything in the text, and the more the text says, the less the address can say. Detail washes out. And mixtures make it worse — the catalog contains statements that pull in opposite directions:
Two majors, one course, opposite rules
Both statements are *about* STAT 3011 — so their individual addresses are neighbors. A text containing both gets one address that is very much "about STAT 3011 counting rules"… and silent about which rule is whose. The geography knows aboutness. It cannot hold a disagreement.
Recognize what embedding-something-large is: it's abstraction — detail traded away for one compact representation — except nobody chose what to keep. Embedding a whole document is abstraction without an author. If we want sharp addresses, we must hand the machine sharp pieces.
Tearing the pages
So we cut the catalog into pieces and embed each piece — this is called chunking, and the honest physical picture is tearing: take each page and tear it into strips, and every strip gets its own address. But here is the trap: the tearing is usually done by ordinary code — every N lines, every paragraph break — and code doesn't know where the meaning bends. Watch a real page get torn:
Where the tear falls
The heading tore off with the HISTORY. Strip 43 is a bare list of math courses — nothing on that strip says "computer science."
Now embed the strips and ask the obvious question:
Is MATH 3320 required for the computer science major?
Tools: search_by_meaning(query, top).
⟨tool_use⟩
search_by_meaning(query = "math courses required for the computer
science major", top = 3)⟨tool_result⟩
1. strip 118 — Mathematics major: core requirements…
2. strip 41 — CS department history… "REQUIRED COURSES —
COMPUTER SCIENCE MAJOR:" [list follows on next strip]
3. strip 87 — Math minor: course list…The nearest passages cover the mathematics major and minor. Strip 41 mentions CS required courses but contains no course list. I don't have evidence that MATH 3320 is a CS requirement.
The tearing principle
A chunk's address is computed from the chunk alone. Whatever context the tear separates from it — the heading, the section, the "this is about X" — is subtracted from its meaning. Tear along the meaning, or the meaning tears.
The size of the tear
And tearing has a second dial: how big? We've now seen both ends fail:
The granularity Goldilocks
The same Goldilocks we met designing results, now on the ingestion side — and the same lesson: the right size is defined by the questions that will be asked, not by a number of lines.
Smarter tearing
If the problem is that code doesn't understand where meaning bends — we have a machine that does. Two ingestion patterns, both built from self-dialogue:
Let a mind place the tears. Before cutting, send each page through a disposable prompt: "Return the line numbers where this page should be split so each piece states one complete idea with its heading and context." The LLM reads page 212 and tears above the heading, keeping "REQUIRED COURSES — COMPUTER SCIENCE" attached to its list — and joining the list's continuation from page 213 to the same piece. Pay a prompt per page, once, at ingestion; every future search benefits.
Cast each piece as the questions it answers. An even stronger move. A chunk and the query that seeks it are different kinds of text — one is a list, the other is a question — and different kinds of text sit in slightly different neighborhoods. So, at ingestion, ask a disposable prompt: "What questions could this piece answer?" — and embed those:
Question-casting at ingestion
Store the piece under the ADDRESSES OF ITS QUESTIONS. When a real question arrives, it matches question-to-question — the same kind of text, the same neighborhood, by construction.
Notice what this is: at ingestion time, a mind imagined the future conversations this piece would matter to — and filed it where those conversations will look. The librarian shelving books by the questions readers will ask, not by the color of the covers.
Smarter asking
The same intelligence helps on the query side. A real task is usually not one clean question — and embedding the whole task has the same blur problem as embedding the whole catalog. So let the agent decompose before it searches, the way chain of thought decomposes before it answers:
I'm switching from math to CS at the start of third year. What do
I still need, and can I finish in two more years? Tools:
search_by_meaning(query, top), read_piece(id).
Before searching, I'll break this into the sub-questions I'd need answered: (1) Which courses are required for the CS major? (2) Which of those have prerequisite chains, and how long? (3) Which math-major courses count toward CS requirements? (4) What is the maximum course load per term? (5) Are there residency or minimum-terms rules for a new major?
⟨tool_use⟩
search_by_meaning(query = "courses required for the computer
science major", top = 2)⟨tool_use⟩
search_by_meaning(query = "transfer credit between majors —
courses counting toward a new major", top = 2)⟨tool_use⟩
search_by_meaning(query = "maximum course load per semester", top
= 2)⟨tool_result⟩
[three result sets: the CS requirements piece; the STAT 3011
counting rules for both majors; the overload policy…]Aggregating: the CS core is 11 courses; your math credits cover MATH 2410, MATH 3320, and — per the CS counting rule — STAT 3011. Eight remain; the longest prerequisite chain is three terms; with the standard load plus one approved overload term, two years is feasible. One flag: the residency rule requires at least four terms in the new major — you have exactly four.
- Question-casting (ingestion) and sub-question decomposition (query) are mirror images. Say precisely what each one moves, and toward what.
- In Example 3, which sub-question would the whole task's embedding have served worst — and why?
What the map doesn't know
Before we build on this, the honest limits — because the map has exactly one skill, aboutness, and several things that look like aboutness are not:
Three things the space gets wrong
So the retrieval ladder from earlier doesn't get replaced — it gets its missing rung:
The ladder, completed
Each rung up costs more and understands more. A well-equipped agent holds several rungs at once — and choosing the rung per question is part of its job.
The principle
Meaning has a geography, and an embedding is a text's address in it. But the address is only as sharp as the piece: tear along the meaning, size the pieces to the questions, and let a mind help on both sides — filing the pieces, and phrasing the search.
Take a real structured document from your field — a regulation, a curriculum, a methods handbook. (1) Tear it two ways: every N lines, and at author-drawn boundaries; find one strip that lost its aboutness to the tear. (2) Pick a piece and cast it as five questions it answers. (3) Take one realistic task against the document and decompose it into sub-questions; check which sub-question the whole task's single embedding would have served worst. (4) Name the one query in your domain where string search still beats all of this — and why.