Instructions to use cssupport/t5-small-awesome-text-to-sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cssupport/t5-small-awesome-text-to-sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cssupport/t5-small-awesome-text-to-sql")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("cssupport/t5-small-awesome-text-to-sql") model = AutoModelForSeq2SeqLM.from_pretrained("cssupport/t5-small-awesome-text-to-sql") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use cssupport/t5-small-awesome-text-to-sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cssupport/t5-small-awesome-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": "cssupport/t5-small-awesome-text-to-sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/cssupport/t5-small-awesome-text-to-sql
- SGLang
How to use cssupport/t5-small-awesome-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 "cssupport/t5-small-awesome-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": "cssupport/t5-small-awesome-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 "cssupport/t5-small-awesome-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": "cssupport/t5-small-awesome-text-to-sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use cssupport/t5-small-awesome-text-to-sql with Docker Model Runner:
docker model run hf.co/cssupport/t5-small-awesome-text-to-sql
Training
Can you please share how to train this model with my own data set
Hi,
I would like to retrain the model with my dataset too...Can you please provide the code for training?
Hi,
Please can someone share the code to train this model with my database
Hello, may this article would be helpful "https://medium.com/@martinkeywood/fine-tuning-a-t5-small-model-to-generate-sql-from-natural-language-with-92-3-accuracy-fb29e062c638"
Hi thanks, yes this article has been helpful to get things started.
I would like to know, how can I create a custom dataset to train a "Text to SQL" model. How can I create an acceptable custom dataset to proceed with training. Please help
Use excel and pandas that will give you format to the same
import pandas as pd
import os
from google.colab import drive
drive.mount("/content/drive", force_remount=True)
file_path="/content/drive/My Drive/data1.csv"
print (os.path.isfile(file_path))
if os.path.exists(file_path):
print(f"File found at :{file_path}")
#!pip install -U datasets
from datasets import load_dataset , Dataset , DatasetDict
import pandas as pd
df=pd.read_csv(file_path)
#print(df)
#dataset = load_dataset("csv",data_files=file_path)
dataset= Dataset.from_pandas(df)
#print(dataset)
#for d in dataset:
#print(d)
dataset_dict= DatasetDict({"train":dataset})
#print(dataset_dict)
split_dataset=dataset_dict["train"].train_test_split(test_size=0.2)
#print(split_dataset)
#print(split_dataset["train"])
#print(split_dataset["test"])
train_dataset=split_dataset["train"]
test_dataset=split_dataset["test"]
my csv file looks like this may be you can create your own
role content
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
user What are new request for white card
assistant get data from credit_card database table credit_card_request
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
user What are new request for white card
assistant get data from credit_card database table credit_card_request
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
user What are new request for white card
assistant get data from credit_card database table credit_card_request
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
user What are new request for white card
assistant get data from credit_card database table credit_card_request
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
user What are new request for white card
assistant get data from credit_card database table credit_card_request
user What are the personal loans nos for last month
assistant get data from LOS request tabel loan_table
Here do we need to provide prompt with create table everytime , I am looking for something where prompt will be natural language , trying build data extractor for enterprise
Yes you need to provide create table statement each time. You will need to train your model without create table statement.