Built to order

Natural Language to SQL Query Generator

This project builds a natural-language-to-SQL generator: type a plain-English question like "show me customers from Mumbai who ordered last month" and get a correct, executable SQL query over a real database schema. A T5 model fine-tuned on the Spider cross-domain text-to-SQL dataset does the translation, and a schema-linking stage grounds table and column names so the model cannot invent columns that do not exist. Suitable for B.E./B.Tech final-year projects in Computer Science, AI/ML and Data Science.

AI & Machine Learning SQLitePandasPyTorchGitPython 3.11Flask web demoT5-base · Hugging Face TransformersSpider text-to-SQL datasetSoftware
Natural Language to SQL Query Generator — project thumbnail preview
More project photos (3)

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.

SYSTEM FLOW

4 components 6 connections

Live flow
Drag to explore
100%
userUser

Asks plain-English questions over the sample company database.

Follow the working sequence

How it works

  1. The user's English question and the database schema (tables, columns, foreign keys) are serialized into the T5 input format used in Spider training.
  2. The fine-tuned T5-base model generates a SQL query token by token, constrained to identifiers present in the provided schema.
  3. 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.
  4. The validated query executes against the SQLite sample database; the result rows are returned to the demo.
  5. The demo displays the question, the generated SQL with linked identifiers highlighted, and the result table side by side.
  6. 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.

Related guides

All guides

How Offline Multilingual Voice Assistants Work: Wake Word, Speech, and Small Language Models

On 3 November 2026 the IndiaAI Mission launched EKA-1 and the open-source Dhir models for Indian languages and offline use. This guide explains the five stages of an offline multilingual voice assistant, why a 26.3-billion-parameter model cannot run on a Raspberry Pi, and what a small quantized model honestly can do instead.

Read guide

Machine Learning Final Year Project Ideas with Datasets

This guide lists 30+ machine learning final-year project ideas grouped by type — tabular prediction, NLP, computer vision, and time series — each paired with a well-known public dataset from the UCI ML Repository or Kaggle. Pick a dataset with 1,000 to 50,000 rows: large enough to train a real model, small enough to iterate on a laptop. Confirm the license allows academic use and that it has a clear target column. Build a baseline model in week 1 so you always have something working. Avoid collecting your own dataset unless you have 2+ months to spare.

Read guide

Best 10 Assistive Technology Projects Students Actually Build

Assistive tech projects help real people: elderly fall detectors that text contacts, voice-driven wheelchairs, sign-language recognizers that speak, pill dispensers with caregiver alerts, and physiotherapy trackers you can calibrate. This guide lists 10 real published projectech.in builds — concrete sensors, datasets and models in every entry — with a comparison table and honest guidance on picking by branch, timeline and budget.

Read guide
Get a quotation