From Questions to Queries to Insights: A Schema-Grounded Agentic Workflow for Natural-Language Crash Data Analysis
Organizations: Department of Civil and Environmental Engineering, University of Wisconsin–Madison, Madison, WI, United States
Abstract
Transportation agencies maintain extensive crash databases to identify safety priorities, evaluate countermeasures, and guide resource allocation. Making these data accessible to practitioners requires flexible ways to translate analytical questions into reliable results. Existing dashboards support predefined analyses, while additional requests often depend on specialists who understand database queries, coded fields, and agency conventions. This study presents CrashDB-QA, a fully local, schema-grounded agentic workflow that enables natural-language analysis of crash databases. Specialized components interpret questions, generate and validate read-only SQL, execute queries, and explain the results. A shared knowledge base grounds query construction in the agency's data dictionary and safety-analysis conventions, while recorded intermediate outputs support inspection and auditing. An optional extension, CrashDB-QA+, checks the alignment among the question, query, and execution result and supplies evidence for iterative repair. We evaluate the workflow on a frozen snapshot of 4.4 million Wisconsin crash records using a new benchmark of 300 questions across ten analytical categories and nine local open-weight models. Domain grounding substantially improves query accuracy, and a code-specialized 7B model provides the best accuracy-latency balance among the tested models. Compositional analyses remain more difficult than routine retrieval, particularly comparisons between groups or periods. Verification improves performance when the Judge uses authoritative field definitions and the Refiner receives execution evidence, whereas additional checking alone offers no consistent benefit. These findings demonstrate the potential of locally deployed, domain-grounded workflows to broaden access to crash analysis and identify the reasoning and verification capabilities needed for reliable use.
Figures & tables
| (a) Column entries | |||
| Column | Description | Stored values | Associated words |
| CNTYNAME | County of the crash | names, e.g. 'MILWAUKEE' | county , counties |
| ALCFLAG | Police suspected alcohol use | 'Y' , 'UNKN' , or NULL | alcohol , drunk , OWI |
| CYCLFLAG | Motorcycle involvement | 'Y' or NULL | motorcycle , motorbike |
| TOTFATL | Number of fatalities | Integer | fatalities , deaths , killed |
| (b) Conventions | |||
| Code | Category | Representative question |
| Tier 1: retrieval through standard filtering and aggregation | ||
| C1 | Descriptive count | How many alcohol-related crashes occurred in Dane County in 2023? |
| C2 | Aggregation / breakdown | How many crashes occurred in each county in 2023? |
| C3 | Ranking / top- | Which five counties had the most crashes in 2023? |
| C4 | Temporal trend | How has the number of fatal crashes changed year over year? |
| C5 | Spatial / location | How many crashes occurred at each intersection type in Dane County? |
| Tier 1: Retrieval | Tier 2: Reasoning | ||||||||||||
| Model | Regime | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | C10 | Overall | Inv. |
| Qwen-2.5-Coder 7B | code | 96.7 | 86.7 | 93.3 | 70.0 | 90.0 | 90.0 | 73.3 | 86.7 | 43.3 | 76.7 | 80.7 | 3 |
| Qwen-2.5 7B | general | 96.7 | 80.0 | 83.3 | 70.0 | 90.0 | 96.7 | 63.3 | 90.0 | 43.3 | 50.0 | 76.3 | 13 |
| DeepSeek-R1 8B | reasoning | 100.0 | 66.7 | 73.3 | 76.7 | 83.3 | 70.0 | 86.7 | 66.7 | 33.3 | 76.7 | 73.3 | 37 |
| DeepSeek-Coder 6.7B | code | 96.7 | 70.0 | 76.7 | 70.0 | 90.0 | 56.7 | 73.3 | 60.0 | 26.7 | 63.3 | 68.3 | 24 |
| Llama-3.1 8B | general | 100.0 | 73.3 | 70.0 | 60.0 | 86.7 | 70.0 | 70.0 | 83.3 | 20.0 | 43.3 | 67.7 | 10 |
| Judge design | TP | FP | FN | TN | Precision | Recall | False-accept |
| Original Judge | 225 | 33 | 17 | 22 | |||
| Dictionary-grounded Judge | 228 | 31 | 14 | 24 | |||
| Evidence-checklist variant | 239 | 51 | 3 | 4 |
| Configuration | Judge | Feedback | Acc. (%) | Repairs | Regressions | |
| Core only | — | — | — | — | — | |
| Pre-registered configurations | ||||||
| Rule checks | rules only | critique | ||||
| LLM Judge | LLM | critique | ||||
| Voting, , + rules | LLM + rules | critique | ||||
| Diagnostic improvements: deterministic heuristics disabled | ||||||
Data Analysis Agents
Data analysis agents use language models and tools to explore datasets, run analyses, and produce answers or reports grounded in evidence.
See all 106 papers