Docs
OfficialJev Cookbooks
Cookbook: Line-by-Line Search
Semantic search over GitHub's Terms of Service: one request ranks all 218 lines with a Choice while a Noul checks whether the document contains an answer at all, including when it should say no.
- Format
- Docs
- Reading time
- 2 min
- Published by
- TypeSafe AI
- Last verified
- Sep 2026
Works forJev for Decision gating
Used inJev for Software & DevTools
Highlights
- 218 tagged lines (43,980 characters) ranked in a single request, with an existence check riding along.
- An absent answer still scored one line at 0.86 while the exists question read 0.14, showing why both thresholds are tuned.
- Choice caps at 255 options, so longer documents need a two-pass window search.
Quickstart
python
response = client.system_one(
state=DOCUMENT, # 218 lines tagged "L000| ...", searched in one request
questions={
"where": Choice(instructions=f'Which line contains the answer to: "{query}"?',
criteria={line_id(i): None for i in range(len(LINES))}),
"exists": Noul(instructions=f'Does any line address or answer: "{query}"?'),
},
model="jev-1.12",
)
relevance = response.answers["where"].probabilities # one score per line id
exists = response.answers["exists"].noul # FOUND, ABSENT = 0.7, 0.35Watch out
The existence and line thresholds were tuned on these examples, so re-tune both on your own corpus before trusting the no-answer path.
Questions about this entry
Short answers drawn from the linked project or page.
Because ranking alone would answer anyway: one absent-answer example still scored a line at 0.86 while the exists question read 0.14, so the cookbook tunes both a line threshold and an existence threshold instead of trusting the top score.
Choice caps at 255 options, so longer documents need a two-pass window search. The example ranks 218 tagged lines (43,980 characters) in a single request with the existence check riding along.
Because the document already carries the text for each line id. The query goes in the instructions, the state stays unchanged between searches, and the option descriptions stay empty since repeating the line text would just duplicate what the model can already read.
Because Choice probabilities always add up to 1, so some line ranks first even when nothing answers the query. A Noul does not depend on the other options, so its probability can fall near zero when the document genuinely has no answer. That is the difference between a real answer and the closest irrelevant line.
The exists probability plus one relevance score per line. The included queries rank lines with direct answers first, and the exists thresholds classify the remaining cases as missing or partial, so you get both a search and an honest no-answer path out of a single request.
Create a key in the TypeSafe console, export TYPESAFE_API_KEY, and pip install 'cooksafe>=0.2.0,<0.3.0'. JsonCache replays the included responses so the steps run with no key and no spend; to make the requests live, set the key and delete json_cache.json. The model used is jev-1.12.
GitHub's Terms of Service split into 218 tagged clauses (43,980 characters), fetched from a gist and searched in a single request. The example uses FOUND and ABSENT thresholds of 0.7 and 0.35, and both the existence and line thresholds were tuned on these examples, so re-tune them on your own corpus.
Reactions & coverage
Posts, threads, and videos about this entry from around the web.
X: LinkedIn bookmarks search
X: 1,066 reaction videos, searchable
X: Intent-based search in a Chrome extension
X: Margin, bookmark search
From the Jev guides
Original write-ups on what this entry is for.
From the Jev AI model community
Posts from builders shipping with Jev right now.