The system knew it was answering a definition question. It also thought the answer needed a number. The result included visual evidence where a paragraph would have done.
I ran into this while working on a retrieval-augmented generation (RAG) system for a specialised document collection. I’d expected the difficult decisions to come down to embeddings, ranking, or how much context to give the model. This one came earlier. Before the system could look for evidence, it had to work out what kind of evidence would help.
When relevance is not enough
Consider three questions about the same technical practice.
- What does it mean?
- Is it required?
- How do I apply it?
A semantic search can reasonably return some of the same passages for all three. The questions are closely related and may use almost identical vocabulary. An introductory guide might give me a good definition. For an obligation, I’d want the applicable rule and enough context to tell whether it applies. For implementation, I’d look for a procedure or a worked example.
That distinction gave us a useful way to organise the questions we were seeing. Definition, recommendation, comparison, and legal obligation described what someone wanted to do with the information. The subject could change while the kind of investigation stayed the same.
Semantic similarity tells us what a question is about. Intent tells us what to do about it.
A plan before the search
Labelling a request comparative still leaves the retrieval stage with several decisions. What are we comparing? Do we need sources from different jurisdictions? Is one document enough?
We used a query plan to make those decisions explicit. Here’s a simplified example.
{
"intent": "comparative",
"targets": ["approach A", "approach B"],
"document_preferences": [
"official_guidance",
"technical_reports"
],
"retrieval_mode": "multi_doc",
"answer_format": "structured_comparison"
}
The classifier proposes an intent and identifies details that matter for the search, such as a jurisdiction or the approaches being compared. The application validates the fields and applies the policy for that intent. When the request specifies a jurisdiction, document metadata can help narrow the search before semantic ranking begins. Source preferences can also guide where to look first. An educational document might still point to the exact provision I need.
In pseudocode, the handoff looks like this.
const classification = await classifyIntent(question, taxonomy);
const queryPlan = validateAndNormalise(classification);
const policy = resolvePolicy(queryPlan.intent);
const retrievalPlan = applyPolicy(queryPlan, policy);
const evidence = await retrieve(retrievalPlan);
return generateGroundedAnswer(question, evidence, queryPlan);
validateAndNormalise checks whether the proposed plan makes sense as a whole. applyPolicy turns that plan into retrieval decisions. That gives us a place to test a specific behaviour, such as whether a question about an obligation sends us to the applicable primary sources first.
The definition that got visual evidence
In the experiment, the plan contained these two fields.
{
"intent": "definition",
"expects_quantitative_answer": true
}
The first field was right. The second sent the system looking for visual evidence. Each component followed the signal it received, and the reply wandered away from the original question.
The fix started with a consistency rule. For this class of definition questions, the presence of a figure in a retrieved document was insufficient reason to add it to the answer. The fields in the plan had to make sense together.
I like this bug because the disappointing answer was easy to spot, but the cause would have been hard to infer from the answer alone. Once we could see the plan, we had two decisions we could inspect separately. The classifier understood the intent. The application let an incompatible flag steer the response.
Leaving room for uncertainty
Some questions express more than one intent. “What does this rule require, and how should I apply it?” needs both the rule and practical guidance. Other questions leave out a detail that would change which documents we should search.
In those cases, a broader search can be more useful than committing early to a narrow set of sources. A confidence score can help decide when to widen the search, provided we’ve tested what that score actually tells us. Guessing wrong at the routing stage can exclude the evidence that would have helped us recover later.
Testing the route
I’d start with a small set of questions about the same topic. Take the three from earlier and write down what each one needs as evidence. For the question about an obligation, I’d check whether the query plan gives priority to the applicable rule and whether that rule actually makes it into the context sent to the model. The same test can also tell me when broad retrieval would have found a source that the router filtered out.
Those checks help narrow down the cause of a bad answer. If the rule never makes it into the candidate set, I’d look at source selection and retrieval. If it’s retrieved but disappears before context assembly, I’d look at ranking or context selection. If it reaches the model and the answer still gets the obligation wrong, I’d look at how the model used the evidence. Each points to a different fix.
The extra step costs time and gives us another component to maintain. Its value for me is that it makes the answer easier to investigate. When a reply sounds convincing but cites the wrong kind of source, I can go back and ask a more precise question.
What did we tell the system to look for?