Instructions to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ"
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:8080/v1 hermes config set model.default majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ"
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:8080/v1 \ --custom-model-id "majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ
majentik's first DWQ pack. A 4-bit (group-size 32) MLX quantization of
Qwen/Qwen2.5-1.5B-Instruct,
refined with Distilled Weight Quantization (DWQ) — the quantization
scales/biases are fine-tuned against an 8-bit teacher, recovering quality that
plain affine 4-bit loses. Produced with the upstream MLX-LM learned-quant path
(mlx_lm.dwq), no forks.
- Teacher: majentik/Qwen2.5-1.5B-Instruct-MLX-8bit (our own 8-bit pack; ≈16-bit quality)
- Method: DWQ, 4-bit, group-size 32, distilled from the 8-bit teacher
- Tooling:
mlx-lm 0.31.3(mlx 0.32.0)
Variants
| Variant | Size | Status |
|---|---|---|
| Qwen2.5-1.5B-Instruct-MLX-8bit | 1.5 GB | teacher |
| Qwen2.5-1.5B-Instruct-MLX-4bit | 0.93 GB | plain affine 4-bit (gs32) |
| Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ | 0.93 GB | this repo — DWQ |
Quality gate
Perplexity over a fixed text sample (lower is better); DWQ must be ≥ as good as the plain affine 4-bit sibling to ship public:
| Pack | Perplexity ↓ |
|---|---|
| 8-bit teacher (reference) | 8.34 |
| plain affine 4-bit gs32 | 9.86 |
| this pack (DWQ 4-bit gs32) | 9.45 |
DWQ recovers ≈27% of the 4-bit→teacher gap. Training KL loss fell 0.116 → 0.050. A 5-prompt greedy sanity check (reasoning, translation, code, arithmetic) is coherent with no loops. Gate: PASS.
Exact gate invocation (mlx-lm 0.31.3, deterministic — no dataset, no sampling,
no seed; single forward pass, mean token NLL over a fixed passage, 197 target
tokens; ppl = exp(nll); full script in the library's docs/dwq-recipe.md
"Gate: exact invocation"):
import mlx.core as mx; from mlx_lm import load
m, t = load("majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ")
ids = mx.array(t.encode(TEXT))[None] # TEXT = fixed passage from docs/dwq-recipe.md
lg = m(ids[:, :-1]).astype(mx.float32)
lp = lg - mx.logsumexp(lg, axis=-1, keepdims=True)
nll = -mx.take_along_axis(lp, ids[:, 1:][..., None], axis=-1).mean()
print(float(mx.exp(nll))) # -> 9.45
The gate condition is the ordering (DWQ ≤ plain affine 4-bit); absolute perplexity values vary with the sample passage.
Recipe
# dwq_stable.py — forces the stable reference KL path (see repo docs/dwq-recipe.md)
import mlx_lm.tuner.losses as _losses
_losses.can_run_metal = lambda: False
from mlx_lm.quant.dwq import main
if __name__ == "__main__":
main()
python dwq_stable.py \
--model Qwen2.5-1.5B-Instruct-MLX-8bit \
--quantized-model Qwen2.5-1.5B-Instruct-MLX-4bit \
--mlx-path Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ \
--group-size 32 --bits 4 \
--num-samples 1024 --max-seq-length 512 --batch-size 1 \
--learning-rate 1e-6 --data-path allenai/tulu-3-sft-mixture
Full reproduction (teacher/baseline build, gate, and the mlx-lm 0.31.3 Metal-KL
workaround, filed upstream as ml-explore/mlx-lm#1700) is documented in the library's docs/dwq-recipe.md, per
docs/quantization-policy.md rule 2 (DWQ for 2–4-bit packs; group-size 32).
Usage
pip install mlx-lm
python -m mlx_lm generate --model majentik/Qwen2.5-1.5B-Instruct-MLX-4bit-DWQ \
--prompt "Explain what a hash table is in two sentences."
License
Apache-2.0, inherited from the base model Qwen/Qwen2.5-1.5B-Instruct.
- Downloads last month
- 88
4-bit