A decision model can't write a value, but most extraction is really selection: the value is already in the text. Let code find the candidates and let the model pick one, then copy it verbatim. Here is that pattern for phone numbers, dates, search reranking, line-level search and deep taxonomies.
Key takeaways
- Most extraction is selection: the value already exists in the source, so the model only has to pick it.
- Code finds candidates (regex, parser, search), the model chooses, code copies the value verbatim, so nothing is invented.
- Dates are parts: month, day and year are each a small Choice with a 'not stated' option; code assembles and does the arithmetic.
- Reranking is selection too: a cheap search finds candidates, one Noul per candidate scores relevance.
- Big taxonomies go level by level, keeping the best few paths instead of one greedy guess.
Try it with your agent
Paste this into your coding agent:
Find one place where we ask an LLM to extract a value (an amount, email, ID, date, name) from text. Replace it with select-don't-generate: candidates from regex/parsing in code, one Choice that picks the requested candidate (always with a "none" option), and code that copies the chosen string verbatim and normalizes it. For dates, ask month/day/ year as separate Choices with "not_stated". Compare both versions on 50 real documents.
Transcript
Intro
A decision model can't write. So how do you get a phone number, a date, or the right paragraph out of a document? You don't ask it to write the value. You let it choose.
The pattern
Here's the pattern. Most extraction is really selection, because the value is already sitting in the text. So code finds the candidates, with a regular expression, a parser or a search. The model picks the one you asked for. And code copies it verbatim. Nothing can be invented, because the model only ever chooses.
Pick a value
This email signature has three phone numbers: a finance desk, a direct line, and a support hotline. A regex finds all three. Then one Choice: which candidate is the twenty four seven support number? The hotline, at one point oh. Your code copies that exact string, and there's no way to get a digit wrong.
Dates are parts
Dates work the same way, part by part. Jev reads dates as text, not as numbers, so don't ask it which date is earlier. Ask three small Choices: which month, which day, which year, each with a not stated option. Here, March, the third, twenty twenty six. Then code builds the real date, and does every comparison.
The model's job ends at the parts. Building the date, checking it's valid, computing a renewal or a deadline, comparing two dates: that's arithmetic, and arithmetic belongs in code. If any part comes back not stated, or with low confidence, ask a person.
Rerank
Search is selection too. In a TypeSafe cookbook, a cheap keyword search found thirty candidate passages for each of forty legal questions. The right one was always in the list, but it came first only five percent of the time. One Noul per candidate, is this passage relevant, then sort by probability. Now the right passage came first eighteen percent of the time, and in the top ten sixty two percent.
Find the line
You can even point at lines. Another cookbook numbers the two hundred eighteen lines of GitHub's terms of service, and uses them as the options of a single Choice: which line answers this question? Plus one Noul: does the document answer it at all? Search without generating a word.
Deep taxonomies
And for taxonomies with thousands of leaves, like patent classes or product categories, go level by level. At each level, a Choice picks among the children. Keep the best few paths, not just one, so a near miss early on can recover. That's a beam search over the model's probabilities.
Quick check
Quick check. You need the invoice total from a PDF's text. What's the select-don't-generate way to get it?
Try it
Try it. Have your agent replace one generated extraction in your code with find, choose, copy.
Recap
So: when you need a value, select it, don't generate it. Code finds candidates, the model picks, code copies. Dates are parts. Reranking and line search are selection. And deep taxonomies go level by level. Next: using decision models to check other models' work.