Instructions to use srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 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("srv-sngh/Nanbeige4.2-3B-mlx-nvfp4") 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 srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4"
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": "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 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 "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4"
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 srv-sngh/Nanbeige4.2-3B-mlx-nvfp4
Run Hermes
hermes
- OpenClaw new
How to use srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4"
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 "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4" \ --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 srv-sngh/Nanbeige4.2-3B-mlx-nvfp4 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "srv-sngh/Nanbeige4.2-3B-mlx-nvfp4", "messages": [ {"role": "user", "content": "Hello"} ] }'
Nanbeige4.2-3B — MLX NVFP4
Nanbeige4.2-3B quantized to NVFP4 (4-bit float, group size 16) in MLX format, for Krill on Apple Silicon.
| Base | Nanbeige/Nanbeige4.2-3B (bf16, 8.3 GB) |
| This build | NVFP4, 4-bit / group 16 (2.26 GB) |
| Quantized tensors | 156 (22 layers x 7, plus embed_tokens and lm_head) |
| Context | 262,144 |
Quantized with Krill's native Swift+MLX checkpoint quantizer
(krill quantize --mode nvfp4) — no Python, no mlx_lm.convert.
⚠️ Runtime support: Krill only
This build runs in Krill and nowhere else. That is not a packaging choice — as of this writing no other local inference engine implements the Nanbeige looped architecture:
| Runtime | Status |
|---|---|
| Krill ≥ 0.17.0 | ✅ native Swift+MLX runtime |
| llama.cpp / Ollama / LM Studio | ❌ unknown model architecture: 'nanbeige' |
| mlx-lm (0.31.3) | ❌ no nanbeige model module |
| vLLM / SGLang | ❌ upstream ships forks, not mainline support |
| transformers | ✅ but only via trust_remote_code on the original bf16 repo — it cannot read these nvfp4-packed tensors |
GGUF conversions of Nanbeige 4.2 exist on the Hub, but they do not load:
llama.cpp rejects the architecture before it reads any weights. If you are not
using Krill, use the original
Nanbeige/Nanbeige4.2-3B with
transformers.
Performance
Measured on Apple Silicon, 512-token prompt, same machine. The baseline is the
upstream PyTorch reference (modeling_nanbeige.py, fp16 on MPS) because it
is the only other runtime that can serve this model at all — an Ollama
comparison is impossible, not merely absent.
| Prefill | Decode | Load | Peak memory | |
|---|---|---|---|---|
| Krill 0.17.0, this nvfp4 build | 294.6 tok/s | 37.5 tok/s | 0.15 s | 1.7 GB |
| PyTorch reference, fp16 (MPS) | 204.0 tok/s | 9.7 tok/s | 10.2 s | ~8 GB |
| speed-up | 1.4× | 3.9× | 68× | ~4.7× smaller |
For scale, a dense qwen2.5-3b 4-bit in the same Krill build does 508.5 tok/s
prefill / 49.8 tok/s decode at 1.5 GB. Nanbeige decodes ~25% slower at a
comparable footprint — that is the loop being paid for: 44 effective layers
out of 22 blocks' worth of weights.
Usage
krill pull srv-sngh/Nanbeige4.2-3B-mlx-nvfp4
krill run Nanbeige4.2-3B-mlx-nvfp4 "Which number is bigger, 9.11 or 9.8?"
Nanbeige 4.2 is a reasoning model: its chat template opens an assistant turn
inside a <think> block, so the model spends tokens reasoning before it emits
any visible answer. Give it room — a few hundred tokens is often not enough to
close the block, and you will see an empty reply. --max-tokens 4000 or more is
a sensible floor for anything non-trivial.
Upstream's recommended sampling settings (from generation_config.json):
temperature 0.6, top_p 0.95, top_k 20 for reasoning and chat; temperature 1.0
for agentic and tool-use work.
About the architecture
This is not a plain Llama clone, and the quantized layout reflects that:
- Looped transformer.
num_loops: 2runs the whole 22-block stack twice over the same weights — 44 effective layer executions from 22 blocks' worth of parameters. Each execution keeps its own KV cache slot, so a runtime must allocatenum_loops * num_hidden_layers= 44 caches, not 22. The finalmodel.normis applied at the end of every loop. head_dimdecoupled fromhidden_size. 48 heads x 128 dims against a 3072-wide residual, soq_projis 3072 -> 6144 ando_proj6144 -> 3072. A loader that deriveshidden_size / num_attention_headsgets 64 and mis-shapes every attention projection.
The optional research features described in upstream's configuration_nanbeige.py
(multi-head hyper-connections with depth attention, concatenated n-gram
embeddings, LoopSplit, loop-shared KV) are off in this checkpoint and its
weight map contains none of their tensors.
Verification
The native Krill runtime backing this build is logit-parity gated against
upstream's own modeling_nanbeige.py (mlx-lm has no nanbeige port), on both a
synthetic fp32 fixture and these real weights — prefill and incremental cached
decode, matching argmax and cosine > 0.9999. A live smoke gate additionally
drives this checkpoint through the whole serving path (prompt → looped prefill →
44-cache decode → reasoning filter → detokenizer), and tool calling is verified
end to end.
Reproducing the reference?
NanbeigeRotaryEmbeddingregistersinv_freqwithpersistent=False, so it is absent from the checkpoint. Under transformers 5.x,from_pretrainedmaterializes the model from checkpoint tensors and that buffer is left zero-initialized on every layer — RoPE then applies no rotation at all and the reference emits positionless gibberish. Recomputeinv_freqafter loading before trusting any comparison. The shippedconfig.jsonalso hasrope_scaling: null, which transformers 5.x repopulates, tripping upstream's_init_ropeon a missing"type"key.
License
Apache 2.0, inherited from the base model. All credit for the model itself goes to the Nanbeige team at BOSS Zhipin.
- Downloads last month
- 79
4-bit