t5-base-text-to-sql / README.md
suriya7's picture
Update README.md
e5a8373 verified
|
raw
history blame
2.73 kB
metadata
license: mit
pipeline_tag: text2text-generation
inference:
  parameters:
    max_new_tokens: 100
    do_sample: false
widget:
  - text: >-
      translate English to SQL: Show all employees with salary greater than
      $50000
  - text: >-
      translate English to SQL: How many models were finetuned using BERT as
      base model?
  - text: 'translate English to SQL: how many cars are in blue color'
datasets:
  - b-mc2/sql-create-context
language:
  - en
tags:
  - code
metrics:
  - bleu 34.962700

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

  1. Install Hugging Face Transformers:
    pip install transformers
    

Inference

# 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)

Performance

  • Evaluation Metrics: BLEU score 34.962700

Acknowledgments