Instructions to use Indirakumar01/tinysql-1.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Indirakumar01/tinysql-1.5b with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Indirakumar01/tinysql-1.5b:Q4_K_M # Run inference directly in the terminal: llama cli -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Indirakumar01/tinysql-1.5b:Q4_K_M # Run inference directly in the terminal: llama cli -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Indirakumar01/tinysql-1.5b:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Indirakumar01/tinysql-1.5b:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Use Docker
docker model run hf.co/Indirakumar01/tinysql-1.5b:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Indirakumar01/tinysql-1.5b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Indirakumar01/tinysql-1.5b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Indirakumar01/tinysql-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Indirakumar01/tinysql-1.5b:Q4_K_M
- Ollama
How to use Indirakumar01/tinysql-1.5b with Ollama:
ollama run hf.co/Indirakumar01/tinysql-1.5b:Q4_K_M
- Unsloth Studio
How to use Indirakumar01/tinysql-1.5b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Indirakumar01/tinysql-1.5b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Indirakumar01/tinysql-1.5b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Indirakumar01/tinysql-1.5b to start chatting
- Pi
How to use Indirakumar01/tinysql-1.5b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Indirakumar01/tinysql-1.5b:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use Indirakumar01/tinysql-1.5b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "Indirakumar01/tinysql-1.5b:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use Indirakumar01/tinysql-1.5b with Docker Model Runner:
docker model run hf.co/Indirakumar01/tinysql-1.5b:Q4_K_M
- Lemonade
How to use Indirakumar01/tinysql-1.5b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Indirakumar01/tinysql-1.5b:Q4_K_M
Run and chat with the model
lemonade run user.tinysql-1.5b-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Indirakumar01/tinysql-1.5b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Indirakumar01/tinysql-1.5b:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Indirakumar01/tinysql-1.5b:Q4_K_M
Run Hermes
hermes
- Atomic Chat
| license: apache-2.0 | |
| base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct | |
| tags: | |
| - text-to-sql | |
| - nl2sql | |
| - sql | |
| - qlora | |
| - gguf | |
| - llama-cpp | |
| - edge | |
| - on-prem | |
| language: | |
| - en | |
| library_name: gguf | |
| pipeline_tag: text-generation | |
| datasets: | |
| - xlangai/spider | |
| # TinySQL-1.5B | |
| **A private, on-prem Natural-Language-to-SQL model that runs on a laptop CPU.** | |
| TinySQL is [Qwen2.5-Coder-1.5B-Instruct](https://huggingface.co/Qwen/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. | |
| --- | |
| ## Measured results | |
| 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. | |
| ### Fine-tuning lift (apples-to-apples) | |
| 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** | | |
| - **+11.99 points** execution accuracy from fine-tuning. | |
| - **54 β 0** malformed outputs: the base model emitted non-SQL chatter and | |
| degenerate repetition loops; the fine-tune produces clean, parseable SELECTs. | |
| ### Performance (laptop CPU, Intel Core Ultra 5 235U) | |
| | 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. | |
| --- | |
| ## Intended use | |
| - Private/on-prem "text-to-SQL copilot" for non-technical users to query a database | |
| in plain English. | |
| - Embedded/offline analytics (edge devices, desktop apps) with no network. | |
| - A cheap first-pass layer that handles routine queries locally, escalating only | |
| hard ones to a larger model. | |
| **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. | |
| ## Out of scope / limitations | |
| - **Not for autonomous critical decisions** β ~63% accuracy means a human should | |
| verify before acting on results. | |
| - **No writes** β SELECT-only. | |
| - **Schema size** β trained/served at 2048-token context; very large schemas are | |
| pruned and accuracy drops. | |
| - **SQLite dialect** β targets SQLite SQL. | |
| --- | |
| ## How to use | |
| ### With `llama-cpp-python` | |
| ```python | |
| from 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'; | |
| ``` | |
| ### With `llama.cpp` CLI | |
| ```bash | |
| llama-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. | |
| --- | |
| ## Prompt format | |
| 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: | |
| ``` | |
| --- | |
| ## Training | |
| - **Base:** Qwen/Qwen2.5-Coder-1.5B-Instruct | |
| - **Method:** QLoRA (4-bit), LoRA r=16, Ξ±=16 | |
| - **Data:** Spider + BIRD, ~15.4k instruction examples, SELECT-only, FK-aware schema | |
| pruning to fit 2048 tokens | |
| - **Shipped checkpoint:** 500 steps (~0.26 epoch). A training-length ablation found | |
| accuracy peaks early: 500 steps = 62.86%, 1000 = 61.22%, 1800 = 40.81% (overfit). | |
| **Less was more.** | |
| - **Export:** merged to 16-bit β GGUF β quantized Q4_K_M for CPU/edge. | |
| --- | |
| ## Datasets & attribution | |
| - **Spider** (Yu et al., 2018) β CC BY-SA 4.0 | |
| - **BIRD** (Li et al., 2023) β CC BY-SA 4.0 | |
| 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. | |
| ## Citation | |
| ```bibtex | |
| @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} | |
| } | |
| ``` | |