Instructions to use samuelfaj/distill-E4B-it-4-bit-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use samuelfaj/distill-E4B-it-4-bit-MLX 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("samuelfaj/distill-E4B-it-4-bit-MLX") 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 samuelfaj/distill-E4B-it-4-bit-MLX with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samuelfaj/distill-E4B-it-4-bit-MLX"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "samuelfaj/distill-E4B-it-4-bit-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use samuelfaj/distill-E4B-it-4-bit-MLX 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 "samuelfaj/distill-E4B-it-4-bit-MLX"
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 samuelfaj/distill-E4B-it-4-bit-MLX
Run Hermes
hermes
- OpenClaw new
How to use samuelfaj/distill-E4B-it-4-bit-MLX with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samuelfaj/distill-E4B-it-4-bit-MLX"
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 "samuelfaj/distill-E4B-it-4-bit-MLX" \ --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"
- MLX LM
How to use samuelfaj/distill-E4B-it-4-bit-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "samuelfaj/distill-E4B-it-4-bit-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "samuelfaj/distill-E4B-it-4-bit-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samuelfaj/distill-E4B-it-4-bit-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }'
distill-E4B-it-4-bit-MLX
MLX mixed-precision 4-bit (text-only) build of
samuelfaj/distill-E4B-it-4-bit,
for fast, accurate local inference on Apple Silicon. Distilled for CLI / command-output
compression → single-line {"response": <str>, "confidence": <int 0-100>}.
✅ Recommended build. Upgraded from plain 4-bit to a Q4_K_M-style mixed recipe (lm_head + sensitive v_proj/down_proj at 6-bit, rest 4-bit). Pair it with the constrained decoding snippet below for near-perfect format compliance.
Details
| Field | Value |
|---|---|
| Base | google/gemma-4-E4B-it |
| Adapter | QLoRA r=64, α=128 (published root, sha256 a229d12c…) |
| Quantization | mixed mixed_4_6 (4-bit base, 6-bit lm_head + sensitive layers) — 4.65 bits/weight |
| Group size | 64 |
| Size on disk | ~4.0 GB |
| Peak memory | ~4.4 GB |
Evaluation
Set: eval_gold_v1 — 130 held-out CLI-compression cases. Decode: greedy.
| Build | P1 accuracy | JSON compliance | json_extraction |
|---|---|---|---|
| plain 4-bit (old) | 64.6% | 89.2% | 37.5% |
| mixed 4-bit | 67.7% | 92.3% | 37.5% |
| mixed 4-bit + constrained decode (this) | 69.2% | 99.2% | 56.2% |
| fp16 reference (ceiling) | 72.3% | 98.5% | 75.0% |
Mixed precision + constrained decoding recovers ~60% of the quantization gap to fp16
and pushes format compliance above the fp16 baseline (+10 pts vs plain 4-bit).
Confidence calibration is unchanged (ECE ≈ 0.29) — treat confidence as a soft signal.
Usage (with constrained decoding)
The model targets a strict {"response","confidence"} JSON contract. Prefilling the
opening of that object forces the schema and suppresses any reasoning preamble — this is
what drives JSON compliance from 92% → 99%.
pip install mlx-lm
import json
from mlx_lm import load, generate
model, tok = load("samuelfaj/distill-E4B-it-4-bit-MLX")
def ask(prompt: str) -> dict:
text = tok.apply_chat_template(
[{"role": "user", "content": prompt}],
add_generation_prompt=True, tokenize=False,
)
prefix = '{"response": "' # constrained decode: pin the contract
raw = prefix + generate(model, tok, prompt=text + prefix, max_tokens=800, verbose=False)
return json.loads(raw)
print(ask('Did the tests pass? Return PASS or FAIL, then failing tests.\n\n'
'PASS src/auth.test.ts\nFAIL src/queue.test.ts\n1 passed, 1 failed.'))
# {'response': 'FAIL src/queue.test.ts', 'confidence': 98}
Plain (unconstrained) decoding also works but is ~10 pts less format-compliant:
python -m mlx_lm generate --model samuelfaj/distill-E4B-it-4-bit-MLX \
--prompt "Is this safe? SAFE/REVIEW/UNSAFE.\n\nDROP TABLE users;" --max-tokens 256
Other builds
3-bit (⚠️ degraded) · 2-bit (❌ broken) · comparison vs distill-1.7B
- Downloads last month
- 27
4-bit
Model tree for samuelfaj/distill-E4B-it-4-bit-MLX
Base model
samuelfaj/distill-E4B-it-4-bit