Downloads · 30 days
42
14% of all-time downloads
RahulPi/qwen2.5-1.5B-sql
qwen2.5-1.5B-sql is a text generation model from RahulPi. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
A fine-tuned text-to-SQL model designed to translate natural language questions into valid SQL queries given a database context and table schema.
Downloads · 30 days
42
14% of all-time downloads
All-time downloads
311
Public
Parameters
1.5B
3.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README
A fine-tuned text-to-SQL model designed to translate natural language questions into valid SQL queries given a database context and table schema.
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.
Generating SQL queries based on database context and user prompts.
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>
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))
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.
SFTTrainer with PEFT (QLoRA)NormalFloat4) during training, merged into fp16 for distributionq_proj, k_proj, v_proj, o_projpaged_adamw_32bit