Text Generation
PEFT
Safetensors
Transformers
lora
sft
trl
unsloth
text-to-sql
education
local-first
conversational
Instructions to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/qwen2.5-coder-14b-instruct-bnb-4bit") model = PeftModel.from_pretrained(base_model, "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora") - Transformers
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora
- SGLang
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora 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 build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora 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 build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora", max_seq_length=2048, ) - Docker Model Runner
How to use build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora with Docker Model Runner:
docker model run hf.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora
docs: fix model card formatting
Browse files
README.md
CHANGED
|
@@ -9,105 +9,127 @@ tags:
|
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
- unsloth
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
-
|
| 15 |
---
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
"
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
Not
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
Training
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
Training completed on 2026-06-10.
|
| 89 |
|
| 90 |
-
Outputs
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
Evaluation is currently manual: a bank of 15 real-world-style queries spanning attendance, discipline, grades, enrollment, and equity comparisons is run through the LFED demo UI. Each query is scored on:
|
| 98 |
|
| 99 |
-
Correctness — does the answer match the expected aggregation/join?
|
| 100 |
-
SQL quality — is the generated SQL valid, safe, and readable?
|
| 101 |
-
UX — is the summary + table useful?
|
| 102 |
-
Latency — does the query complete within a reasonable time?
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
import torch
|
| 112 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 113 |
from peft import PeftModel
|
|
@@ -134,45 +156,71 @@ SQL:"""
|
|
| 134 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 135 |
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.0)
|
| 136 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
Use the matching GGUF:
|
| 139 |
|
|
|
|
| 140 |
llama-cli \
|
| 141 |
-m lfed-qwen2.5-coder-14b-sql-gguf/ggml-model-q4_k_m.gguf \
|
| 142 |
-p "Question: How many chronically absent students at Lincoln Elementary in 2023-2024?\nSQL:" \
|
| 143 |
-n 128 --temp 0.0
|
|
|
|
|
|
|
| 144 |
Or run the full LFED app locally:
|
| 145 |
|
|
|
|
| 146 |
git checkout -b product local-llamacpp-v1
|
| 147 |
python3.12 -m venv .venv && source .venv/bin/activate
|
| 148 |
pip install -r requirements.txt
|
| 149 |
python app.py
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
Estimated training energy use on a Modal A10G for ~2 epochs:
|
| 158 |
|
| 159 |
-
Hardware type: NVIDIA A10G
|
| 160 |
-
Training time: approximately 1–2 hours
|
| 161 |
-
Cloud provider: Modal
|
| 162 |
-
Region: likely US-east (Modal default)
|
| 163 |
-
Carbon emitted: not precisely measured; rough estimate using ML CO2 Impact calculator is on the order of tens to low-hundreds of grams of CO2eq.
|
| 164 |
-
|
| 165 |
-
|
| 166 |
|
| 167 |
-
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
@misc{lfed_sql_adapter,
|
| 170 |
title={Local First Education Data Framework: A Qwen2.5-Coder-14B LoRA Adapter for School-Data Text-to-SQL},
|
| 171 |
author={build-small-hackathon},
|
| 172 |
year={2026},
|
| 173 |
howpublished={\url{https://huggingface.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora}}
|
| 174 |
}
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
| 178 |
-
PEFT 0.19.1
|
|
|
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
- unsloth
|
| 12 |
+
- text-to-sql
|
| 13 |
+
- education
|
| 14 |
+
- local-first
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# LFED SQL Assistant — Qwen2.5-Coder-14B-LoRA
|
| 18 |
+
|
| 19 |
+
A LoRA adapter that turns plain-English school-data questions into read-only DuckDB SQL queries. Built for the **Local First Education Data Framework (LFED)**, a local-first analytics assistant for school administrators.
|
| 20 |
+
|
| 21 |
+
- **Live demo:** https://huggingface.co/spaces/build-small-hackathon/Kasualdad_LFED
|
| 22 |
+
- **GGUF (local/llama.cpp):** https://huggingface.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-gguf
|
| 23 |
+
- **Project:** https://huggingface.co/spaces/build-small-hackathon/Kasualdad_LFED
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## Model Details
|
| 28 |
+
|
| 29 |
+
- **Developer:** build-small-hackathon (HF Build Small Hackathon, Chapter One: Backyard AI)
|
| 30 |
+
- **Base model:** [`unsloth/qwen2.5-coder-14b-instruct-bnb-4bit`](https://huggingface.co/unsloth/qwen2.5-coder-14b-instruct-bnb-4bit)
|
| 31 |
+
- **Model type:** Causal LM, text-to-SQL, instruction-tuned
|
| 32 |
+
- **Language:** English (questions and SQL)
|
| 33 |
+
- **License:** Apache 2.0
|
| 34 |
+
- **Fine-tuning method:** Unsloth QLoRA (r=32, α=32, target modules `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`)
|
| 35 |
+
- **Training data:** 27,859 synthetic NL→SQL pairs over a 5-table education schema
|
| 36 |
+
- **Adapter size:** ~551 MB
|
| 37 |
+
- **Framework versions:** PEFT 0.19.1, transformers, Unsloth, TRL
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## Intended Use
|
| 42 |
+
|
| 43 |
+
This adapter is designed for a single downstream task: **converting natural-language questions about school data into safe, read-only SQL**.
|
| 44 |
+
|
| 45 |
+
### Direct use
|
| 46 |
+
- Drop the adapter onto the base model for inference in the LFED Gradio app.
|
| 47 |
+
- Run locally with the matching GGUF or with `transformers + PEFT`.
|
| 48 |
+
|
| 49 |
+
### Suitable questions
|
| 50 |
+
- "How many students were chronically absent at Lincoln Elementary in 2023-2024?"
|
| 51 |
+
- "What is the suspension rate by race/ethnicity at Washington Middle?"
|
| 52 |
+
- "Show the average GPA for English learners vs non-English learners."
|
| 53 |
+
- "Which school has the highest enrollment growth since 2021?"
|
| 54 |
+
|
| 55 |
+
### Out-of-scope use
|
| 56 |
+
- Not a general chatbot or coding assistant.
|
| 57 |
+
- Not trained on real student PII; the demo uses synthetic seed data only.
|
| 58 |
+
- Not suitable for arbitrary SQL dialects beyond DuckDB-compatible queries.
|
| 59 |
+
- Should not be used for write operations; the execution guard allows only `SELECT` statements.
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## Training Details
|
| 64 |
+
|
| 65 |
+
### Training data
|
| 66 |
+
|
| 67 |
+
- **Source:** synthetic data generated from hand-written templates, augmented with Gretel, and rephrased for natural-language variety.
|
| 68 |
+
- **Schema:** 5 tables — `students`, `enrollment`, `attendance`, `discipline`, `grades`.
|
| 69 |
+
- **Coverage:** single-table aggregations, joins, filtering by school/year/grade, subgroup comparisons, ranking, and simple rates/percentages.
|
| 70 |
+
- **Size:** 27,859 question→SQL pairs.
|
| 71 |
+
- **Format:** each example contains a `question` and a `sql` field.
|
| 72 |
+
- **Data generation scripts:** `modal_train/generate_synthetic_v2.py`, `modal_train/augment_gretel.py`, `modal_train/rephrase_pairs.py` in the project repo.
|
| 73 |
+
|
| 74 |
+
### Training procedure
|
| 75 |
+
|
| 76 |
+
| Setting | Value |
|
| 77 |
+
|---|---|
|
| 78 |
+
| Optimizer | AdamW (Unsloth default) |
|
| 79 |
+
| Learning rate | 1e-4 |
|
| 80 |
+
| LR scheduler | cosine |
|
| 81 |
+
| Warmup steps | 10 |
|
| 82 |
+
| Batch size | 4 |
|
| 83 |
+
| Gradient accumulation | 4 |
|
| 84 |
+
| Epochs | 2 |
|
| 85 |
+
| LoRA r | 32 |
|
| 86 |
+
| LoRA α | 32 |
|
| 87 |
+
| LoRA dropout | 0 |
|
| 88 |
+
| Target modules | all linear layers |
|
| 89 |
+
| Quantization | 4-bit (bnb NF4) |
|
| 90 |
+
| Max sequence length | 2048 |
|
| 91 |
+
| Trainer | SFTTrainer (TRL) |
|
| 92 |
+
| Packing | False |
|
| 93 |
+
| Hardware | Modal A10G |
|
| 94 |
+
|
| 95 |
Training completed on 2026-06-10.
|
| 96 |
|
| 97 |
+
### Outputs
|
| 98 |
+
|
| 99 |
+
| Artifact | Location |
|
| 100 |
+
|---|---|
|
| 101 |
+
| This LoRA adapter | `build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora` |
|
| 102 |
+
| Merged GGUF Q4_K_M | `build-small-hackathon/lfed-qwen2.5-coder-14b-sql-gguf` |
|
| 103 |
+
| Training code | `modal_train/` in the LFED project repo |
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## Evaluation
|
| 108 |
+
|
| 109 |
+
### Approach
|
| 110 |
+
|
| 111 |
Evaluation is currently manual: a bank of 15 real-world-style queries spanning attendance, discipline, grades, enrollment, and equity comparisons is run through the LFED demo UI. Each query is scored on:
|
| 112 |
|
| 113 |
+
1. Correctness — does the answer match the expected aggregation/join?
|
| 114 |
+
2. SQL quality — is the generated SQL valid, safe, and readable?
|
| 115 |
+
3. UX — is the summary + table useful?
|
| 116 |
+
4. Latency — does the query complete within a reasonable time?
|
| 117 |
+
|
| 118 |
+
### Known limitations
|
| 119 |
+
|
| 120 |
+
- The model is fine-tuned on synthetic data; real-world schema variations require additional prompting or fine-tuning.
|
| 121 |
+
- It occasionally needs explicit school name and school year in the question to produce the most reliable query.
|
| 122 |
+
- Complex multi-step reasoning (e.g., "students who improved GPA across consecutive years") can be brittle.
|
| 123 |
+
- Percentage/rate formatting is handled by the downstream app, not the model; the model may return either 0–1 proportions or already-scaled percentages.
|
| 124 |
+
- No formal academic benchmark evaluation has been run.
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
## How to Use
|
| 129 |
+
|
| 130 |
+
### With transformers + PEFT (HF Space path)
|
| 131 |
+
|
| 132 |
+
```python
|
| 133 |
import torch
|
| 134 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 135 |
from peft import PeftModel
|
|
|
|
| 156 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 157 |
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.0)
|
| 158 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
### With llama.cpp (local-first path)
|
| 162 |
+
|
| 163 |
Use the matching GGUF:
|
| 164 |
|
| 165 |
+
```bash
|
| 166 |
llama-cli \
|
| 167 |
-m lfed-qwen2.5-coder-14b-sql-gguf/ggml-model-q4_k_m.gguf \
|
| 168 |
-p "Question: How many chronically absent students at Lincoln Elementary in 2023-2024?\nSQL:" \
|
| 169 |
-n 128 --temp 0.0
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
Or run the full LFED app locally:
|
| 173 |
|
| 174 |
+
```bash
|
| 175 |
git checkout -b product local-llamacpp-v1
|
| 176 |
python3.12 -m venv .venv && source .venv/bin/activate
|
| 177 |
pip install -r requirements.txt
|
| 178 |
python app.py
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
---
|
| 182 |
+
|
| 183 |
+
## Bias, Risks, and Limitations
|
| 184 |
+
|
| 185 |
+
- **Synthetic data:** the training data is generated from templates and rephrased. Demographic patterns in the seed data do not represent any real population; they exist to exercise joins and filters.
|
| 186 |
+
- **No PII handling training:** the model has no special safeguards around personally identifiable information because the schema uses anonymized `student_id`s only.
|
| 187 |
+
- **Read-only enforcement is app-level:** the adapter itself will emit any SQL-like text; the downstream `data_engine.py` validator enforces `SELECT`-only and forbidden-token rules.
|
| 188 |
+
- **Hallucinated columns/tables:** the model may occasionally reference a plausible-sounding column that does not exist. The execution guard catches these via schema-aware `EXPLAIN` validation.
|
| 189 |
+
- **Numeric accuracy:** the model writes the SQL; percentage interpretation depends on the application layer. Users should verify rates and percentages against their own conventions.
|
| 190 |
+
|
| 191 |
+
---
|
| 192 |
+
|
| 193 |
+
## Environmental Impact
|
| 194 |
+
|
| 195 |
Estimated training energy use on a Modal A10G for ~2 epochs:
|
| 196 |
|
| 197 |
+
- **Hardware type:** NVIDIA A10G
|
| 198 |
+
- **Training time:** approximately 1–2 hours
|
| 199 |
+
- **Cloud provider:** Modal
|
| 200 |
+
- **Region:** likely US-east (Modal default)
|
| 201 |
+
- **Carbon emitted:** not precisely measured; rough estimate using [ML CO2 Impact calculator](https://mlco2.github.io/impact#compute) is on the order of tens to low-hundreds of grams of CO2eq.
|
| 202 |
+
|
| 203 |
+
---
|
| 204 |
|
| 205 |
+
## Citation
|
| 206 |
|
| 207 |
+
If you use this model, please cite the base model and the LFED project:
|
| 208 |
+
|
| 209 |
+
**BibTeX:**
|
| 210 |
+
```bibtex
|
| 211 |
@misc{lfed_sql_adapter,
|
| 212 |
title={Local First Education Data Framework: A Qwen2.5-Coder-14B LoRA Adapter for School-Data Text-to-SQL},
|
| 213 |
author={build-small-hackathon},
|
| 214 |
year={2026},
|
| 215 |
howpublished={\url{https://huggingface.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora}}
|
| 216 |
}
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
**APA:**
|
| 220 |
+
build-small-hackathon. (2026). *Local First Education Data Framework: A Qwen2.5-Coder-14B LoRA adapter for school-data text-to-SQL*. Hugging Face. https://huggingface.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora
|
| 221 |
+
|
| 222 |
+
---
|
| 223 |
+
|
| 224 |
+
## Framework versions
|
| 225 |
|
| 226 |
+
- PEFT 0.19.1
|
|
|