Views
No views yet
| Model | Exact-Match Accuracy |
|---|---|
| Llama-3.3-70B (zero-shot, via Groq) | 32.0% |
| Qwen2.5-0.5B (this model, fine-tuned) | 84.0% |
1from peft import PeftModel
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
5tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
6model = PeftModel.from_pretrained(base_model, "javeria163/text-to-sql")
7
8schema = "CREATE TABLE employees (id INT, name TEXT, department TEXT, salary INT)"
9question = "What is the average salary in the Engineering department?"
10
11prompt = (
12 "Task: Convert the question to SQL using the table schema.\n\n"
13 "Schema:\n" + schema + "\n\n"
14 "Question:\n" + question + "\n\n"
15 "SQL:\n"
16)
17
18inputs = tokenizer(prompt, return_tensors="pt")
19outputs = model.generate(**inputs, max_new_tokens=150, do_sample=False)
20print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("SQL:")[-1].strip())