Instructions to use logicless/qwen25-coder-3b-markdown-reliability-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-markdown-reliability-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-markdown-reliability-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-markdown-reliability-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-markdown-reliability-lora-mlx" --prompt "Once upon a time"
- Atomic Chat
Publish final Run 2 MLX LoRA adapter
Browse files- LICENSE +21 -0
- README.md +155 -0
- adapter_config.json +45 -0
- adapters.safetensors +3 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Karnesh Mehra
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: mlx-community/Qwen2.5-Coder-3B-Instruct-4bit
|
| 3 |
+
library_name: mlx
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
license: mit
|
| 6 |
+
tags:
|
| 7 |
+
- mlx
|
| 8 |
+
- mlx-lm
|
| 9 |
+
- lora
|
| 10 |
+
- text-generation
|
| 11 |
+
- markdown
|
| 12 |
+
- supervised-fine-tuning
|
| 13 |
+
- apple-silicon
|
| 14 |
+
datasets:
|
| 15 |
+
- nuprl/MultiPL-E
|
| 16 |
+
- google-research-datasets/mbpp
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Qwen2.5-Coder-3B Markdown Reliability LoRA (MLX)
|
| 20 |
+
|
| 21 |
+
This repository contains the final MLX-LM LoRA adapter from a two-stage local
|
| 22 |
+
supervised fine-tuning experiment for strict Markdown structure compliance.
|
| 23 |
+
It is designed for the 4-bit Apple Silicon base model
|
| 24 |
+
[`mlx-community/Qwen2.5-Coder-3B-Instruct-4bit`](https://huggingface.co/mlx-community/Qwen2.5-Coder-3B-Instruct-4bit)
|
| 25 |
+
at revision `3dd939c621c08e5753d5b89f35a2642cd83b98ca`.
|
| 26 |
+
|
| 27 |
+
On a frozen 240-prompt LatentMD evaluation subset, full structural-contract
|
| 28 |
+
accuracy improved from **8.33%** for the base model to **32.08%** after broad
|
| 29 |
+
Run 1 SFT and **82.50%** after the targeted Run 2 correction.
|
| 30 |
+
|
| 31 |
+
| Model state | Passed | Full contract pass rate |
|
| 32 |
+
| --- | ---: | ---: |
|
| 33 |
+
| Base model | 20/240 | 8.33% |
|
| 34 |
+
| Run 1 broad SFT | 77/240 | 32.08% |
|
| 35 |
+
| Run 2 targeted booster | 198/240 | **82.50%** |
|
| 36 |
+
|
| 37 |
+
The full experiment, source code, evaluator, generated-data pipeline, configs,
|
| 38 |
+
and report are available at
|
| 39 |
+
[`karyboy/mlx-markdown-reliability-lora`](https://github.com/karyboy/mlx-markdown-reliability-lora).
|
| 40 |
+
|
| 41 |
+
## What is included
|
| 42 |
+
|
| 43 |
+
- `adapters.safetensors`: final iteration-300 Run 2 adapter (about 114 MiB);
|
| 44 |
+
- `adapter_config.json`: complete portable MLX-LM adapter/training metadata;
|
| 45 |
+
- `configs/`: frozen experiment, Run 1, and Run 2 configurations;
|
| 46 |
+
- `results/`: final external metrics, comparison, and training summary.
|
| 47 |
+
|
| 48 |
+
The Run 2 adapter is **standalone relative to the base model**. Although Run 2
|
| 49 |
+
continued training from Run 1, its saved tensor file contains the complete
|
| 50 |
+
final LoRA state; users do not need to download or stack the Run 1 adapter.
|
| 51 |
+
Paths such as `data`, `config`, and `resume_adapter_file` in
|
| 52 |
+
`adapter_config.json` document the original reproducible training run. The
|
| 53 |
+
MLX-LM inference loader uses the model-shape and LoRA fields and does not need
|
| 54 |
+
those training files.
|
| 55 |
+
|
| 56 |
+
## Load with MLX-LM
|
| 57 |
+
|
| 58 |
+
MLX-LM expects an adapter directory on disk, so download this repository first:
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from huggingface_hub import snapshot_download
|
| 62 |
+
from mlx_lm import generate, load
|
| 63 |
+
|
| 64 |
+
BASE_MODEL = "mlx-community/Qwen2.5-Coder-3B-Instruct-4bit"
|
| 65 |
+
ADAPTER_REPO = "logicless/qwen25-coder-3b-markdown-reliability-lora-mlx"
|
| 66 |
+
|
| 67 |
+
adapter_dir = snapshot_download(
|
| 68 |
+
repo_id=ADAPTER_REPO,
|
| 69 |
+
allow_patterns=["adapter_config.json", "adapters.safetensors"],
|
| 70 |
+
)
|
| 71 |
+
model, tokenizer = load(BASE_MODEL, adapter_path=adapter_dir)
|
| 72 |
+
|
| 73 |
+
messages = [{
|
| 74 |
+
"role": "user",
|
| 75 |
+
"content": (
|
| 76 |
+
"Write a concise Markdown guide with a title, a numbered list, "
|
| 77 |
+
"and one fenced Python example. Return the document directly."
|
| 78 |
+
),
|
| 79 |
+
}]
|
| 80 |
+
prompt = tokenizer.apply_chat_template(
|
| 81 |
+
messages,
|
| 82 |
+
tokenize=False,
|
| 83 |
+
add_generation_prompt=True,
|
| 84 |
+
)
|
| 85 |
+
response = generate(
|
| 86 |
+
model,
|
| 87 |
+
tokenizer,
|
| 88 |
+
prompt=prompt,
|
| 89 |
+
max_tokens=800,
|
| 90 |
+
verbose=False,
|
| 91 |
+
)
|
| 92 |
+
print(response)
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
Install the tested runtime with:
|
| 96 |
+
|
| 97 |
+
```zsh
|
| 98 |
+
python -m pip install "mlx-lm[train]==0.31.3" "huggingface_hub==1.31.0"
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Training summary
|
| 102 |
+
|
| 103 |
+
The model was trained using assistant-only token loss with LoRA modules on all
|
| 104 |
+
36 transformer blocks.
|
| 105 |
+
|
| 106 |
+
| Setting | Run 1 | Run 2 |
|
| 107 |
+
| --- | ---: | ---: |
|
| 108 |
+
| Examples | 5,000 broad SFT | 600 targeted booster |
|
| 109 |
+
| LoRA rank / scale / dropout | 16 / 32 / 0.05 | 16 / 32 / 0.05 |
|
| 110 |
+
| Learning rate | `1e-5` | `2e-6` |
|
| 111 |
+
| Effective batch size | 8 | 8 |
|
| 112 |
+
| Selected iterations | 500 | 300 |
|
| 113 |
+
| Optimizer updates | 125 | 75 |
|
| 114 |
+
| Trained tokens | 261,123 | 91,031 |
|
| 115 |
+
|
| 116 |
+
Run 1 improved broad structural behavior but failed all 80 external prompts
|
| 117 |
+
that required an outer four-backtick `markdown` wrapper. Run 2 used short
|
| 118 |
+
targets, exact instruction wording, A2 oversampling, and matched A1/A2 contrast
|
| 119 |
+
pairs. It brought external A2 full-contract accuracy from 0/80 to 63/80 while
|
| 120 |
+
preserving the A1 and A3 controls.
|
| 121 |
+
|
| 122 |
+
## Evaluation
|
| 123 |
+
|
| 124 |
+
The same frozen prompts and deterministic generation settings were used for
|
| 125 |
+
the base model and both adapters. Run 2 results by wrapper axis were A1 82.50%,
|
| 126 |
+
A2 78.75%, and A3 86.25%. By content-complexity axis they were B1 95%, B2 90%,
|
| 127 |
+
B3 80%, and B4 65%.
|
| 128 |
+
|
| 129 |
+
The score is produced by this project's deterministic structural evaluator.
|
| 130 |
+
It checks fence balance, wrapper policy, language-specific code examples, raw
|
| 131 |
+
Markdown source, tables, cited blockquotes, and numbered lists. It is not the
|
| 132 |
+
LatentMD authors' official evaluator and does not assess semantic correctness
|
| 133 |
+
of arbitrary prose or code.
|
| 134 |
+
|
| 135 |
+
## Training data
|
| 136 |
+
|
| 137 |
+
The SFT examples are deterministically rendered and programmatically verified
|
| 138 |
+
from task-family-disjoint MBPP and MultiPL-E content plans. The LatentMD prompts
|
| 139 |
+
are evaluation-only and are never used as training targets. See the GitHub
|
| 140 |
+
repository's data attribution and generation scripts for exact source
|
| 141 |
+
revisions, licenses, splits, and leakage checks.
|
| 142 |
+
|
| 143 |
+
## Limitations
|
| 144 |
+
|
| 145 |
+
- This adapter targets Markdown structure, not factuality or code correctness.
|
| 146 |
+
- The 240-prompt result is a controlled experiment rather than a comprehensive
|
| 147 |
+
benchmark of Markdown generation.
|
| 148 |
+
- The local evaluator is project-specific.
|
| 149 |
+
- This adapter is in MLX-LM format for Apple Silicon; other runtimes may require
|
| 150 |
+
conversion.
|
| 151 |
+
|
| 152 |
+
## License
|
| 153 |
+
|
| 154 |
+
The adapter and project code are released under MIT. The original base model
|
| 155 |
+
and source datasets retain their respective licenses.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"adapter_path": "adapters/qwen25-coder-3b-markdown-reliability-wrapper-run2",
|
| 3 |
+
"batch_size": 2,
|
| 4 |
+
"clear_cache_threshold": 0,
|
| 5 |
+
"config": "configs/lora_wrapper_booster.yaml",
|
| 6 |
+
"data": "data/processed/wrapper_booster",
|
| 7 |
+
"early_stopped": false,
|
| 8 |
+
"fine_tune_type": "lora",
|
| 9 |
+
"grad_accumulation_steps": 4,
|
| 10 |
+
"grad_checkpoint": true,
|
| 11 |
+
"iters": 300,
|
| 12 |
+
"learning_rate": 2e-06,
|
| 13 |
+
"lora_parameters": {
|
| 14 |
+
"dropout": 0.05,
|
| 15 |
+
"rank": 16,
|
| 16 |
+
"scale": 32.0
|
| 17 |
+
},
|
| 18 |
+
"lr_schedule": null,
|
| 19 |
+
"mask_prompt": true,
|
| 20 |
+
"max_seq_length": 1280,
|
| 21 |
+
"model": "mlx-community/Qwen2.5-Coder-3B-Instruct-4bit",
|
| 22 |
+
"model_revision": "3dd939c621c08e5753d5b89f35a2642cd83b98ca",
|
| 23 |
+
"num_layers": -1,
|
| 24 |
+
"optimizer": "adam",
|
| 25 |
+
"optimizer_config": {
|
| 26 |
+
"adafactor": {},
|
| 27 |
+
"adam": {},
|
| 28 |
+
"adamw": {},
|
| 29 |
+
"muon": {},
|
| 30 |
+
"sgd": {}
|
| 31 |
+
},
|
| 32 |
+
"planned_iters": 300,
|
| 33 |
+
"project_name": null,
|
| 34 |
+
"report_to": null,
|
| 35 |
+
"resume_adapter_file": "adapters/qwen25-coder-3b-markdown-reliability-lora/adapters.safetensors",
|
| 36 |
+
"save_every": 50,
|
| 37 |
+
"seed": 20260929,
|
| 38 |
+
"steps_per_eval": 50,
|
| 39 |
+
"steps_per_report": 10,
|
| 40 |
+
"stopped_at_iteration": 300,
|
| 41 |
+
"test": false,
|
| 42 |
+
"test_batches": 500,
|
| 43 |
+
"train": true,
|
| 44 |
+
"val_batches": -1
|
| 45 |
+
}
|
adapters.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a892954dbf11822d6f4ab1ef50328b6ade8ca3fad072b8706eb319dfaa27e5d5
|
| 3 |
+
size 119789457
|