Vicen-te/sql-create-context-mini
Updated • 24
How to use Vicen-te/qwen3.5-2b-sql-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-2B")
model = PeftModel.from_pretrained(base_model, "Vicen-te/qwen3.5-2b-sql-lora")LoRA adapter trained on top of Qwen/Qwen3.5-2B for Text-to-SQL generation.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-2B", dtype="auto", device_map="auto")
tok = AutoTokenizer.from_pretrained("Vicen-te/qwen3.5-2b-sql-lora")
model = PeftModel.from_pretrained(base, "Vicen-te/qwen3.5-2b-sql-lora")
messages = [
{"role": "system", "content": "You are a precise Text-to-SQL assistant. Output only the SQL query."},
{"role": "user", "content": "### Schema\nCREATE TABLE employees (id INT, name TEXT, salary REAL)\n\n### Question\nWhat is the average salary?\n\n### SQL"},
]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok([text], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs['input_ids'].shape[-1]:], skip_special_tokens=True))
SFTTrainerSee the project repo for the full evaluation report (executable accuracy, exact match, BLEU) against the same base model on a held-out 200-example split.