Kasualdad commited on
Commit
3c6b90a
·
verified ·
1 Parent(s): c3d1b55

docs: fix model card formatting

Browse files
Files changed (1) hide show
  1. README.md +160 -112
README.md CHANGED
@@ -9,105 +9,127 @@ tags:
9
  - transformers
10
  - trl
11
  - unsloth
12
- license: apache-2.0
13
- language:
14
- - en
15
  ---
16
 
17
- base_model unsloth/qwen2.5-coder-14b-instruct-bnb-4bit
18
- library_name peft
19
- pipeline_tag text-generation
20
- tags
21
- base_model:adapter:unsloth/qwen2.5-coder-14b-instruct-bnb-4bit
22
- lora
23
- sft
24
- transformers
25
- trl
26
- unsloth
27
- text-to-sql
28
- education
29
- local-first
30
- LFED SQL Assistant — Qwen2.5-Coder-14B-LoRA
31
- 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.
32
-
33
- Live demo: https://huggingface.co/spaces/build-small-hackathon/Kasualdad_LFED
34
- GGUF (local/llama.cpp): https://huggingface.co/build-small-hackathon/lfed-qwen2.5-coder-14b-sql-gguf
35
- Project: https://huggingface.co/spaces/build-small-hackathon/Kasualdad_LFED
36
- Model Details
37
- Developer: build-small-hackathon (HF Build Small Hackathon, Chapter One: Backyard AI)
38
- Base model: unsloth/qwen2.5-coder-14b-instruct-bnb-4bit
39
- Model type: Causal LM, text-to-SQL, instruction-tuned
40
- Language: English (questions and SQL)
41
- License: Apache 2.0
42
- Fine-tuning method: Unsloth QLoRA (r=32, α=32, target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
43
- Training data: 27,859 synthetic NL→SQL pairs over a 5-table education schema
44
- Adapter size: ~551 MB
45
- Framework versions: PEFT 0.19.1, transformers, Unsloth, TRL
46
- Intended Use
47
- This adapter is designed for a single downstream task: converting natural-language questions about school data into safe, read-only SQL.
48
-
49
- Direct use
50
- Drop the adapter onto the base model for inference in the LFED Gradio app.
51
- Run locally with the matching GGUF or with transformers + PEFT.
52
- Suitable questions
53
- "How many students were chronically absent at Lincoln Elementary in 2023-2024?"
54
- "What is the suspension rate by race/ethnicity at Washington Middle?"
55
- "Show the average GPA for English learners vs non-English learners."
56
- "Which school has the highest enrollment growth since 2021?"
57
- Out-of-scope use
58
- Not a general chatbot or coding assistant.
59
- Not trained on real student PII; the demo uses synthetic seed data only.
60
- Not suitable for arbitrary SQL dialects beyond DuckDB-compatible queries.
61
- Should not be used for write operations; the execution guard allows only SELECT statements.
62
- Training Details
63
- Training data
64
- Source: synthetic data generated from hand-written templates, augmented with Gretel, and rephrased for natural-language variety.
65
- Schema: 5 tables — students, enrollment, attendance, discipline, grades.
66
- Coverage: single-table aggregations, joins, filtering by school/year/grade, subgroup comparisons, ranking, and simple rates/percentages.
67
- Size: 27,859 question→SQL pairs.
68
- Format: each example contains a question and a sql field.
69
- Data generation scripts: modal_train/generate_synthetic_v2.py, modal_train/augment_gretel.py, modal_train/rephrase_pairs.py in the project repo.
70
- Training procedure
71
- Setting Value
72
- Optimizer AdamW (Unsloth default)
73
- Learning rate 1e-4
74
- LR scheduler cosine
75
- Warmup steps 10
76
- Batch size 4
77
- Gradient accumulation 4
78
- Epochs 2
79
- LoRA r 32
80
- LoRA α 32
81
- LoRA dropout 0
82
- Target modules all linear layers
83
- Quantization 4-bit (bnb NF4)
84
- Max sequence length 2048
85
- Trainer SFTTrainer (TRL)
86
- Packing False
87
- Hardware Modal A10G
 
 
 
 
 
 
 
88
  Training completed on 2026-06-10.
89
 
90
- Outputs
91
- Artifact Location
92
- This LoRA adapter build-small-hackathon/lfed-qwen2.5-coder-14b-sql-lora
93
- Merged GGUF Q4_K_M build-small-hackathon/lfed-qwen2.5-coder-14b-sql-gguf
94
- Training code modal_train/ in the LFED project repo
95
- Evaluation
96
- Approach
 
 
 
 
 
 
 
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
- Known limitations
104
- The model is fine-tuned on synthetic data; real-world schema variations require additional prompting or fine-tuning.
105
- It occasionally needs explicit school name and school year in the question to produce the most reliable query.
106
- Complex multi-step reasoning (e.g., "students who improved GPA across consecutive years") can be brittle.
107
- Percentage/rate formatting is handled by the downstream app, not the model; the model may return either 0–1 proportions or already-scaled percentages.
108
- No formal academic benchmark evaluation has been run.
109
- How to Use
110
- With transformers + PEFT (HF Space path)
 
 
 
 
 
 
 
 
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
- With llama.cpp (local-first path)
 
 
 
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
- Bias, Risks, and Limitations
151
- 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.
152
- No PII handling training: the model has no special safeguards around personally identifiable information because the schema uses anonymized student_ids only.
153
- 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.
154
- 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.
155
- Numeric accuracy: the model writes the SQL; percentage interpretation depends on the application layer. Users should verify rates and percentages against their own conventions.
156
- Environmental Impact
 
 
 
 
 
 
 
 
 
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
- Citation
165
- If you use this model, please cite the base model and the LFED project:
166
 
167
- BibTeX:
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
- APA: 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
 
 
 
 
 
 
 
176
 
177
- Framework versions
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