NL-SQL-T5-Small: Fine-Tuned Text-to-SQL Transformer
This model is a fine-tuned version of google-t5/t5-small specialized for translating English natural language questions into executable SQL queries based on table schemas.
Developed as part of the Natural Language Data Analysis Agent project by Solayman Sameh Solayman & Habiba Ayman Ahmed.
π Model Details & Performance
- Base Architecture: T5-small (Encoder-Decoder Transformer, 60M parameters)
- Training Dataset: WikiSQL (56,355 training queries, 8,421 validation, 15,878 test)
- Exact Match Accuracy: 61.8% on the WikiSQL test split (BLEU: 0.824)
- Input Format:
translate to SQL: {question} | columns: {col1} ({type1}), {col2} ({type2})
π How to Use
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load model and tokenizer
model_id = "Solayman-Sameh/nl-sql-t5-small"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
# Prepare schema-aware prompt
question = "What is the average salary of engineers?"
columns = ["name (text)", "role (text)", "salary (real)"]
prompt = f"translate to SQL: {question} | columns: {', '.join(columns)}"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=64)
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("Generated SQL:", sql_query)
# Output: SELECT AVG salary FROM table WHERE role = engineer
π₯ Authors & Acknowledgments
- Solayman Sameh Solayman (@Solayman-Sameh)
- Habiba Ayman Ahmed (@Habibaa11)
Developed as part of the NL Data Analysis Agent project.
- Downloads last month
- 35