Views
No views yet
q_proj/k_proj/v_proj/o_proj)SFTTrainer)CREATE TABLE statement), and gold SQL query triples, derived from WikiSQL and Spider. Trained on a 20,000-example subset (randomly sampled, seed 42) for time budget on free-tier compute; a 95/5 train/test split was used.| Metric | Score |
|---|---|
| Exact-match accuracy | 73.0% |
| Execution validity rate | 96.7% |
| Gold query validity (sanity ceiling) | 97.7% |
b-mc2/sql-create-context provides schemas but no populated rows, so this measures syntactic/semantic validity against the real schema (correct table/column references, valid SQL) rather than whether results are correct — not full execution accuracy. The gold queries' own validity rate is reported as a sanity ceiling.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "yuashi/qwen2.5-1.5b-text2sql-merged"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
6
7schema = "CREATE TABLE employees (id INT, name TEXT, department TEXT, salary INT)"
8question = "What is the average salary in the engineering department?"
9
10messages = [
11 {"role": "system", "content": "You are a SQL expert. Given a database schema and a question, write the correct SQL query. Respond with only the SQL query, no explanation."},
12 {"role": "user", "content": f"Schema:\n{schema}\n\nQuestion: {question}"},
13]
14prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
15inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
16output = model.generate(**inputs, max_new_tokens=150, temperature=0.1, do_sample=False)
17print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))https://huggingface.co/yuashi/qwen2.5-1.5b-text2sql-gguf.b-mc2/sql-create-context) is CC-BY-4.0.