Instructions to use vote-for-pedro/Nanbeige4.2-3B-mlx-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use vote-for-pedro/Nanbeige4.2-3B-mlx-4bit 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("vote-for-pedro/Nanbeige4.2-3B-mlx-4bit") 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 vote-for-pedro/Nanbeige4.2-3B-mlx-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit"
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": "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use vote-for-pedro/Nanbeige4.2-3B-mlx-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use vote-for-pedro/Nanbeige4.2-3B-mlx-4bit 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 "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit"
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 vote-for-pedro/Nanbeige4.2-3B-mlx-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use vote-for-pedro/Nanbeige4.2-3B-mlx-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit"
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 "vote-for-pedro/Nanbeige4.2-3B-mlx-4bit" \ --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"
Nanbeige4.2-3B-mlx-4bit
An MLX conversion of Nanbeige/Nanbeige4.2-3B, for fast local inference on Apple silicon.
This is the 4-bit conversion (~4.5 bits/weight, group size 64).
| Precision | 4-bit |
| On-disk size | 2.2 GB |
| Peak RAM (generation) | ~2.5 GB |
| Context length | 262 144 |
| Languages | English, Chinese |
⚠️ Requires a custom model class
Nanbeige uses a custom architecture (model_type: nanbeige) that is not yet
part of mlx-lm, so you must drop a small model file into your mlx-lm install
before loading:
pip install -U mlx-lm
# copy the bundled nanbeige.py into mlx_lm/models/
curl -L https://huggingface.co/vote-for-pedro/Nanbeige4.2-3B-mlx-4bit/resolve/main/nanbeige.py \
-o "$(python3 -c 'import mlx_lm,os;print(os.path.dirname(mlx_lm.__file__))')/models/nanbeige.py"
nanbeige.py is included in this repo.
Usage
python3 -m mlx_lm generate --model vote-for-pedro/Nanbeige4.2-3B-mlx-4bit \
--prompt "Explain how rotary position embeddings work." --max-tokens 400
from mlx_lm import load, generate
model, tok = load("vote-for-pedro/Nanbeige4.2-3B-mlx-4bit")
messages = [{"role": "user", "content": "Give me three study tips."}]
prompt = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
print(generate(model, tok, prompt=prompt, max_tokens=400))
Note: Nanbeige4.2 is a reasoning model — it emits a thinking trace before the final answer. Parse after the trace for the answer itself.
Architecture
Under the hood the released checkpoint is a standard Llama-style GQA decoder
(RMSNorm, SwiGLU MLP, rotate-half RoPE with θ=7e7, 48 query / 8 KV heads,
head-dim 128, 22 layers, vocab 166 144) with one non-standard behavior:
weight-tied looping (num_loops: 2) — the full 22-layer stack is executed
twice with shared weights, each loop keeping its own KV cache, with a final
RMSNorm applied between loops. All other optional features in the original
modeling code (n-gram embeddings, hyper-connection / mHC, depth-attention,
double-loop split, QK-LayerNorm) are disabled in this checkpoint and carry no
weights.
Conversion & validation
- Converted with
mlx_lm.convertfrom the original bf16 safetensors. - The MLX implementation was validated numerically against the original Hugging Face model in fp32: identical argmax on every position and max |Δ| ≈ 1e-4 on the logits (bit-level agreement).
- The per-loop KV cache was checked for prompt-forward vs. token-by-token consistency.
During validation, two
transformers >= 5incompatibilities were found in the original modeling code (arope_scalingcrash and a degenerate RoPE). This MLX build is unaffected — it does not usetransformersfor inference — but be aware the original PyTorch weights may misbehave on currenttransformers.
License & attribution
Apache-2.0, inherited from the base model Nanbeige/Nanbeige4.2-3B. All credit for the model belongs to the Nanbeige team; this repo only provides an MLX-format conversion.
- Downloads last month
- 89
4-bit