Instructions to use Hex990/text2sql-qwen2.5-7b 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 Hex990/text2sql-qwen2.5-7b 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 Hex990/text2sql-qwen2.5-7b:Q4_K_M # Run inference directly in the terminal: llama cli -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M # Run inference directly in the terminal: llama cli -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M
Use Docker
docker model run hf.co/Hex990/text2sql-qwen2.5-7b:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Hex990/text2sql-qwen2.5-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Hex990/text2sql-qwen2.5-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hex990/text2sql-qwen2.5-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Hex990/text2sql-qwen2.5-7b:Q4_K_M
- Ollama
How to use Hex990/text2sql-qwen2.5-7b with Ollama:
ollama run hf.co/Hex990/text2sql-qwen2.5-7b:Q4_K_M
- Unsloth Desktop
- Pi
How to use Hex990/text2sql-qwen2.5-7b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Hex990/text2sql-qwen2.5-7b:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Hex990/text2sql-qwen2.5-7b:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Hex990/text2sql-qwen2.5-7b with Docker Model Runner:
docker model run hf.co/Hex990/text2sql-qwen2.5-7b:Q4_K_M
- Lemonade
How to use Hex990/text2sql-qwen2.5-7b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Hex990/text2sql-qwen2.5-7b:Q4_K_M
Run and chat with the model
lemonade run user.text2sql-qwen2.5-7b-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Hex990/text2sql-qwen2.5-7b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Hex990/text2sql-qwen2.5-7b: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:9931/v1 hermes config set model.default Hex990/text2sql-qwen2.5-7b:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Hex990/text2sql-qwen2.5-7b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Hex990/text2sql-qwen2.5-7b: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:9931/v1 \ --custom-model-id "Hex990/text2sql-qwen2.5-7b: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"
text2sql-qwen2.5-7b
A fine-tune of Qwen/Qwen2.5-7B-Instruct that turns a plain-English question plus a database schema into one SQLite query. It is meant to run offline on a laptop GPU through Ollama: the Q4_K_M file is 4.7 GB and fits in 8 GB of VRAM.
Warning: do not use this model on real databases. On 160 hand-written questions over four realistic multi-table databases it scores 16.3%, while the untuned base model scores 81.9%. It only does well on questions shaped like its training data (tiny, mostly single-table schemas). For real use, run the base model instead, for example
ollama run qwen2.5:7bwith the prompt format below. A second training run with better data reached 65.6% and is not published either. This repository is kept as a record of the experiment.
Files
| File | What it is |
|---|---|
text2sql-qwen2.5-7b-Q4_K_M.gguf |
Merged model, quantized to Q4_K_M (4.7 GB). This is the one to run. |
Modelfile |
Ollama Modelfile with the Qwen chat template and the system prompt. |
lora-adapter/ |
The LoRA adapter on its own (161 MB), for use with the full-precision base model. |
Results
Real-world questions (the number that matters)
Execution accuracy on 160 hand-written questions over four multi-table SQLite databases (shop, HR, school, football), none of which appear in the training data.
| Qwen2.5-7B-Instruct, untuned | This model (run 1) | Run 2, epoch 1 (not published) | Run 2, epoch 2 (not published) | |
|---|---|---|---|---|
| All 160 | 81.9% | 16.3% | 65.6% | 62.5% |
| Easy (48) | 93.8% | 25.0% | 81.2% | 83.3% |
| Medium (64) | 87.5% | 14.1% | 67.2% | 64.1% |
| Hard (48) | 62.5% | 10.4% | 47.9% | 39.6% |
| Query runs without error | 96.3% | 54.4% | 93.1% | 91.2% |
All four were tested as Q4_K_M files in Ollama.
Fine-tuning made this model much worse than its base. It joins tables the question never mentions and invents column names.
Run 2 was a second attempt to fix that: 6,598 Spider examples with the full schema of each database plus 3,000 multi-table examples from gretelai/synthetic_text_to_sql, a lower learning rate (5e-5), rank 16 and 2 epochs. It removed most of the invented columns and needless joins, but the result is still below the untuned base, so its weights are not published. Compared with the base it is less careful with details: it drops tie-break ordering and rounding that the question asks for, and writes = 'null' where IS NULL is needed. Epoch 2 scored lower than epoch 1.
Conclusion: neither fine-tune beats the untuned base model on realistic databases. The public training answers are terser and less careful than what Qwen2.5-7B-Instruct already writes.
In-distribution test set
Execution accuracy on 625 held-out questions from the same dataset as the training data. A query counts as correct only if it runs and returns the same rows as the reference query on three differently seeded SQLite databases.
| Model | All 625 | Hard subset (500) | Valid SQL |
|---|---|---|---|
| Qwen2.5-Coder-1.5B-Instruct, untuned (4-bit) | 57.6% | 54.0% | 100% |
| Qwen2.5-7B-Instruct, untuned (Q4_K_M) | 68.0% | 61.6% | 100% |
| This model (Q4_K_M) | 83.4% | 81.6% | 100% |
"Hard" means the reference query uses a join, grouping, ordering, an aggregate, a set operation, or more than one table.
Use with Ollama
Download text2sql-qwen2.5-7b-Q4_K_M.gguf and Modelfile into the same folder, then:
ollama create text2sql -f Modelfile
ollama run text2sql
Send the schema as CREATE TABLE statements, a blank line, then the question. This is the exact format the model was trained on:
Schema:
CREATE TABLE instructor (salary INTEGER)
Question: Find the salaries of all distinct instructors that are less than the largest salary.
The reply is a single query in a fenced block:
```sql
SELECT DISTINCT salary FROM instructor WHERE salary < (SELECT MAX(salary) FROM instructor)
```
The system prompt, already set in the Modelfile, is:
You are a SQLite expert. Given a database schema and a question, write one SQLite query that answers it. Reply with only the query inside a ```sql code block.
Training
- Method: supervised LoRA fine-tuning on Nebius Token Factory.
- Data: 5,698 training and 300 validation examples drawn from b-mc2/sql-create-context, keeping only examples whose reference query runs and returns rows on generated SQLite databases. The 625 test questions are a separate slice of the same dataset.
- Settings: rank 32, alpha 64, dropout 0.05, learning rate 1e-4, batch size 16, 3 epochs (1,071 steps, about 2.0M tokens), all attention and MLP projection layers.
- This is the epoch-3 checkpoint, merged into the base weights and quantized with llama.cpp.
Limitations
- It does not generalise beyond its training distribution. On realistic multi-table schemas it is far worse than the base model it was trained from (16.3% against 81.9%), and almost half of its queries fail to run. The in-distribution score should not be read as a measure of usefulness.
- About one answer in six is wrong even on the in-distribution test set. Read the query before trusting its result. A typical slip is picking the wrong column to return or the wrong comparison direction.
- Columns the question does not need can distract it. With the schema
instructor (name, salary, dept)the example above comes back with a strayGROUP BY deptinside the subquery, which is wrong. - It writes one read-only
SELECTstatement in SQLite dialect. It was not trained on writes, multi-statement scripts, or other dialects. - Training schemas are small, mostly one or two tables, and nearly every column in them is used by the answer. That is the likely cause of the failure on real schemas.
- Many questions in the source data do not say which aggregate is wanted, and the reference picks one arbitrarily (
MINversusMAX, for example). That caps the score any model can reach on this test set. - The published checkpoint was chosen between epoch 2 (82.6%) and epoch 3 (83.4%) using the test set itself. The gap is five questions, well within noise, so treat 83.4% as slightly optimistic.
- The 625 test questions come from the same dataset as the training data, which is why that score is high while the real-world score is low.
Credits and licenses
- Base model: Qwen/Qwen2.5-7B-Instruct, Apache 2.0. This model is released under the same license.
- Training data: b-mc2/sql-create-context, CC BY 4.0, itself built from WikiSQL and Spider.
- Downloads last month
- 102
4-bit