T5-SQL-Translator
Overview
T5-SQL-Translator is a fine-tuned version of the Google T5-small model, specialized in translating English natural language queries into SQL SELECT queries. This model is trained to understand English queries and generate corresponding SQL SELECT queries for databases, making it valuable for automating the process of translating natural language to SQL, particularly for SELECT operations.
Model Details
- Model Name: T5-SQL-Translator
- Model Type: Text-to-Text Transformers
- Base Model: Google T5-small
- Language: English
- Task: English to SQL SELECT Translation
- Training Data: Combination of English natural language queries paired with corresponding SQL SELECT queries from diverse domains.
- Fine-tuning: The model has been fine-tuned on a dataset of English-to-SQL SELECT translations to optimize its performance for this specific task.
Example Use Cases
- Automatically translating English questions into SQL SELECT queries for database querying.
How to Use
- Install Hugging Face Transformers:
pip install transformers
Inference
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("suriya7/t5-base-text-to-sql")
model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/t5-base-text-to-sql")
def translate_to_sql_select(english_query):
input_text = "translate English to SQL: "english_query
input_ids = tokenizer.encode(input_text, return_tensors="pt",max_new_tokens=100,do_sample=False)
outputs = model.generate(input_ids)
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
return sql_query
english_query = "Show all employees with salary greater than $50000"
sql_query = translate_to_sql_select(english_query)
print("SQL Query:", sql_query)
Performance
- Evaluation Metrics: BLEU score 34.962700
Acknowledgments
Contact
For any inquiries or issues regarding the model, feel free to contact: