Decision Models for Query Understanding: A Calibrated Decision Layer for Search and AI Systems
References:
- AnyJev: Turn any LLM into a Jev-style decision model
- SearchJev: A Fast and Calibrated System-1 Model for Search Agents
- GLiNER-2.5-Decide: Open-weight structured decision model
- Decision 1.0: Open Decision Foundation Models
Search systems often need to make many small decisions before they can retrieve anything useful: Did the user misspell an artist name? Is this a song title or a podcast name? Should the query be rewritten? Is there enough evidence to proceed? Should the system ask a larger model for help?
A common approach is to send the query to a generative LLM and ask it to return JSON. That works, but it turns a bounded decision problem into an open-ended text-generation problem. The model may produce malformed JSON, invent an entity type, change its answer when options are reordered, or assign high confidence to an incorrect interpretation.
Decision models offer a different contract:
\[\text{Query} + \text{Context} + \text{Candidate Set} \rightarrow \text{Typed probability distribution}\]Instead of generating an answer, the model scores supplied candidates and returns calibrated probabilities. This makes query understanding faster, more constrained, and easier to operate in production.
AnyJev describes this pattern as typed decisions with real probabilities: a choice among options, a yes/no decision, or an ordinal score, read from a model’s distribution in one prefill. SearchJev applies the same idea to search agents, separating fast System-1 decisions from slower System-2 reasoning and generation. github
The core intuition
Most query-understanding systems do not need to generate language. They need to choose among possibilities.
Given a noisy query such as:
tailor swift songs
the system must decide:
- Is this a spelling mistake?
- Should it become
taylor swift songs? - Is
taylor swiftan artist, song, album, or something else? - Is
songsa media-type indicator? - Should the system search the catalog directly, reformulate the query, or escalate?
A generative model can answer these questions by writing JSON. A decision model answers them by scoring bounded alternatives:
Raw query: tailor swift songs
Correction candidates:
- KEEP_ORIGINAL 0.02
- taylor swift songs 0.94
- tailor swift song 0.02
- taylor swift music 0.02
Interpretation candidates:
- ArtistName:taylor swift + MediaType:SONG 0.96
- SongName:taylor swift + MediaType:SONG 0.03
- AlbumName:taylor swift + MediaType:SONG 0.01
The application—not the model—then decides what to do with those probabilities. For example, it may automatically route high-confidence queries, retrieve catalog candidates for medium-confidence queries, and escalate low-confidence queries.
This is the central idea: the decision model chooses; the surrounding system acts.
Why not just prompt an LLM?
A generative LLM is flexible, but flexibility has a cost.
| Concern | Generative JSON output | Decision-model output |
|---|---|---|
| Output format | Text that must be parsed and validated | Typed, schema-bounded decisions |
| Invalid answers | Possible invented fields or class names | Structurally constrained |
| Latency | Grows with generated tokens | Can score candidates in one pass |
| Confidence | Often poorly calibrated | Designed for thresholdable probabilities |
| Candidate-order sensitivity | Can change with option order | Can be reduced with rotation or calibration methods |
| Cost | Higher for reasoning-heavy paths | Lower for high-volume decisions |
| Best use | Open-ended reasoning and generation | Routing, classification, extraction, gating |
AnyJev’s documentation highlights a specific failure mode of raw LLM label logits: answers can flip when the order of options changes. Its rotation-based readout reduces order sensitivity and improves calibration without requiring labels. github
That matters because production systems often use confidence thresholds:
- Automatically route queries above 0.90 confidence.
- Retrieve more evidence between 0.70 and 0.90.
- Escalate below 0.70.
An accurate but overconfident model will automate too many mistakes. An underconfident model will escalate too much, increasing latency and cost.
A factored decision graph
A naive design might try to enumerate every spelling correction and every possible interpretation:
\[\text{Candidates} = M \times N\]where $M$ is the number of spelling corrections and $N$ is the number of interpretations.
That becomes expensive quickly. If a query has three uncertain tokens, each with five corrections, and each correction has ten interpretations, the system would consider:
\[5^3 \times 10 = 1{,}250\]paths.
A better design factors the decision:
\[P(C, R, I, S \mid X, U, K) = P(C \mid X, U, K) \cdot P(R \mid X, C, U, K) \cdot P(I \mid X, C, R, U, K) \cdot P(S \mid X, C, R, I, U, K)\]where:
- $X$ is the raw query.
- $C$ is the selected correction.
- $R$ is the reformulation strategy or rewritten query.
- $I$ is the selected interpretation.
- $S$ is the slot assignment.
- $U$ is user and session context.
- $K$ is catalog or retrieval context.
Raw query
|
v
Correction candidates
|
v
Decision model: select correction
|
v
Reformulation candidates
|
v
Decision model: select reformulation
|
v
Interpretation candidates
|
v
Decision model: select interpretation
|
v
Slot spans, types, canonical values
|
v
Structured query understanding
At each stage, retain only the top-$k$ candidates. This converts an exponential search into a bounded beam search.
What a decision model should own
A decision model is excellent at selection among bounded alternatives.
| Task | Decision-model role |
|---|---|
| Spelling correction | Choose among correction candidates |
| Intent detection | Choose music, podcast, audiobook, or unknown |
| Slot detection | Predict token-level spans |
| Slot typing | Choose among entity types |
| Canonicalization | Choose among closed vocabularies |
| Language detection | Choose among language codes |
| Interpretation selection | Choose among candidate interpretations |
| Reformulation | Choose a rewrite strategy or candidate rewrite |
| Autocomplete | Rank candidate completions |
| RAG grounding | Decide whether retrieval is needed and whether evidence is sufficient |
| Escalation | Decide whether a larger reasoner is needed |
It is less suitable for open-ended creation.
| Task | Better approach |
|---|---|
| Generate every possible spelling correction | Edit-distance, phonetic, embedding, or catalog index |
| Generate every possible rewrite | Template rewriter or small generator |
| Generate arbitrary autocomplete text | Language-model generator plus decision reranker |
| Resolve a brand-new entity | Fresh catalog retrieval |
| Perform multi-hop reasoning | Larger reasoner or agent |
The practical rule is simple:
Use retrieval or a small generator to create candidates. Use a decision model to score, select, calibrate, and route them.
A practical architecture
+---------------------------+
User query ------------->| Input normalization |
Voice transcript ------> | - lowercase |
Locale / market -------->| - punctuation cleanup |
Session context -------> | - privacy filtering |
+-------------+-------------+
|
v
+-----------------------------------+
| Candidate generators |
| |
| - spelling candidates |
| - phonetic candidates |
| - catalog candidates |
| - autocomplete candidates |
| - reformulation candidates |
| - RAG retrieval candidates |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Decision model |
| |
| - correction selection |
| - interpretation selection |
| - slot spans and types |
| - canonical values |
| - language |
| - ambiguity |
| - reformulation strategy |
| - autocomplete selection |
| - RAG grounding decision |
+-----------------+-----------------+
|
+-----------------+-----------------+
| |
v v
+-----------------------+ +-----------------------+
| High-confidence path | | Low-confidence path |
| Return structured | | Retrieve, reason, |
| query understanding | | or escalate |
+-----------------------+ +-----------------------+
This is one decision model in the deployment sense: one encoder, one set of weights, one service. Internally, it has multiple decision heads.
Query + context + candidates
|
+-----------------------+
| Shared encoder |
+-----------+-----------+
|
+-----------+-----------+-------+-------+-------------+-----------+
| | | | | |
v v v v v v
Correction Intent and Span and Canonical Language Ambiguity /
selection language slot-type value head head routing
head head heads head
Spelling correction without overcorrection
Spelling correction should never blindly change the user’s query. Always include a KEEP_ORIGINAL candidate.
Raw query: tailor swift songs
Candidates:
0. KEEP_ORIGINAL
1. taylor swift songs
2. tailor swift song
3. taylor swift music
The decision model returns:
{
"KEEP_ORIGINAL": 0.02,
"taylor swift songs": 0.94,
"tailor swift song": 0.02,
"taylor swift music": 0.02
}
Candidate generators can include:
- Edit-distance indexes.
- Phonetic indexes.
- Catalog n-gram indexes.
- Embedding retrievers.
- Query-log correction indexes.
- Language-specific normalizers.
- Transliteration variant generators.
- ASR-error normalizers.
For voice interfaces, leading commands such as play, put on, and find me should usually be treated as command or stopword tokens, not as content entities.
Handling multiple interpretations
Some queries are genuinely ambiguous.
Query: drake
This could mean:
- An artist.
- A song.
- A podcast.
- An album.
The correct behavior depends on context. A decision model can score candidate interpretations using catalog data, user history, market, and session signals.
Candidate interpretations:
1. ArtistName:drake 0.82
2. SongName:drake 0.09
3. ProgramName:drake 0.06
4. AlbumName:drake 0.03
Confidence should measure whether the slot type is correct, not whether the exact entity is known.
For example, jolene may match songs by multiple artists, but it is still confidently a song title. By contrast, the mill could be a song, artist, album, or podcast, so the slot type itself may be uncertain.
This distinction prevents a common failure mode: treating ambiguity about which entity as though it were ambiguity about what kind of thing the user wants.
Autocomplete as a decision problem
Autocomplete has two distinct problems:
| Task | Input | Output | Approach |
|---|---|---|---|
| Completion selection | Prefix plus candidate completions | Ranked completions | Decision model |
| Completion generation | Prefix only | Possible continuations | Generator plus decision reranker |
For a prefix such as calm hindi, a candidate generator might produce:
- calm hindi songs
- calm hindi romantic songs
- calm hindi playlist
- calm hindi 90s songs
The decision model then ranks them:
calm hindi songs 0.58
calm hindi romantic songs 0.22
calm hindi playlist 0.12
calm hindi 90s songs 0.08
This keeps autocomplete fast and controllable. The generator explores; the decision model chooses.
RAG grounding
Retrieval-augmented generation, or RAG, is often discussed as a way to give a model current facts. In query understanding, it has a narrower and more useful role: grounding an interpretation in authoritative context.
Useful retrieval sources include:
- Catalog metadata.
- Entity aliases.
- User library and preferences.
- Recent releases.
- Regional availability.
- Knowledge-graph relationships.
- Optional web evidence.
The decision model should decide:
Does this query need retrieval?
Which retrieval source should be used?
Is the retrieved evidence sufficient?
Which candidate entity best resolves the query?
Should the system escalate?
Corrected query
|
v
Grounding decision model
|
+-- no retrieval needed --> return interpretation
|
+-- retrieval needed -----> retrieve candidates
|
v
Grounded decision model
|
+-- sufficient --> return interpretation
|
+-- insufficient -> escalate
Latency matters here. Catalog and user-library retrieval can often fit a low-latency budget. Web retrieval usually cannot.
| Path | Typical latency |
|---|---|
| No retrieval | 5–20 ms |
| Local catalog retrieval | 10–25 ms |
| User-library retrieval | 10–30 ms |
| Knowledge-graph retrieval | 20–50 ms |
| Web retrieval | Hundreds of milliseconds or more |
Therefore, web retrieval belongs offline, in an escalation path, or in asynchronous enrichment—not in the primary sub-30 ms path.
Calibration is the product
A decision model’s most valuable output is often not the selected label. It is the probability distribution.
Expected Calibration Error, or ECE, measures whether predicted confidence matches observed accuracy:
\[\text{ECE} = \sum_{b=1}^{B} \frac{|I_b|}{N} \left| \text{acc}(I_b) - \text{conf}(I_b) \right|\]where:
- $I_b$ is a confidence bin.
- $N$ is the total number of predictions.
- $\text{acc}(I_b)$ is observed accuracy in the bin.
- $\text{conf}(I_b)$ is average predicted confidence in the bin.
Lower ECE means the model’s confidence is more trustworthy.
AnyJev reports that its rotation-based readout reduced order-flip rate from 0.230 to 0.073 and improved calibration error from 0.240 to 0.095 in its published README example. The exact numbers depend on the model, dataset, and evaluation setup, but the lesson generalizes: calibration should be measured and improved directly, not treated as an afterthought. github
When to escalate
A small decision model should not pretend to know everything.
Escalate when:
- The query is highly ambiguous.
- The language or script is rare.
- The entity is new and absent from catalog features.
- The query requires multi-hop reasoning.
- The query is adversarial or safety-sensitive.
- Confidence falls below a validated threshold.
AnyJev’s Tacit models illustrate a bounded escalation design: they answer typed decisions in one forward pass, but with adaptive mode enabled, a capped share of low-confidence decisions can be sent to the model’s own reasoning. The escalation is reported and constrained by configuration such as tau, max_cot_share, and cot_window.
Decision model
|
+-- high confidence --> return structured decision
|
+-- low confidence ---> retrieval, reasoner, or human review
The escalation path should have its own latency objective, cost budget, and monitoring. It should not silently violate the primary path’s service-level objective.
Can a small model match a large model?
For constrained query understanding, often yes—on the common query distribution.
A 300M-parameter decision model can match or exceed a 7B generative model when:
- The label schema is fixed.
- Training data is diverse and grounded in real usage.
- The catalog provides current entity resolution.
- Queries are short or medium length.
- The system is regularly calibrated and refreshed.
It will usually lose when:
- The query requires broad world knowledge.
- The entity is new and absent from retrieval features.
- The language is rare or unsupported.
- The query requires multi-step reasoning.
- The query is adversarial or intentionally ambiguous.
The right goal is not “make a small model universally equal to a 7B model.” The right goal is:
Make the small model excellent on high-volume, well-understood queries, and escalate the minority that genuinely need more capacity.
Production lessons
- Separate selection from generation. Decision models select; retrievers and generators create.
- Factor the decision space. Do not enumerate every correction-interpretation pair.
- Always include a no-change option. This prevents overcorrection.
- Use calibrated probabilities for policy. Confidence thresholds should be learned from validation data.
- Ground against fresh context. The model interprets; the catalog resolves current facts.
- Personalize carefully. User history should disambiguate, not override explicit intent.
- Escalate deliberately. Use a bounded reasoning path for uncertainty, not as a default.
- Measure calibration in production. Accuracy alone is insufficient for automated decision systems.
Final takeaways
- Central mechanism: A decision model maps a query, context, and candidate set to typed probability distributions.
- Main architectural insight: Query understanding is mostly a bounded selection problem, not an open-ended generation problem.
- Best system shape: Candidate generators create options; a decision model scores, selects, calibrates, and routes.
- Key trade-off: A small decision model gives low latency and reliable structure; a larger reasoner gives broader coverage for rare or difficult cases.
- Main limitation: A decision model cannot efficiently create an unbounded candidate space or resolve every new entity without retrieval.
- Broader implication: Build AI systems as calibrated decision graphs, with fast System-1 decisions handling volume and slower System-2 reasoning reserved for genuine uncertainty. github