Downloads · 30 days
13
3% of all-time downloads
cudo528/Nanbeige4.2-3B-mlx-bf16
Nanbeige4.2-3B-mlx-bf16 is a text generation model from cudo528. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as apache-2.0.
An MLX bfloat16 conversion of Nanbeige/Nanbeige4.2-3B, ready to run on Apple Silicon with mlx-lm.
Downloads · 30 days
13
3% of all-time downloads
All-time downloads
468
Public
Parameters
4.2B
8.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors8.3 GB · 100%
From the Hugging Face model README
An MLX bfloat16 conversion of
Nanbeige/Nanbeige4.2-3B,
ready to run on Apple Silicon with mlx-lm.
bfloat16 (no quantization — full-precision weights)Nanbeige/Nanbeige4.2-3B with mlx_lm.convert(..., quantize=False, dtype="bfloat16")[!IMPORTANT] This model needs a custom architecture file to load. Nanbeige uses a looped transformer architecture (
model_type: "nanbeige") thatmlx-lmdoes not support out of the box. Without the step below you will get:ValueError: Model type nanbeige not supported.This repo ships the requirednanbeige.py— see Setup.
Install mlx-lm, then drop the bundled nanbeige.py into mlx-lm's model registry:
pip install -U mlx-lm
# Download nanbeige.py from this repo, then copy it into mlx_lm/models/:
python - <<'PY'
import mlx_lm, os, shutil
dst = os.path.join(os.path.dirname(mlx_lm.__file__), "models", "nanbeige.py")
shutil.copy("nanbeige.py", dst)
print("installed ->", dst)
PY
Note: re-installing or upgrading
mlx-lmremoves this file — just copy it again.
from mlx_lm import load, generate
model, tokenizer = load("cudo528/Nanbeige4.2-3B-mlx-bf16")
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": "What is the capital of France?"}],
add_generation_prompt=True,
)
text = generate(model, tokenizer, prompt=prompt, max_tokens=256, verbose=True)
mlx_lm.generate \
--model cudo528/Nanbeige4.2-3B-mlx-bf16 \
--prompt "Explain rotary position embeddings in one paragraph."
| Base model | Nanbeige/Nanbeige4.2-3B |
| Architecture | nanbeige — Llama-style decoder run as a looped transformer |
| Decoder layers | 22 (weights) · executed 2× (num_loops = 2) → 44 effective passes |
| Hidden size | 3072 |
| Attention heads | 48 (head_dim = 128) |
| KV heads | 8 (grouped-query attention) |
| Intermediate size | 10752 (SwiGLU / SiLU) |
| Normalization | RMSNorm (eps = 1e-5) |
| Position encoding | RoPE (theta = 7e7) |
| Vocab size | 166,144 |
| Max context | 262,144 |
| Tied embeddings | No (separate lm_head) |
| Weight dtype | bfloat16 |
Nanbeige reuses a single 22-layer stack for num_loops passes instead of stacking
distinct layers. The effective forward is:
h = embed(x)
for loop in range(num_loops): # num_loops = 2
for layer in layers: h = layer(h) # KV cache slot = layer_idx + loop * 22
h = norm(h) # final norm after each loop pass
logits = lm_head(h)
Because layers are shared across loops, the KV cache holds
num_loops × num_layers = 44 entries (each loop pass keeps its own keys/values).
This behavior is implemented in the bundled nanbeige.py.
from mlx_lm import convert
convert(
"Nanbeige/Nanbeige4.2-3B",
"Nanbeige4.2-3B-mlx-bf16",
quantize=False,
dtype="bfloat16",
)
The converted model loads in mlx-lm and produces coherent generations (e.g.
correctly answers "The capital of France is Paris."). Weights are cast to
bfloat16 with no quantization, so quality matches the original within bf16 precision.