Views
No views yet
fp16/ — merged FP16 model (recommended)int8/ — quantized INT8 checkpoint (smaller footprint)lora_adapter/ — LoRA adapter only (for further tuning / research)| Item | Value |
|---|---|
| Base model | Qwen/Qwen2.5-3B-Instruct |
| Fine-tuning method | QLoRA (4-bit) |
| Optimizer | paged_adamw_8bit |
| Epochs | 4 |
| Training time | ~4 minutes (A100) |
| Trainable params | 29.9M (1.73% of 3B total) |
| Decoding | Greedy |
| Tracking | MLflow (DagsHub) |
sqlglot).| Model | Parseable SQL | Exact match | Mean latency (s) | P50 (s) | P95 (s) |
|---|---|---|---|---|---|
| qwen_finetuned_fp16_strict | 1.00 | 0.15 | 0.433 | 0.427 | 0.736 |
| qwen_finetuned_int8_strict | 0.99 | 0.20 | 2.152 | 2.541 | 3.610 |
| qwen_baseline_fp16 | 1.00 | 0.09 | 0.405 | 0.422 | 0.624 |
| qwen_finetuned_fp16 | 0.93 | 0.13 | 0.527 | 0.711 | 0.739 |
| qwen_finetuned_int8 | 0.93 | 0.13 | 2.672 | 3.454 | 3.623 |
| gpt-4o-mini | 1.00 | 0.04 | 1.616 | 1.551 | 2.820 |
| claude-3.5-haiku | 0.99 | 0.07 | 1.735 | 1.541 | 2.697 |

1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3repo_id = "aravula7/qwen-sql-finetuning"
4
5tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="fp16")
6model = AutoModelForCausalLM.from_pretrained(
7 repo_id,
8 subfolder="fp16",
9 torch_dtype=torch.float16,
10 device_map="auto"
11)1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3repo_id = "aravula7/qwen-sql-finetuning"
4
5tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="int8")
6model = AutoModelForCausalLM.from_pretrained(
7 repo_id,
8 subfolder="int8",
9 device_map="auto"
10)1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5base_id = "Qwen/Qwen2.5-3B-Instruct"
6repo_id = "aravula7/qwen-sql-finetuning"
7
8tokenizer = AutoTokenizer.from_pretrained(base_id)
9base = AutoModelForCausalLM.from_pretrained(
10 base_id,
11 torch_dtype=torch.float16,
12 device_map="auto"
13)
14
15model = PeftModel.from_pretrained(base, repo_id, subfolder="lora_adapter")1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo_id = "aravula7/qwen-sql-finetuning"
5tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="fp16")
6model = AutoModelForCausalLM.from_pretrained(
7 repo_id,
8 subfolder="fp16",
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13system = "Return ONLY the PostgreSQL query. Do NOT include explanations, markdown, code fences, or commentary."
14schema = "Table: customers (customer_id, email, state)\nTable: orders (order_id, customer_id, order_timestamp)"
15request = "Show the number of orders per customer in 2025."
16
17prompt = f"""{system}
18
19Schema:
20{schema}
21
22Request:
23{request}
24"""
25
26inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
27with torch.no_grad():
28 out = model.generate(
29 **inputs,
30 max_new_tokens=256,
31 do_sample=False,
32 pad_token_id=tokenizer.eos_token_id
33 )
34
35sql = tokenizer.decode(out[0], skip_special_tokens=True)
36# Extract SQL after prompt
37sql = sql.split("Request:")[-1].strip()
38print(sql)1@misc{qwen-sql-finetuning-2026,
2 author = {Anirudh Reddy Ravula},
3 title = {Qwen2.5-3B Text-to-SQL Fine-Tuning for PostgreSQL},
4 year = {2026},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/aravula7/qwen-sql-finetuning}},
7 note = {Fine-tuned with QLoRA for e-commerce SQL generation}
8}