Instructions to use harshit2312/Nanbeige4.2-3B-mlx-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use harshit2312/Nanbeige4.2-3B-mlx-8bit 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("harshit2312/Nanbeige4.2-3B-mlx-8bit") 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 harshit2312/Nanbeige4.2-3B-mlx-8bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "harshit2312/Nanbeige4.2-3B-mlx-8bit"
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": "harshit2312/Nanbeige4.2-3B-mlx-8bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use harshit2312/Nanbeige4.2-3B-mlx-8bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "harshit2312/Nanbeige4.2-3B-mlx-8bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "harshit2312/Nanbeige4.2-3B-mlx-8bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "harshit2312/Nanbeige4.2-3B-mlx-8bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use harshit2312/Nanbeige4.2-3B-mlx-8bit 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 "harshit2312/Nanbeige4.2-3B-mlx-8bit"
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 harshit2312/Nanbeige4.2-3B-mlx-8bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use harshit2312/Nanbeige4.2-3B-mlx-8bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "harshit2312/Nanbeige4.2-3B-mlx-8bit"
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 "harshit2312/Nanbeige4.2-3B-mlx-8bit" \ --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"
File size: 2,211 Bytes
fe57af1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ---
license: apache-2.0
language:
- en
- zh
library_name: mlx
pipeline_tag: text-generation
tags:
- llm
- nanbeige
- mlx
base_model: Nanbeige/Nanbeige4.2-3B
---
# harshit2312/Nanbeige4.2-3B-mlx-8bit
This is an **8-bit MLX** conversion of [Nanbeige/Nanbeige4.2-3B](https://huggingface.co/Nanbeige/Nanbeige4.2-3B),
for running on Apple Silicon. Converted from the official weights with
[mlx-lm](https://github.com/ml-explore/mlx-lm) **0.31.3** (8-bit, group size 64).
## ⚠️ Requires a custom architecture module
Nanbeige4.2 is a **looped / recurrent-depth transformer** (`num_loops: 2` — the decoder
stack is executed twice, each pass with its own KV cache). Stock `mlx-lm` does **not**
ship a `nanbeige` architecture, so loading this repo directly will fail with
`Model type nanbeige not supported`. Install the bundled `nanbeige.py` into your mlx-lm first:
```python
import os, shutil, mlx_lm
from huggingface_hub import hf_hub_download
src = hf_hub_download("harshit2312/Nanbeige4.2-3B-mlx-8bit", "nanbeige.py")
dst = os.path.join(os.path.dirname(mlx_lm.__file__), "models", "nanbeige.py")
shutil.copy(src, dst)
print("installed nanbeige architecture ->", dst)
```
## Use with mlx
```bash
pip install mlx-lm
```
```python
from mlx_lm import load, generate
model, tokenizer = load("harshit2312/Nanbeige4.2-3B-mlx-8bit")
messages = [{"role": "user", "content": "What is unified memory on Apple Silicon?"}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=prompt, verbose=True, max_tokens=512)
```
> Note: Nanbeige4.2-3B is a **reasoning model** — its chat template opens the assistant
> turn with a `<think>` block, so responses begin with visible chain-of-thought.
## Verification
The MLX architecture port was validated against the official HuggingFace implementation
(fp32, eager attention): **40/40 greedy tokens matched**, with the MLX token being the
reference's argmax at every position.
## Conversion details
| | |
|---|---|
| Precision | 8-bit affine, group size 64 (~8.5 bits/weight) |
| Size | ~4.2 GB |
| Architecture | Llama-style (GQA 48/8 heads, head_dim 128, SwiGLU, RoPE θ=70M) + `num_loops=2` |
|