Downloads · 30 days
26
100% of all-time downloads
AmbikaSoni/qwen2.5-coder-1.5b-sql-lora
qwen2.5-coder-1.5b-sql-lora is a machine learning model from AmbikaSoni. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter for Qwen2.5-Coder-1.5B-Instruct, fine-tuned on text-to-SQL generation.
Downloads · 30 days
26
100% of all-time downloads
All-time downloads
26
Public
Repo size
48.4 MB
Likes
0
Public
Click a slice to open those files.
.safetensors37 MB · 76%
From the Hugging Face model README
LoRA adapter for Qwen2.5-Coder-1.5B-Instruct, fine-tuned on text-to-SQL generation.
Evaluated on 100 held-out examples from b-mc2/sql-create-context (exact-match after SQL normalization):
| Model | Baseline | Fine-tuned | Δ |
|---|---|---|---|
| Qwen2.5-1.5B-Instruct (V1) | 42.0% | 61.0% | +19.0 |
| Qwen2.5-Coder-1.5B-Instruct (this) | 42.0% | 69.0% | +27.0 |
The Coder base model doesn't score higher out-of-the-box on this exact-match eval, but fine-tunes to a higher ceiling (+8 points over vanilla Qwen with identical LoRA config and training data).
Qwen/Qwen2.5-Coder-1.5B-Instructb-mc2/sql-create-context, 1 epochA parallel run with r=32, α=64 and everything else identical gave exactly 69.0% test accuracy — no gain. Training loss was slightly worse at every step, suggesting the extra adapter capacity added init noise without adding useful representational power at this data volume. Adapter is available at AmbikaSoni/qwen2.5-coder-1.5b-sql-lora-r32.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
base = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-Coder-1.5B-Instruct",
quantization_config=bnb_config,
device_map="auto",
)
model = PeftModel.from_pretrained(base, "AmbikaSoni/qwen2.5-coder-1.5b-sql-lora")
tokenizer = AutoTokenizer.from_pretrained("AmbikaSoni/qwen2.5-coder-1.5b-sql-lora")
prompt = '''### Instruction:
Given the schema, write a SQL query to answer the question.
### Schema:
CREATE TABLE employees (id INT, name VARCHAR, department VARCHAR, salary INT)
### Question:
What is the average salary in the Engineering department?
### SQL:
'''
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=100, do_sample=False)
print(tokenizer.decode(out[0], skip_special_tokens=True))
Fine-tuned by Ambika as a learning project. Part of studying QLoRA and efficient fine-tuning at IIT Bombay.