This repository contains a schema-aware Text-to-SQL encoder-decoder model based
on Salesforce/codet5p-770m.
The model converts a natural-language question and a serialized relational
database schema into one read-only SQLite query.
It was fine-tuned using PEFT and LoRA on Spider 1.0 together with a small set of
curated rule-based and synthetic portfolio examples. The final LoRA adapter was
merged into the base model so that the model can be loaded directly with
Hugging Face Transformers without requiring PEFT during inference.
Model summary
Property
Value
Selected experiment
CodeT5+ 770M LoRA r32
Base model
Salesforce/codet5p-770m
Architecture
Encoder-decoder Transformer
Task
Schema-aware natural-language-to-SQL generation
Fine-tuning method
PEFT / LoRA
LoRA rank
32
LoRA alpha
64
LoRA dropout
0.05
Training precision
BF16
Training hardware
NVIDIA GeForce RTX 5090
Target SQL dialect
SQLite
Output policy
One read-only SELECT or WITH query
Validation examples
628
Held-out test examples
1,040
Final evaluation results
Validation results
The selected model was evaluated on 628 validation examples.
Metric
Result
Execution accuracy
60.99%
Valid-SQL rate
94.90%
Exact match
42.04%
Schema-linking precision
88.89%
Schema-linking recall
100.00%
Schema-linking F1
93.33%
Average generation latency
1,104.62 ms
Median generation latency
850.23 ms
P95 generation latency
2,639.82 ms
Held-out test results
The final held-out evaluation used 1,040 examples.
Metric
Result
Execution accuracy
56.92%
Valid-SQL rate
92.69%
Exact match
38.37%
Schema-linking precision
96.67%
Schema-linking recall
100.00%
Schema-linking F1
98.15%
Average generation latency
1,184.16 ms
Median generation latency
932.17 ms
P95 generation latency
2,849.17 ms
Portfolio quality gate
The final project quality gate required:
Requirement
Minimum
Achieved
Held-out execution accuracy
50.00%
56.92%
Held-out valid-SQL rate
90.00%
92.69%
Improvement over the base model
3 percentage points
Passed
Held-out evaluation examples
500
1,040
The model passed all required portfolio-readiness checks.
Dataset
The complete training corpus contained 8,070 examples.
Split
Examples
Training
6,402
Validation
628
Held-out test
1,040
Total
8,070
The corpus included:
Spider 1.0 examples;
curated rule-based examples;
synthetic portfolio examples.
The evaluation process used database-aware splitting and leakage checks.
The completed leakage audit found:
zero exact-record leakage;
zero question leakage;
no detected overlap between the training and held-out evaluation records.
Spider database files and private database files are not redistributed with this
model repository.
Input format
The model expects one prompt containing:
a task instruction;
the database schema;
table names;
column names and data types;
primary-key indicators;
foreign-key relationships;
the natural-language question;
read-only SQL generation rules.
Example input:
text
1Task:
2Generate one valid SQLite query for the given business question.
34Database schema:
5Table: sales
67Columns:
8- sale_id INTEGER PRIMARY KEY
9- region TEXT
10- sale_date TEXT
11- sales_amount REAL
1213Question:
14What is the total sales amount for each region?
1516Rules:
17- Use only tables and columns present in the schema.
18- Generate exactly one read-only SELECT or WITH query.
19- Return SQL only.
Output format
The expected output is SQL text without an explanation:
Exact-match accuracy is lower than execution accuracy because multiple SQL
queries can be textually different while returning equivalent results.
Human review is required before using generated SQL for real decisions.
Evaluation notes
Execution accuracy compares the shape and normalized returned values of the
generated and reference queries.
Output aliases and SQLite-generated column labels are not required to match when
the returned values are equivalent.
The SQL validator masks quoted string literals before applying schema-aware
identifier checks. This prevents values such as "JetBlue Airways" or
"Presentation" from being incorrectly classified as column names.
Training configuration
The selected experiment used approximately the following configuration:
CodeT5+ 770M LoRA rank 32 was selected as the final model.
Base-model attribution
This model is derived from:
Salesforce/codet5p-770m
The base model and this merged derivative use the BSD 3-Clause license.
Users should also review the original base-model documentation and comply with
all applicable dataset, model and software licenses.
Citation
A formal research-paper citation is not currently associated with this
portfolio model.
When referencing the implementation, cite the GitHub repository and this
Hugging Face model page.
Disclaimer
This model is provided for research, educational and portfolio-demonstration
purposes.
The model authors do not guarantee the correctness, completeness, safety or
business suitability of generated SQL. Users are responsible for validating
queries and protecting all connected databases.