← Projects Applied AI Personal project · 2026
A small model that doesn't do the counting
Can a 4B-parameter local LLM answer vehicle-safety questions correctly if SQL and search supply the facts and the model only plans and writes? On 50 questions over NHTSA complaint and recall data, the agent got 43 right; the same model without tools got none.
- 43 / 50
- Agent answers correct
- 0 / 50
- Same LLM without tools
- 0.77 vs 0.46
- Recall hit@1, vehicle filter vs none
- 4.9 s
- Median time per question
Architecture
- 01 Classify sql / semantic / both
- 02 Plan Pydantic tool calls, validator retries
- 03 Execute DuckDB SQL + FAISS search
- 04 Answer cited draft from evidence only
- 05 Grounding check citations and numbers
The problem
A safety analyst asks: how many complaints about the brakes of the 2024 Toyota Tacoma has NHTSA received, and is there a recall that covers this problem? They need a number they can trust and the recall that explains it.
A small language model asked that cold will make something up. I wanted to know whether the same model becomes useful if it never has to know the facts: SQL and search supply them, and the model only routes, plans tool calls and writes the answer.
What I built
The data is NHTSA’s public flat files: 13,673 recall campaigns reported since 2010 and 135,048 complaints received in 2025-2026, loaded into DuckDB. Fields that could identify people are never read. Before testing the agent I checked the database against the live NHTSA API for the 20 vehicles in the test questions.
The agent is a LangGraph state machine running qwen3:4b through Ollama on a laptop:
- Classify the question as
sql,semanticorboth. - Plan tool calls. The model never writes SQL. It fills one of two Pydantic models: a
StatsQuerycompiled into one parameterised DuckDB query, or aRecallSearchanswered by FAISS over BGE-small embeddings, restricted to the vehicle’s campaigns. - Validate. Pydantic checks the vocabulary (a known make, model and component, a vehicle that exists in that year) and that each argument is grounded in the question. Validator messages go back to the model, up to three plans. If nothing valid remains, the agent declines.
- Execute and turn results into evidence blocks with ids.
- Answer from the evidence only, then check grounding: every number must occur in the evidence or the question, and every citation must exist.
Gold answers come from SQL written separately from the agent’s compiler. Prompts and rules were developed on 9 separate questions; the 50 test questions were run once at the end.
Results
Tools are what make the small model useful. With tools it answered 43 of 50 correctly (0.86, 95% CI 0.74-0.93). Without them it answered none: it either said it had no access or gave a wrong count, a recall number that doesn’t exist, or a recall for the wrong problem.
Validator messages repair most bad plans. The first plan was invalid for 11 questions. Feeding the messages back fixed 8. They work when they name the fix (“use ‘count’ to count complaints”), and fail when the fix is to copy a longer name.
The vehicle filter matters more than the query. Restricting search to the vehicle’s campaigns lifted hit@1 from 0.46 to 0.77. Listing recalls newest first was no better than random.
Routing holds up on paraphrases. On 18 separately written paraphrases the LLM routed 17 correctly, against 11 for a keyword router.
A question takes 4.9 s at the median on a laptop RTX 4050. SQL and FAISS take milliseconds; planning takes most of it.
What didn’t work
Vehicle names. Six of the seven misses start in the tool call. Three times the model wrote
SILVERADO or SIERRA for “Silverado 1500” and similar, and kept doing it after the validator
listed the right model. Two more resolved to a real but wrong vehicle. In total, 4 answers (8%)
state something wrong and 3 (6%) are abstentions.
The grounding check catches garbled text, not wrong evidence. It flagged 2 of 47 drafts, both with a corrupted “F-15:0”, and the rewrite fixed them. It passed the three wrong drafts that faithfully reported evidence for a slightly different question.
Limits
- The 50 test questions come from 9 templates, so they test vehicle names and filters, not phrasing. Intervals are about ±0.1.
- The argument-grounding rules were written after the development runs and could reject unusual but valid phrasings.
- Semantic answers are scored by the cited campaign number. The defect and remedy text wasn’t graded.
- One model, one seed, greedy decoding. The OpenAI and Azure adapters are wired in but weren’t exercised.
What I’d do differently
Resolve the vehicle from the question text before planning, for example by preferring a validator suggestion that appears verbatim in the question. It would likely recover the three declined Silverado and Sierra questions. I found it on the test run, so I left it out rather than tune on the test set.