Downloads · 30 days
17
49% of all-time downloads
AmbikaSoni/qwen2.5-1.5b-sql-lora-v1
qwen2.5-1.5b-sql-lora-v1 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-1.5B-Instruct, fine-tuned on text-to-SQL generation. This is the first version in a series of experiments studying QLoRA fine-tuning on free Colab.
Downloads · 30 days
17
49% of all-time downloads
All-time downloads
35
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-1.5B-Instruct, fine-tuned on text-to-SQL generation. This is the first version in a series of experiments studying QLoRA fine-tuning on free Colab.
Evaluated on 100 held-out examples from b-mc2/sql-create-context (exact-match after SQL normalization):
| Metric | Value |
|---|---|
| Baseline (untuned Qwen2.5-1.5B-Instruct) | 42.0% |
| Fine-tuned (this adapter) | 61.0% |
| Improvement | +19.0 points (+45% relative) |
A follow-up ablation with the code-specialized Qwen2.5-Coder-1.5B-Instruct base — identical LoRA config, identical training data — reached 69.0% exact-match (+8 points on top of V1). See AmbikaSoni/qwen2.5-coder-1.5b-sql-lora.
Qwen/Qwen2.5-1.5B-Instructb-mc2/sql-create-context, 1 epochTraining loss dropped rapidly in the first 20 steps (1.44 → 0.86) as the model learned the output format, then plateaued around 0.75 for the remaining 130 steps as it slowly learned SQL patterns from the data.
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-1.5B-Instruct",
quantization_config=bnb_config,
device_map="auto",
)
model = PeftModel.from_pretrained(base, "AmbikaSoni/qwen2.5-1.5b-sql-lora-v1")
tokenizer = AutoTokenizer.from_pretrained("AmbikaSoni/qwen2.5-1.5b-sql-lora-v1")
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.