Downloads · 30 days
16
43% of all-time downloads
Indirakumar01/tinysql-1.5b
tinysql-1.5b is a text generation model from Indirakumar01. Use it when you need the model to write or continue text. It is set up for gguf. The card lists the license as apache-2.0.
A private, on-prem Natural-Language-to-SQL model that runs on a laptop CPU.
Downloads · 30 days
16
43% of all-time downloads
All-time downloads
37
Public
Repo size
986 MB
Likes
1
Public
Click a slice to open those files.
.gguf986 MB · 100%
From the Hugging Face model README
A private, on-prem Natural-Language-to-SQL model that runs on a laptop CPU.
TinySQL is Qwen2.5-Coder-1.5B-Instruct
fine-tuned with QLoRA for text-to-SQL and quantized to 4-bit GGUF (Q4_K_M) so it
runs offline via llama.cpp — no GPU, no cloud, no per-query cost. It converts an
English question + a database schema into a validated, read-only SQL SELECT.
The point is not to beat frontier models on raw accuracy. It is to be the compliant, $0/query, offline option for regulated data (finance, health, legal, government) where the schema + data cannot leave the premises.
All numbers below are measured, not estimated. Evaluation is execution accuracy on the full Spider dev split (1,034 examples): run the predicted SQL and the gold SQL against the real SQLite database and compare returned rows (order-insensitive), over a read-only connection.
Identical base model, identical Q4_K_M quantization, identical prompt template and SELECT-only guardrail — only the QLoRA adapter differs.
| Model | Spider dev exec. acc | Valid (SELECT-only + executes) | Malformed outputs |
|---|---|---|---|
| Base Qwen2.5-Coder-1.5B | 50.87% | 76.9% | 54 |
| TinySQL-1.5B | 62.86% | 87.99% | 0 |
| Metric | Value |
|---|---|
| Mean latency | 0.57 s / query |
| p95 latency | 0.75 s |
| Peak RAM | ~1.73 GB |
| Cost | $0 / query (self-hosted) |
Larger models and cloud APIs achieve higher accuracy, but require GPU/cloud and send your schema + data off-premises. TinySQL trades peak accuracy for privacy, $0 cost, and offline operation — the axes that matter for regulated data.
Read-only by design. Generated SQL is validated to be a single SELECT before it is shown or executed. It cannot INSERT/UPDATE/DELETE/DROP.
llama-cpp-pythonfrom llama_cpp import Llama
llm = Llama(model_path="tinysql-1.5b-q4_k_m.gguf", n_ctx=2048, verbose=False)
INSTRUCTION = ("You are a SQL expert. Given the database schema, write a single "
"SQLite SELECT query that answers the question. Return ONLY the SQL.")
schema = """CREATE TABLE orders (
id INTEGER PRIMARY KEY,
status TEXT,
customer_id INTEGER
);"""
question = "How many orders are completed?"
prompt = (f"### Instruction:\n{INSTRUCTION}\n\n"
f"### Schema:\n{schema}\n\n"
f"### Question:\n{question}\n\n"
f"### SQL:\n")
out = llm(prompt, max_tokens=256, temperature=0.0, stop=["###"])
print(out["choices"][0]["text"].strip())
# -> SELECT count(*) FROM orders WHERE status = 'completed';
llama.cpp CLIllama-cli -m tinysql-1.5b-q4_k_m.gguf -p "### Instruction:..." -n 256 --temp 0
Always enforce SELECT-only + run against a read-only DB connection before executing generated SQL. Do not run model output with write permissions.
The model was trained with (and expects) this exact template:
### Instruction:
You are a SQL expert. Given the database schema, write a single SQLite
SELECT query that answers the question. Return ONLY the SQL.
### Schema:
{CREATE TABLE statements}
### Question:
{natural-language question}
### Evidence: # optional external-knowledge hint (BIRD-style)
{hint}
### SQL:
Base model Qwen2.5-Coder-1.5B-Instruct is Apache-2.0. This fine-tune is released under Apache-2.0; please also honor the CC BY-SA 4.0 attribution for Spider/BIRD.
@misc{tinysql2026,
title = {TinySQL: Private On-Prem NL-to-SQL on a Laptop CPU},
author = {Indirakumar},
year = {2026},
howpublished = {\url{https://huggingface.co/Indirakumar01/tinysql-1.5b}},
note = {Fine-tuned Qwen2.5-Coder-1.5B, GGUF Q4_K_M}
}