Downloads · 30 days
80
1% of all-time downloads
suriya7/t5-base-text-to-sql
t5-base-text-to-sql is a text generation model from suriya7. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
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 gene…
Downloads · 30 days
80
1% of all-time downloads
All-time downloads
14.3K
Public
Parameters
60.5M
243 MB on disk
Likes
6
Public
Click a slice to open those files.
.safetensors242 MB · 99%
From the Hugging Face model README
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.
pip install transformers
# Load model directly
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
# Example usage
english_query = "Show all employees with salary greater than $50000"
sql_query = translate_to_sql_select(english_query)
print("SQL Query:", sql_query)
For any inquiries or issues regarding the model, feel free to contact: