Minnow-SQL-0.5B

A small model (0.5B parameters) that turns a question in plain English into a SQLite query. It is Qwen2.5-Coder-0.5B-Instruct fine-tuned with LoRA on the Spider training set plus a slice of SynSQL-2.5M, then merged into one model. It runs on a laptop GPU or a CPU.

Code, training scripts and every scored run: github.com/thiscube/Minnow-SQL-0.5B

Scores

Execution accuracy: a query counts as right when it returns the same rows as the reference query.

Spider dev (1,034) Spider test, scored once (917)
Base model, one answer 45.36%
This model, one answer 62.48%
This model, 15 answers voted, then repaired 71.18% 76.66%

The third row uses the vote and repair steps from the GitHub repo: the model writes 15 queries, they are run, the most common result wins (empty results last), and a winning query that names a missing column is fixed from the database. Scores use the project's own checker, not the official Spider test-suite checker.

Prompt format

The model was trained on this exact format. Use the chat template with this system message:

You are an expert in SQLite. Given a database schema and a question, write one SQLite query that answers the question. Reply with the SQL query only.

and this user message:

Database schema:
<the CREATE TABLE statements of the database>
/*
Values from the question found in the database:
singer.Country = 'France'
*/

Question: How many singers are from France?

The comment block is optional. It lists words from the question that appear as stored values, which helps the model pick the right column and spelling. Leave it out when nothing matches.

Example

from transformers import AutoModelForCausalLM, AutoTokenizer

name = "cubehugging/Minnow-SQL-0.5B"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name)

schema = """CREATE TABLE singer (Singer_ID int PRIMARY KEY, Name text, Country text, Age int)"""
question = "How many singers are from France?"
messages = [
    {"role": "system", "content": "You are an expert in SQLite. Given a database schema and a question, write one SQLite query that answers the question. Reply with the SQL query only."},
    {"role": "user", "content": f"Database schema:\n{schema}\n\nQuestion: {question}"},
]
inputs = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
)
output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# SELECT count(*) FROM singer WHERE country  =  "France"

Limits

  • SQLite only. Other SQL dialects were not trained or tested.
  • Questions that need two or more joins are its weak spot.
  • Spider dev questions were never used for training. Dev and the test half above were only used for scoring.
Downloads last month
-
Safetensors
Model size
0.5B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for cubehugging/Minnow-SQL-0.5B

Finetuned
(124)
this model

Dataset used to train cubehugging/Minnow-SQL-0.5B