Instructions to use ritam-05/qwen2.5-7b-sql-specialist with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ritam-05/qwen2.5-7b-sql-specialist with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct") model = PeftModel.from_pretrained(base_model, "ritam-05/qwen2.5-7b-sql-specialist") - Transformers
How to use ritam-05/qwen2.5-7b-sql-specialist with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ritam-05/qwen2.5-7b-sql-specialist") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ritam-05/qwen2.5-7b-sql-specialist", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ritam-05/qwen2.5-7b-sql-specialist with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ritam-05/qwen2.5-7b-sql-specialist" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ritam-05/qwen2.5-7b-sql-specialist", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ritam-05/qwen2.5-7b-sql-specialist
- SGLang
How to use ritam-05/qwen2.5-7b-sql-specialist 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 "ritam-05/qwen2.5-7b-sql-specialist" \ --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": "ritam-05/qwen2.5-7b-sql-specialist", "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 "ritam-05/qwen2.5-7b-sql-specialist" \ --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": "ritam-05/qwen2.5-7b-sql-specialist", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ritam-05/qwen2.5-7b-sql-specialist with Docker Model Runner:
docker model run hf.co/ritam-05/qwen2.5-7b-sql-specialist
Qwen2.5-7B SQL Specialist (QLoRA Adapter)
This is a fine-tuned LoRA adapter for Qwen/Qwen2.5-7B-Instruct, specifically trained to act as a Senior SQL Database Specialist. It accurately translates natural language questions into executable SQL queries based on provided database schemas.
Model Details
- Base Model:
Qwen/Qwen2.5-7B-Instruct - Fine-tuning Method: QLoRA (4-bit quantization) via PEFT
- Task: Text-to-SQL generation
- Language: English / SQL
Intended Use
This model is designed to take a database schema and a user question, and output only the executable SQL query enclosed in a markdown code block. It is instructed to avoid conversational filler.
Training Details
- Hardware: Trained on an NVIDIA T4 GPU (Kaggle).
- Hyperparameters:
- Batch size: 1 (with gradient accumulation steps = 16)
- Learning rate: 2e-4 (Cosine schedule)
- Mixed precision: fp16
- LoRA Rank (r): 16
- LoRA Alpha: 32
How to Get Started
To use this model, load the base model in 4-bit and attach this LoRA adapter:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
base_model_id = "Qwen/Qwen2.5-7B-Instruct"
adapter_id = "ritam-05/qwen2.5-7b-sql-specialist"
# Load base model in 4-bit
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16
)
base_model = AutoModelForCausalLM.from_pretrained(base_model_id, quantization_config=bnb_config, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
# Attach adapter
model = PeftModel.from_pretrained(base_model, adapter_id)
# Test prompt
schema = "CREATE TABLE employees (emp_id INT, name VARCHAR, department VARCHAR, salary INT);"
question = "What is the average salary in the Engineering department?"
messages = [
{"role": "system", "content": "You are a Senior SQL Database Specialist. Output only the executable SQL query enclosed within a markdown code block."},
{"role": "user", "content": f"Database Schema:\n{schema}\n\nQuestion:\n{question}"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.1)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
- Downloads last month
- 46