The problem
Writing SQL is a barrier for anyone who needs answers from data but never learned the language — product managers, analysts, and students in non-CS branches. Text-to-SQL closes that gap, but naive models hallucinate table names and produce queries that look right and fail. This project builds the translation properly: a T5-base model fine-tuned on Spider (10,000+ questions over 200 databases) generates the query, while a schema-linking stage feeds the actual table and column names into the model and a validation stage executes every generated query against SQLite, rejecting or repairing anything that does not run. The demo makes the whole loop visible — English question, generated SQL with schema links highlighted, execution result table — over a realistic sample company database with customers, orders and products. Exact-set-match accuracy on Spider's development set is the honest evaluation metric.
Asks plain-English questions over the sample company database.
Follow the working sequence
How it works
- The user's English question and the database schema (tables, columns, foreign keys) are serialized into the T5 input format used in Spider training.
- The fine-tuned T5-base model generates a SQL query token by token, constrained to identifiers present in the provided schema.
- A post-processing step normalizes the query and checks every referenced table/column against the schema; unknown identifiers trigger a regeneration or a clear error.
- The validated query executes against the SQLite sample database; the result rows are returned to the demo.
- The demo displays the question, the generated SQL with linked identifiers highlighted, and the result table side by side.
- Evaluation runs the model over Spider's development set with the official exact-set-match script, and the score is reported honestly in the report.
Tech stack:
- Python 3.11, Hugging Face Transformers
- T5-base (t5-base) fine-tuned on Spider
- Spider dataset (Yale, 10k questions / 200 databases)
- PyTorch (fine-tuning)
- SQLite (execution validation + demo database)
- Flask + HTML/CSS/JS (demo)
- Official Spider evaluation script
Dataset & model details
- Dataset: Spider (Yu et al., Yale, 2018) — 10,181 natural-language questions paired with 5,693 SQL queries over 200 databases across 138 domains, the standard cross-domain text-to-SQL benchmark. Source: yale-lily.github.io/spider.
- Task: Cross-domain text-to-SQL — input = English question + database schema, output = executable SQL query.
- Model: T5-base (220M parameters) fine-tuned on Spider with schema serialization; schema linking + SQLite execution validation as guardrails.
- Metrics: Exact-set-match accuracy on Spider's development set using the official evaluation script — the published T5-3B baseline (~65–70%) is cited as literature context; this project's achieved score is a design target reported after training.
| Parameter | Value |
|---|---|
| Training pairs | 10,181 questions / 200 databases (Spider) |
| Model | T5-base fine-tune, ~220M parameters |
| Exact-set-match | Design target on Spider dev set (reported after training) |
| Demo database | 4 tables, realistic company data (SQLite) |
| Generation latency | Under 4 s per question on CPU (expected) |
| Demo | Single-file web app with schema explorer |
| Fine-tuning | Approximately 6–10 h on a single GPU (expected) |
Project features
- [Spider-trained T5 model] T5-base fine-tuned on the Spider dataset translates English questions into SQL across database schemas it has never seen.
- [Schema linking] Table and column names from the live schema are fed to the model and matched against question mentions, preventing hallucinated columns.
- [Execution validation] Every generated query is executed against SQLite; failures are caught and the error is shown instead of a broken query.
- [Sample company database] A realistic multi-table database (customers, orders, products, employees) with sensible data for asking real questions.
- [Schema explorer] Browse tables, columns and foreign keys in the demo so you can see exactly what the model is allowed to reference.
- [Query highlighting] Generated SQL renders with schema-linked identifiers highlighted, making the translation auditable.
- [Live web demo] Ask questions in English, watch the SQL generate, and see the result table — the full ask-to-answer loop.
What is included
- Fine-tuned T5 text-to-SQL model
- Schema-linking + execution-validation pipeline source
- Sample company SQLite database with realistic data
- Web demo (ask in English → SQL → result table)
- Spider evaluation notebook with official metric script
- Project report PDF (background, seq2seq models, schema linking, methodology, results)
- PPT presentation for final review
- Viva Q&A preparation document (T5, Spider, exact-set-match, beam search)
Limitations & prerequisites
- Exact-set-match is a design target until training executes; the report records the achieved dev-set score.
- Very complex questions (multi-level nesting, window functions) may generate incorrect SQL — the execution validator catches failures but cannot fix wrong-but-runnable queries, and the report is honest about this.
- The model handles one database schema per question; cross-database joins are out of scope.
- Demo latency on CPU is a few seconds per question; a GPU is recommended for the training run.
- Generated queries are read-only SELECT in the demo; write operations are deliberately excluded.
Frequently Asked Questions
Which dataset is used?
Spider — over 10,000 English questions with SQL answers across 200 databases in 138 domains. It is the standard benchmark because it tests generalization to schemas the model has never seen.
How do you stop the model inventing column names?
Two guardrails: schema linking feeds the real table/column names into the model input, and every generated query is validated against the actual schema and executed on SQLite before being shown.
What kinds of questions work?
Filtering, aggregation, sorting, joins and grouping — "top 5 products by revenue last quarter", "customers from Mumbai with more than 3 orders". The demo suggests examples per difficulty.
How is it evaluated?
With Spider's official exact-set-match script on the development set — the same metric the research literature uses, so the score is comparable.
Can I plug in my own database?
The pipeline accepts any SQLite database: point it at your schema and ask questions. The report documents the steps.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It is sequence-to-sequence NLP grounded in a real benchmark, with a demo anyone can try. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.
Components & software requirements
- Python 3.11, Hugging Face Transformers
- T5-base (t5-base) fine-tuned on Spider
- Spider dataset (Yale, 10k questions / 200 databases)
- PyTorch (fine-tuning)
- SQLite (execution validation + demo database)
- Flask + HTML/CSS/JS (demo)
- Official Spider evaluation script
Dataset & model details
- Dataset: Spider (Yu et al., Yale, 2018) — 10,181 natural-language questions paired with 5,693 SQL queries over 200 databases across 138 domains, the standard cross-domain text-to-SQL benchmark. Source: yale-lily.github.io/spider.
- Task: Cross-domain text-to-SQL — input = English question + database schema, output = executable SQL query.
- Model: T5-base (220M parameters) fine-tuned on Spider with schema serialization; schema linking + SQLite execution validation as guardrails.
- Metrics: Exact-set-match accuracy on Spider's development set using the official evaluation script — the published T5-3B baseline (~65–70%) is cited as literature context; this project's achieved score is a design target reported after training.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.