Skip to main content

Unfold any HuggingFace transformer into an interactive architecture diagram, inline in Jupyter.

Project description

MODEL UNFOLDER

your one click model unfolder

PyPI

from model_unfolder import unfold
unfold("meta-llama/Meta-Llama-3-8B")

Meta-Llama-3-8B architecture diagram


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, Kimi K2
Llama Llama 3 / 3.1 / 3.2 / 3.3
Mistral Mistral 7B, Mixtral 8x7B / 8x22B, Mistral Medium 3.5
Qwen Qwen2 / 2.5, Qwen2-MoE, Qwen3, Qwen3-MoE, Qwen3.5 / 3.6
Gemma Gemma 3 / 3n, Gemma 4 (31B, E2B, E4B)
MiniMax MiniMax-Text-01

Diffusors

Coming soon.

Custom

Drop a request in issues.

License

Apache 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_unfolder-0.2.5.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

model_unfolder-0.2.5-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file model_unfolder-0.2.5.tar.gz.

File metadata

  • Download URL: model_unfolder-0.2.5.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for model_unfolder-0.2.5.tar.gz
Algorithm Hash digest
SHA256 8f8321fa1ce51cf61ebdd3e67a7a30727a0ab82631fe21e1ba2369d8b5c72e04
MD5 57b5bd19ef7976870704f2fede341736
BLAKE2b-256 c7aaa821e8796efd8118754f313b4c14d51bc9a3a05b37778beb02060f581f98

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_unfolder-0.2.5.tar.gz:

Publisher: release.yml on SoumilB7/unfold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file model_unfolder-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: model_unfolder-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 67.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for model_unfolder-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0569c85e298fcb514f3934e6de5fdebd60c0f2c2db89fa6f35a54fe1b9c173e2
MD5 c6e11c449c2c833a71f6e34ac254e6c7
BLAKE2b-256 f23e210c739df94cfac8d9a38b4d56056f8466fe72e709a7ba9956ceb8b56833

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_unfolder-0.2.5-py3-none-any.whl:

Publisher: release.yml on SoumilB7/unfold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page