Views
No views yet
| Metric | Base Model | Fine-tuned | Delta |
|---|---|---|---|
| Perplexity (eval split, ↓) | 35.0650 | 1.8836 | -94.6% |
| ROUGE-L (200 samples, ↑) | 0.9092 | 0.9856 | +8.4% |
b-mc2/sql-create-context (seed=42, 3,929 examples).| Setting | Value |
|---|---|
| Base model | meta-llama/Llama-3.2-3B-Instruct |
| Quantization | 4-bit NF4 (QLoRA) |
| LoRA rank | r=16, alpha=32 |
| LoRA target modules | q/k/v/o/gate/up/down_proj |
| Trainable parameters | ~20M (~0.67% of model) |
| Dataset | b-mc2/sql-create-context (~78k rows) |
| Epochs | 1 |
| Effective batch size | 16 |
| Learning rate | 0.0002 (cosine schedule) |
| Optimizer | paged_adamw_8bit |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5base_model = AutoModelForCausalLM.from_pretrained(
6 "meta-llama/Llama-3.2-3B-Instruct",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9)
10model = PeftModel.from_pretrained(base_model, "glen-louis/llama-3.2-3b-sql-qlora")
11tokenizer = AutoTokenizer.from_pretrained("glen-louis/llama-3.2-3b-sql-qlora")
12
13messages = [
14 {"role": "system", "content": "Given a SQL table schema, write a SQL query that answers the question."},
15 {"role": "user", "content": "Table: employees (id INT, name TEXT, department TEXT, salary INT)\nQuestion: What is the average salary by department?"},
16]
17prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
18inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
19
20with torch.no_grad():
21 output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
22
23print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))CREATE TABLE schemas. Each example provides the full table definition, a natural language question, and the correct SQL query — teaching the model to ground its output in real schema structure rather than hallucinate column names or types.meta-llama/Llama-3.2-3B-Instruct.1@dataset{sql_create_context,
2 author = {b-mc2},
3 title = {sql-create-context},
4 year = {2023},
5 url = {https://huggingface.co/datasets/b-mc2/sql-create-context},
6}