How hkustdial/nl2sql_handbook works
Purpose and Entry Points
This is a research handbook and curated knowledge base for Text-to-SQL/NL2SQL, accompanying TKDE 2025 and VLDB tutorials. Its primary entry point is README.md, which links readers to lifecycle guidance, method taxonomies, benchmark material, evaluation resources, papers, and slides. It is not an executable Text-to-SQL service; the only implementation is an offline Python benchmark-analysis utility under src/dataset_analyze/.
Knowledge and Publication Layer
The repository’s principal deliverable is static documentation and publication material:
• README.md is the navigation hub and curated paper/application index.
• chapter/Pre_Processing.md, chapter/Translation_method.md, and chapter/Post_Processing.md describe the model-facing pipeline stages.
• TKDE_Survey.pdf, VLDB_Tutorial.pdf, and slides/NL2SQL-VLDB2025.pdf are distributable survey/tutorial artifacts.
• assets/ supplies diagrams referenced by the handbook, including lifecycle and benchmark timelines.
Text-to-SQL Lifecycle Taxonomy
The handbook organizes the problem space into connected stages rather than implementing them:
1. Input pre-processing: enriches natural-language questions with schema, instance, retrieval, or disambiguation context (chapter/Pre_Processing.md).
2. Translation: maps natural language plus database context to SQL (chapter/Translation_method.md).
3. Post-processing: refines, validates, repairs, or selects generated SQL (chapter/Post_Processing.md).
4. Benchmarking and data: characterizes datasets and their task properties (chapter/Benchmark.md).
5. Evaluation and error analysis: measures output quality and identifies failure causes (chapter/Evaluation.md, chapter/Error_Analysis.md).
These are conceptual boundaries; model training, inference, database execution, and LLM calls are delegated to externally linked projects.
Dataset Analysis Runtime
src/dataset_analyze/analyze.py is the practical analysis entry point. It coordinates dataset ingestion, SQL parsing, and report-oriented aggregation:
• src/dataset_analyze/dataset.py defines dataset-facing handling.
• src/dataset_analyze/sql_parser.py extracts SQL structure/features.
• src/dataset_analyze/utils.py provides shared support functions.
The expected flow is benchmark dataset input → dataset normalization/loading → SQL structural analysis → serialized benchmark report. Python is the material runtime implied by this code; no package manifest, service process, or deployment infrastructure appears in the tree.
Benchmark Report Corpus
report/ stores precomputed JSON outputs, partitioned by benchmark. Each benchmark has an isolated report contract, e.g.:
• report/Spider/report.json
• report/BIRD/report.json
• report/ATIS/report.json
The corpus spans single-turn, multi-turn, multilingual, robustness, domain-specific, and realistic benchmarks. Reports are outputs/data assets rather than dynamically served API responses, and provide the concrete bridge between the analysis code and handbook claims.
External Boundaries
The project links to, but does not vendor, model and evaluation infrastructure. External dependencies include LLM training/deployment ecosystems (LitGPT, LLaMA-Factory), benchmark-specific evaluators (BIRD official evaluation, test-suite-sql-eval), and the separate NL2SQL360 testbed. External database engines, hosted LLM APIs, vector stores, and web infrastructure are not implemented or configured here.
Key Architectural Constraint
Treat this repository as a versioned documentation-plus-analysis artifact. Changes to benchmark logic should originate in src/dataset_analyze/ and regenerate affected report/*/report.json; conceptual guidance belongs in chapter/ and is surfaced through README.md. Avoid planning application runtime components unless intentionally expanding beyond the repository’s current scope.
Main entry points: README.md README hub · analyze.py Analysis coordinator · Translation_method.md Translation · Benchmark.md Benchmarking
Components 20
Handbook taxonomy
Curated lifecycle guidance and research resources.
- Pre-processing · Question and database-context enrichment.
chapter/Pre_Processing.md - Translation · Natural language and context mapped to SQL.
chapter/Translation_method.md - Post-processing · Generated SQL validation, repair, and selection.
chapter/Post_Processing.md - Benchmarking · Dataset task properties and benchmark material.
chapter/Benchmark.md - Evaluation · Output-quality measurement.
chapter/Evaluation.md - Error analysis · Failure-cause analysis.
chapter/Error_Analysis.md
Offline analysis
Python utility that derives benchmark characteristics.
- Analysis coordinator · Runs ingestion, SQL analysis, and report aggregation.
src/dataset_analyze/analyze.py - Dataset handling · Loads and normalizes benchmark datasets.
src/dataset_analyze/dataset.py - SQL feature parser · Extracts SQL structure and features.
src/dataset_analyze/sql_parser.py - Shared utilities
src/dataset_analyze/utils.py - Benchmark datasets · Source datasets supplied to offline analysis.
Report corpus
Precomputed benchmark analysis outputs.
- Benchmark reports · Versioned per-benchmark analysis results.
- Spider report
report/Spider/report.json - BIRD report
report/BIRD/report.json - ATIS report
report/ATIS/report.json
Other components
- README hub · Primary navigation and curated resource index.
README.md - Survey and tutorial artifacts · Distributable TKDE survey and VLDB tutorial materials.
TKDE_Survey.pdf - VLDB slides
slides/NL2SQL-VLDB2025.pdf - Handbook diagrams · Lifecycle and benchmark timeline figures.
assets/readme.md - External model and eval tools · Linked training, evaluation, and NL2SQL360 projects are not vendored.
Connections 24
- README hub → Pre-processing: links
- README hub → Translation: links
- README hub → Post-processing: links
- README hub → Benchmarking: links
- README hub → Evaluation: links
- README hub → Error analysis: links
- README hub → Survey and tutorial artifacts: surfaces
- README hub → VLDB slides: links
- Handbook diagrams → README hub: illustrates
- Pre-processing → Translation: conceptual input
- Translation → Post-processing: generated SQL
- Benchmarking → Evaluation: benchmark basis
- Evaluation → Error analysis: diagnoses
- Benchmark datasets → Dataset handling: loads
- Dataset handling → Analysis coordinator: normalized data
- Analysis coordinator → SQL feature parser: parses SQL
- Shared utilities → Analysis coordinator: supports
- SQL feature parser → Analysis coordinator: structural features
- Analysis coordinator → Benchmark reports: serializes reports
- Benchmark reports → Spider report: contains
- Benchmark reports → BIRD report: contains
- Benchmark reports → ATIS report: contains
- Benchmark reports → Benchmarking: informs claims
- README hub → External model and eval tools: links externally