Convert natural-language questions into accurate, executable SQL for insurance data. Unlike one-shot LLMs, this system uses person-based, domain filtering, schema guidance, and iterative error correction.
- Insurance data is vast but SQL expertise is limited.
- Non-technical users need fast, accurate KPI answers (loss ratio, claims, premiums).
- LLMs alone: hallucinate tables, produce invalid SQL, miss joins, lack correctness validation.
Enable users to ask plain English questions and get correct SQL, even without DB knowledge:
- Filter irrelevant queries
- Ground in schema
- Generate SQL guided by knowledge
- Detect syntax & logical errors
- Iteratively refine or reject failures
- Relevance Check: Skip irrelevant queries
- Knowledge Generation: Tables, columns, KPIs, reasoning steps
- SQL Generation: Create initial SQL
- Syntax Check: Catch errors, regenerate with Judge
- Logical Check: Validate against results or reverse NL
- Iterative Refinement: Loop until correct or reject
Flow:
NL Query → Relevance → Knowledge → SQL → Syntax → Judge → Reverse NL → Iterate → Result
- Policies, Claims, Agents, Submissions, Customers
gretelai/synthetic_text_to_sql+ 10 insurance-specific queries
- 60 queries, ~90% correctness
- Syntax + semantic validation using LLM-as-Judge
- Model:
mistral-large-2411 - Avg runtime: ~20s/query
- 7 LLM calls per query
- LLM roles: Domain Specialist, SQL Analyst, Judge
- Make sure the Mistral API key is still working.
- Install packages/dependencies using
pip install -r requirements.txt - Finally, run
app.pyusingpython app.py
- Anjali Vemula (6076947)
- Akshat Dasula (5979761)
- Presentation:
NL2SQL 70-30.pptx