Text Generation
Transformers
Safetensors
PEFT
English
Generated from Trainer
trl
sft
lora
gemma
conversational
Instructions to use sirunchained/text-to-sql-model-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sirunchained/text-to-sql-model-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sirunchained/text-to-sql-model-v1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sirunchained/text-to-sql-model-v1", device_map="auto") - PEFT
How to use sirunchained/text-to-sql-model-v1 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sirunchained/text-to-sql-model-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sirunchained/text-to-sql-model-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sirunchained/text-to-sql-model-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sirunchained/text-to-sql-model-v1
- SGLang
How to use sirunchained/text-to-sql-model-v1 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 "sirunchained/text-to-sql-model-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sirunchained/text-to-sql-model-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "sirunchained/text-to-sql-model-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sirunchained/text-to-sql-model-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sirunchained/text-to-sql-model-v1 with Docker Model Runner:
docker model run hf.co/sirunchained/text-to-sql-model-v1
| base_model: google/gemma-3-270m-it | |
| library_name: transformers | |
| model_name: text-to-sql-model | |
| tags: | |
| - generated_from_trainer | |
| - trl | |
| - sft | |
| - peft | |
| - lora | |
| - gemma | |
| licence: license | |
| license: mit | |
| datasets: | |
| - sirunchained/text-to-sql-dataset | |
| language: | |
| - en | |
| pipeline_tag: text-generation | |
| # Gemma 270M-IT Text-to-SQL Model (Version 1) | |
| This model is a fine-tuned version of `google/gemma-3-270m-it` specifically adapted for **Text-to-SQL conversion**. It takes natural language questions, optionally along with a database schema, and generates the corresponding SQL query. | |
| ## Model Description | |
| - **Base Model:** `google/gemma-3-270m-it` | |
| - **Task:** Text-to-SQL Generation (Instruction-tuned language model) | |
| - **Fine-tuning Framework:** `trl` library with `SFTTrainer` | |
| - **Optimization:** LoRA (Low-Rank Adaptation) for Parameter-Efficient Fine-Tuning (PEFT) and 4-bit quantization using `bitsandbytes` to reduce memory footprint and enable training on resource-constrained environments (e.g., T4 GPU). | |
| ## Training Data | |
| The model was fine-tuned on the `sirunchained/text-to-sql-dataset` from Hugging Face. This dataset consists of natural language queries, corresponding database schemas (optional), and the target SQL queries. | |
| ## Model Performance | |
| The model's performance was evaluated on a test set, yielding the following results: | |
| - **Evaluation Loss:** `0.681` | |
| - **Mean Token Accuracy:** `0.836` | |
| During training, the model showed a consistent decrease in both training and validation loss, indicating successful learning and generalization. The validation mean token accuracy steadily improved, reaching approximately `84%` by the end of the training process, suggesting that the model is capable of generating accurate SQL queries given natural language input and schema information. | |
| ## Version Information | |
| This is **Version 1** of the `sirunchained/text-to-sql-model`. The model will be continuously updated and improved over time with more data and potentially different architectures. | |
| ## Gradio Demo | |
| A Gradio web interface was developed to demonstrate the model's capabilities, allowing users to input natural language queries and provide database schema details table by table, then view the generated SQL output. You can find the Gradio app code within the accompanying notebook. | |
| You can test it [here](https://huggingface.co/spaces/sirunchained/text-to-sql-gradio). |