Instructions to use logicless/qwen25-coder-3b-sql-create-context-lora-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use logicless/qwen25-coder-3b-sql-create-context-lora-mlx with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("logicless/qwen25-coder-3b-sql-create-context-lora-mlx") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use logicless/qwen25-coder-3b-sql-create-context-lora-mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "logicless/qwen25-coder-3b-sql-create-context-lora-mlx" --prompt "Once upon a time"
- Atomic Chat
Upload 3 files
Browse files- README.md +88 -0
- adapter_config.json +41 -0
- adapters.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: mlx-community/Qwen2.5-Coder-3B-Instruct-4bit
|
| 3 |
+
library_name: mlx
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- mlx
|
| 9 |
+
- mlx-lm
|
| 10 |
+
- lora
|
| 11 |
+
- adapter
|
| 12 |
+
- text-to-sql
|
| 13 |
+
- sqlite
|
| 14 |
+
license: other
|
| 15 |
+
datasets:
|
| 16 |
+
- b-mc2/sql-create-context
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Qwen2.5-Coder-3B Text-to-SQL LoRA Adapter for MLX
|
| 20 |
+
|
| 21 |
+
This is a LoRA adapter for `mlx-community/Qwen2.5-Coder-3B-Instruct-4bit`, trained locally with MLX-LM on Apple Silicon for schema-conditioned text-to-SQL generation.
|
| 22 |
+
|
| 23 |
+
## Results
|
| 24 |
+
|
| 25 |
+
On a frozen 1,000-example held-out set with context groups disjoint from the 5,000 training rows:
|
| 26 |
+
|
| 27 |
+
| Metric | Base model | This adapter |
|
| 28 |
+
| --- | ---: | ---: |
|
| 29 |
+
| Normalized reference-SQL exact match | 5.2% | **77.0%** |
|
| 30 |
+
| Parser-valid SQL | 99.0% | **99.6%** |
|
| 31 |
+
| SELECT-only SQL | 99.0% | **99.6%** |
|
| 32 |
+
|
| 33 |
+
Exact match is normalized agreement with the dataset reference SQL, **not** a semantic-equivalence or database-execution result. SQL validity is parser-only; no database is opened or executed.
|
| 34 |
+
|
| 35 |
+
## Base model and compatibility
|
| 36 |
+
|
| 37 |
+
- **Base:** `mlx-community/Qwen2.5-Coder-3B-Instruct-4bit`
|
| 38 |
+
- **Pinned base revision:** `3dd939c621c08e5753d5b89f35a2642cd83b98ca`
|
| 39 |
+
- **Runtime tested:** MLX 0.32.2 and MLX-LM 0.31.3
|
| 40 |
+
- **Adapter type:** MLX-LM LoRA, rank 16, final 16 transformer layers
|
| 41 |
+
|
| 42 |
+
This repository contains an adapter only. It requires the base model above and an MLX-LM-compatible Apple Silicon environment.
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
from mlx_lm import generate, load
|
| 48 |
+
|
| 49 |
+
base_model = "mlx-community/Qwen2.5-Coder-3B-Instruct-4bit"
|
| 50 |
+
adapter_path = "/path/to/this/repository"
|
| 51 |
+
|
| 52 |
+
model, tokenizer = load(base_model, adapter_path=adapter_path)
|
| 53 |
+
messages = [
|
| 54 |
+
{
|
| 55 |
+
"role": "system",
|
| 56 |
+
"content": "You translate natural-language questions into SQLite SQL. Return exactly one read-only SELECT statement. Use only the supplied schema. Return SQL only: no Markdown fences, explanation, or comments.",
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"role": "user",
|
| 60 |
+
"content": "Schema:\\nCREATE TABLE employees (id INTEGER, name TEXT);\\n\\nQuestion: List employee names.\\n\\nSQL:",
|
| 61 |
+
},
|
| 62 |
+
]
|
| 63 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 64 |
+
print(generate(model, tokenizer, prompt=prompt, max_tokens=256, verbose=False))
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Training data and method
|
| 68 |
+
|
| 69 |
+
- Dataset: `b-mc2/sql-create-context`, revision `9d80a6a118b838d9defc3798d659a54a2ac2ff37`
|
| 70 |
+
- Inputs: supplied `CREATE TABLE` schema context plus natural-language question
|
| 71 |
+
- Target: reference SQLite SQL answer
|
| 72 |
+
- Split: 5,000 training and 1,000 held-out rows grouped by identical full schema context; zero shared context groups
|
| 73 |
+
- Training: 2,500 micro-batches, batch size 2, gradient accumulation 4, learning rate `1e-5`, prompt loss masking
|
| 74 |
+
|
| 75 |
+
## Limitations
|
| 76 |
+
|
| 77 |
+
- This is a local, schema-conditioned subset experiment, not a production SQL agent.
|
| 78 |
+
- Exact match can mark semantically equivalent SQL as incorrect.
|
| 79 |
+
- The evaluator does not execute queries, validate schema references, or assess result equivalence.
|
| 80 |
+
- Use generated SQL with normal application-level authorization and review controls.
|
| 81 |
+
|
| 82 |
+
## License and attribution
|
| 83 |
+
|
| 84 |
+
The training dataset is distributed under CC-BY-4.0 and should be attributed to `b-mc2/sql-create-context`. This adapter is derived from Qwen2.5-Coder-3B-Instruct; use is subject to the [Qwen Research License](https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct/blob/main/LICENSE). This model card does not grant rights beyond those upstream terms.
|
| 85 |
+
|
| 86 |
+
## Project source
|
| 87 |
+
|
| 88 |
+
The accompanying experiment code and technical report are published at [karyboy/mlx-text-to-sql-lora](https://github.com/karyboy/mlx-text-to-sql-lora).
|
adapter_config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"adapter_path": "adapters/qwen25-coder-3b-sql-create-context-lora-run2",
|
| 3 |
+
"batch_size": 2,
|
| 4 |
+
"clear_cache_threshold": 0,
|
| 5 |
+
"config": "/Users/karneshmehra/Projects/posttrain/configs/lora.yaml",
|
| 6 |
+
"data": "data/processed/mlx_chat",
|
| 7 |
+
"fine_tune_type": "lora",
|
| 8 |
+
"grad_accumulation_steps": 4,
|
| 9 |
+
"grad_checkpoint": true,
|
| 10 |
+
"iters": 2500,
|
| 11 |
+
"learning_rate": 1e-05,
|
| 12 |
+
"lora_parameters": {
|
| 13 |
+
"rank": 16,
|
| 14 |
+
"dropout": 0.05,
|
| 15 |
+
"scale": 32.0
|
| 16 |
+
},
|
| 17 |
+
"lr_schedule": null,
|
| 18 |
+
"mask_prompt": true,
|
| 19 |
+
"max_seq_length": 2048,
|
| 20 |
+
"model": "mlx-community/Qwen2.5-Coder-3B-Instruct-4bit",
|
| 21 |
+
"num_layers": 16,
|
| 22 |
+
"optimizer": "adam",
|
| 23 |
+
"optimizer_config": {
|
| 24 |
+
"adam": {},
|
| 25 |
+
"adamw": {},
|
| 26 |
+
"muon": {},
|
| 27 |
+
"sgd": {},
|
| 28 |
+
"adafactor": {}
|
| 29 |
+
},
|
| 30 |
+
"project_name": null,
|
| 31 |
+
"report_to": null,
|
| 32 |
+
"resume_adapter_file": null,
|
| 33 |
+
"save_every": 100,
|
| 34 |
+
"seed": 20260914,
|
| 35 |
+
"steps_per_eval": 200,
|
| 36 |
+
"steps_per_report": 10,
|
| 37 |
+
"test": false,
|
| 38 |
+
"test_batches": 500,
|
| 39 |
+
"train": true,
|
| 40 |
+
"val_batches": 25
|
| 41 |
+
}
|
adapters.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:540c5cf5db7c1c73ff0a713581e14fc68fb1309d15c5018b34c19d47e01acded
|
| 3 |
+
size 53239690
|