Instructions to use RahulPi/qwen2.5-1.5B-sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RahulPi/qwen2.5-1.5B-sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RahulPi/qwen2.5-1.5B-sql") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RahulPi/qwen2.5-1.5B-sql") model = AutoModelForCausalLM.from_pretrained("RahulPi/qwen2.5-1.5B-sql", device_map="auto") 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 Settings
- vLLM
How to use RahulPi/qwen2.5-1.5B-sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RahulPi/qwen2.5-1.5B-sql" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RahulPi/qwen2.5-1.5B-sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RahulPi/qwen2.5-1.5B-sql
- SGLang
How to use RahulPi/qwen2.5-1.5B-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 "RahulPi/qwen2.5-1.5B-sql" \ --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": "RahulPi/qwen2.5-1.5B-sql", "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 "RahulPi/qwen2.5-1.5B-sql" \ --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": "RahulPi/qwen2.5-1.5B-sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RahulPi/qwen2.5-1.5B-sql with Docker Model Runner:
docker model run hf.co/RahulPi/qwen2.5-1.5B-sql
Qwen2.5-1.5B SQL Assistant
A fine-tuned text-to-SQL model designed to translate natural language questions into valid SQL queries given a database context and table schema.
Model Details
Model Description
This model is a fine-tuned, merged version of Qwen/Qwen2.5-1.5B-Instruct. It was trained using QLoRA with Hugging Face's SFTTrainer on a structured SQL context dataset and subsequently merged back into full 16-bit precision (fp16) for direct inference.
- Developed by: RahulPi
- Model type: Causal Language Model
- Language(s): English
- License: Apache 2.0
- Finetuned from model: Qwen/Qwen2.5-1.5B-Instruct
Uses
Direct Use
Generating SQL queries based on database context and user prompts.
Prompt Format
The model was trained using the following template format:
System: You are a strict SQL assistant. Output ONLY valid SQL queries.
User: Schema: <context/schema> Question: <natural_language_question>
Assistant: <sql_query>
How to Get Started with the Model
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "RahulPi/qwen2.5-1.5B-sql"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
context = "CREATE TABLE head (born_state VARCHAR, age INTEGER)"
question = "How many heads were born in California and are older than 50?"
prompt = (
f"System: You are a strict SQL assistant. Output ONLY valid SQL queries.\n"
f"User: Schema: {context} Question: {question}\n"
f"Assistant:"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Training Details
Training Data
Trained on a 1,000-row subset of b-mc2/sql-create-context, combining table schemas and questions mapped directly to correct SQL target queries.
Training Procedure
- Framework: TRL
SFTTrainerwith PEFT (QLoRA) - Base Precision: Loaded in 4-bit (
NormalFloat4) during training, merged intofp16for distribution - LoRA Target Modules:
q_proj,k_proj,v_proj,o_proj - LoRA Parameters: r = 16, alpha = 32, Dropout = 0.05
Training Hyperparameters
- Learning Rate: 2e-4
- Scheduler: Cosine
- Batch Size: 4 per device
- Gradient Accumulation Steps: 4 (Effective batch size: 16)
- Optimizer:
paged_adamw_32bit - Max Sequence Length: 2048
- Epochs: 3 (189 global steps)
Results
- Final Training Loss: 0.7238
- Mean Token Accuracy: 85.97%
- Training Runtime:
1707 seconds (28.5 minutes on NVIDIA T4)
- Downloads last month
- 211