Downloads · 30 days
13
18% of all-time downloads
ssnym/llama-3.2-1b-text-to-sql
llama-3.2-1b-text-to-sql is a text generation model from ssnym. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as llama3.2.
LoRA adapter fine-tuned via QLoRA + SFT on b-mc2/sql-create-context, converting a table schema + natural language question into a SQL query.
Downloads · 30 days
13
18% of all-time downloads
All-time downloads
72
Public
Repo size
62.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors45.1 MB · 72%
From the Hugging Face model README
LoRA adapter fine-tuned via QLoRA + SFT on b-mc2/sql-create-context, converting a table schema + natural language question into a SQL query.
Release date: August 10, 2026
| Metric | Baseline | Fine-tuned |
|---|---|---|
| Exact match | 0.401 | 0.843 |
| Normalized match | 0.414 | 0.848 |
Metric definitions:
This is a LoRA adapter — load it on top of the base model.
from unsloth import FastLanguageModel
from peft import PeftModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/Llama-3.2-1B-Instruct-bnb-4bit",
max_seq_length=1024,
load_in_4bit=True,
)
model = PeftModel.from_pretrained(model, "ssnym/llama-3.2-1b-text-to-sql")
FastLanguageModel.for_inference(model)
SYSTEM_PROMPT = "You are a text-to-SQL assistant. Given a table schema and a question, output only the SQL Query"
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "Context (schema):\nCREATE TABLE head (age INTEGER)\n\nQuestion: How many heads of the departments are older than 56 ?"}
]
inputs = tokenizer.apply_chat_template(
messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
).to("cuda")
outputs = model.generate(inputs, max_new_tokens=128, temperature=0.1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Testing on out-of-distribution examples (custom schemas not from the training dataset) showed strong performance on single-table queries but weaker performance on multi-table JOINs, likely because the training dataset (b-mc2/sql-create-context) is predominantly single-table.
Built with Llama.
This adapter is released under the Llama 3.2 Community License, inherited from the base model (Meta Llama 3.2, released Sept 25, 2024). Base model weights via unsloth/Llama-3.2-1B-Instruct-bnb-4bit.