Instructions to use suriya7/t5-base-text-to-sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use suriya7/t5-base-text-to-sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="suriya7/t5-base-text-to-sql")# 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") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use suriya7/t5-base-text-to-sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "suriya7/t5-base-text-to-sql" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "suriya7/t5-base-text-to-sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/suriya7/t5-base-text-to-sql
- SGLang
How to use suriya7/t5-base-text-to-sql with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "suriya7/t5-base-text-to-sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "suriya7/t5-base-text-to-sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "suriya7/t5-base-text-to-sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "suriya7/t5-base-text-to-sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use suriya7/t5-base-text-to-sql with Docker Model Runner:
docker model run hf.co/suriya7/t5-base-text-to-sql
YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
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
# 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
- The original T5 model was developed by Google Research.
- Training data was sourced from https://huggingface.co/datasets/b-mc2/sql-create-context
- Special thanks to Hugging Face for providing the Transformers library and the Model Hub for easy model sharing.
Contact
For any inquiries or issues regarding the model, feel free to contact:
- Downloads last month
- 35
docker model run hf.co/suriya7/t5-base-text-to-sql