Unfold any HuggingFace transformer into an interactive architecture diagram, inline in Jupyter.
Project description
MODEL UNFOLDER
your one click model unfolder
from model_unfolder import unfold
unfold("meta-llama/Meta-Llama-3-8B")
Install
pip install model-unfolder
# for local development
pip install -e .
pip install transformers # only required to load by model ID
Three ways to call it
from model_unfolder import unfold
# 1) by HuggingFace model ID — only config.json is downloaded, never weights
unfold("meta-llama/Meta-Llama-3-8B")
unfold("deepseek-ai/DeepSeek-V3")
# 2) from a transformers AutoConfig
from transformers import AutoConfig
unfold(AutoConfig.from_pretrained("Qwen/Qwen2.5-7B", trust_remote_code=True))
# 3) from a raw config.json dict — no transformers install needed
import json
unfold(json.load(open("config.json")))
Built on transformers
Pass a model ID and unfold calls transformers.AutoConfig.from_pretrained(model_id) under the hood (parser.py). It only retries with trust_remote_code=True when Transformers says the config requires remote code.
Auth-token from your environment
Gated models (Llama-3, Mistral, Gemma, …) need a HuggingFace token. unfold reuses whatever transformers / huggingface_hub already see:
# Either set an env var
export HF_TOKEN="hf_xxxxxxxx" # also accepted: HUGGING_FACE_HUB_TOKEN
# or use the CLI cache (persists across sessions)
huggingface-cli login
# or load a .env in your notebook
# >>> from dotenv import load_dotenv; load_dotenv()
No extra config in model_unfolder itself.
Save / export
diagram = unfold(cfg)
diagram.save("model.html") # standalone interactive HTML
diagram.save("model.json") # IR (no rendering)
diagram.param_count() # {"total": ..., "active": ..., "per_layer": [...]}
diagram.to_ir() # full IR dict
Param estimates are close to published numbers — DeepSeek-V3 reports ~675B (~41B active), Llama-3-8B reports 8.03B.
Models supported
Transformers
| Family | Models |
|---|---|
| DeepSeek | DeepSeek-V2, DeepSeek-V3 (+ MTP head), Kimi K2 |
| Llama | Llama 3 / 3.1 / 3.2 / 3.3, OLMo-2, Llama 4 Scout / Maverick (MoE + iRoPE NoPE layers) |
| Mistral | Mistral 7B, Mixtral 8x7B / 8x22B, Mistral Medium 3.5 |
| Qwen | Qwen2 / 2.5, Qwen2-MoE, Qwen3, Qwen3-MoE, Qwen3.5 / 3.6 (+ MTP) |
| Gemma | Gemma 2 9B / 27B (interleaved local+global), Gemma 3 / 3n (+ PLE), Gemma 4 31B / E2B / E4B (+ PLE), RecurrentGemma 2B / 9B (LRU + local attention) |
| Cohere | Command R, Command R+, Command R7B (QK-Norm attention) |
| Jamba | Jamba (SSM + attention hybrid, MoE) |
| Zamba | Zamba 7B, Zamba2 2.7B / 7B (Mamba SSM + weight-shared attention) |
| Mamba | Mamba 130M–2.8B, Mamba-2 (pure SSM, no attention) |
| Falcon | Falcon 7B / 40B (parallel attn+FFN), Falcon-H1 (Mamba-2 SSM) |
| MiniMax | MiniMax-Text-01 (lightning + softmax hybrid, MoE) |
| RWKV | RWKV-4 / 5 / 6 (pure recurrent, no attention) |
Diffusors
Coming soon.
Custom
Drop a request in issues.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file model_unfolder-0.2.7.tar.gz.
File metadata
- Download URL: model_unfolder-0.2.7.tar.gz
- Upload date:
- Size: 77.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6d5eb82f37e3f24f0413172ab9f07a36e41e8289cb3aae612a5fa21a46a6460
|
|
| MD5 |
fcc64f5fc7e09ddb71403a0e2678b7fb
|
|
| BLAKE2b-256 |
3e17eace45d5c1e432cff13502ecd624ccb872d60415cb699297afed6a12e837
|
Provenance
The following attestation bundles were made for model_unfolder-0.2.7.tar.gz:
Publisher:
release.yml on SoumilB7/unfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_unfolder-0.2.7.tar.gz -
Subject digest:
d6d5eb82f37e3f24f0413172ab9f07a36e41e8289cb3aae612a5fa21a46a6460 - Sigstore transparency entry: 1524943441
- Sigstore integration time:
-
Permalink:
SoumilB7/unfold@42c30d7d2b5075d396fdc2b36770a99a46ef64ee -
Branch / Tag:
refs/tags/v0.2.7 - Owner: https://github.com/SoumilB7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@42c30d7d2b5075d396fdc2b36770a99a46ef64ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file model_unfolder-0.2.7-py3-none-any.whl.
File metadata
- Download URL: model_unfolder-0.2.7-py3-none-any.whl
- Upload date:
- Size: 108.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7344c91d9c09edefbfb307b7959699cc7e1bc632d64ac7ba1dcfa76aa772dfd2
|
|
| MD5 |
9e8c9ed2d15e363b83366b362374c6c4
|
|
| BLAKE2b-256 |
0ee6c46b842c3300bcdaf317d258b58dc70036290597e4f56845f23b149499fd
|
Provenance
The following attestation bundles were made for model_unfolder-0.2.7-py3-none-any.whl:
Publisher:
release.yml on SoumilB7/unfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_unfolder-0.2.7-py3-none-any.whl -
Subject digest:
7344c91d9c09edefbfb307b7959699cc7e1bc632d64ac7ba1dcfa76aa772dfd2 - Sigstore transparency entry: 1524943464
- Sigstore integration time:
-
Permalink:
SoumilB7/unfold@42c30d7d2b5075d396fdc2b36770a99a46ef64ee -
Branch / Tag:
refs/tags/v0.2.7 - Owner: https://github.com/SoumilB7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@42c30d7d2b5075d396fdc2b36770a99a46ef64ee -
Trigger Event:
push
-
Statement type: