Instructions to use onkolahmet/Qwen2-0.5B-Instruct-SQL-generator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use onkolahmet/Qwen2-0.5B-Instruct-SQL-generator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="onkolahmet/Qwen2-0.5B-Instruct-SQL-generator") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("onkolahmet/Qwen2-0.5B-Instruct-SQL-generator") model = AutoModelForCausalLM.from_pretrained("onkolahmet/Qwen2-0.5B-Instruct-SQL-generator") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use onkolahmet/Qwen2-0.5B-Instruct-SQL-generator with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/onkolahmet/Qwen2-0.5B-Instruct-SQL-generator
- SGLang
How to use onkolahmet/Qwen2-0.5B-Instruct-SQL-generator 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 "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator" \ --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": "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator", "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 "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator" \ --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": "onkolahmet/Qwen2-0.5B-Instruct-SQL-generator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use onkolahmet/Qwen2-0.5B-Instruct-SQL-generator with Docker Model Runner:
docker model run hf.co/onkolahmet/Qwen2-0.5B-Instruct-SQL-generator
Model Card for Qwen2-0.5B-Instruct-SQL-generator
This model is a fine-tuned version of Qwen/Qwen2-0.5B-Instruct.
It has been trained using TRL (Transformer Reinforcement Learning) for SQL generation tasks.
Quick Start
from transformers import pipeline
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
generator = pipeline("text-generation", model="onkolahmet/Qwen2-0.5B-Instruct-SQL-generator", device="cuda")
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
print(output["generated_text"])
Training Procedure
This model was trained with Supervised Fine-Tuning (SFT) using the gretelai/synthetic_text_to_sql dataset.
The goal was to fine-tune the model to better translate natural language queries into SQL statements.
Framework Versions
- TRL: 0.12.2
- Transformers: 4.46.3
- PyTorch: 2.6.0
- Datasets: 3.4.1
- Tokenizers: 0.20.3
Evaluation Results
The model was evaluated using standard text generation metrics (BLEU, ROUGE-L F1, CHRF) in both zero-shot and few-shot prompting scenarios.
🔹 Zero-shot Prompting (on gretelai/synthetic_text_to_sql/test)
After Post-processing:
- BLEU Score: 0.5195
- ROUGE-L F1: 0.7031
- CHRF Score: 70.0409
Before Post-processing:
- BLEU Score: 0.1452
- ROUGE-L F1: 0.3009
- CHRF Score: 47.8182
SQL-Specific Metrics:
- Exact Match (case insensitive): 0.1600
- Normalized Exact Match: 0.1500
- Average Component Match: 0.4528
- Average Entity Match: 0.8807
Query Quality Distribution:
- High Quality (≥80% component match): 18 (18.0%)
- Medium Quality (50-79% component match): 28 (28.0%)
- Low Quality (<50% component match): 54 (54.0%)
🔹 Few-shot Prompting (on gretelai/synthetic_text_to_sql/test)
After Post-processing:
- BLEU Score: 0.2680
- ROUGE-L F1: 0.4975
- CHRF Score: 57.1704
Before Post-processing:
- BLEU Score: 0.1272
- ROUGE-L F1: 0.2816
- CHRF Score: 46.1643
SQL-Specific Metrics:
- Exact Match (case insensitive): 0.0000
- Normalized Exact Match: 0.0000
- Average Component Match: 0.2140
- Average Entity Match: 0.8067
Query Quality Distribution:
- High Quality (≥80% component match): 4 (4.0%)
- Medium Quality (50-79% component match): 17 (17.0%)
- Low Quality (<50% component match): 79 (79.0%)
Citations
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
- Downloads last month
- 8