Sudharsanselvaraj/Token-Print
À propos
Interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
IA et apprentissage automatiqueWhat you can do
- Architecture - Every layer, parameter and tensor of the loaded model, from the real named_parameters() list.
- Generation - Token-by-token decoding over WebSocket with the real top-k distribution and per-layer activation stats.
- Walkthrough - A guided tour: tokenization, embedding, RMSNorm, self-attention, MLP, softmax and output.
- Debugger - Breakpoints, ablation, activation patching, logit lens and the induction-head lab.
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +4
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
Original
Watch your model think.
An open-source 3D visual debugger for transformers: run a real forward pass and inspect attention, RoPE, the KV cache and the residual stream as they happen.
Live demo · Quick start · Features · Hosted on Hugging Face · Docs · Wiki · Roadmap · Discord
BUILT WITH
Why TokenPrint
Architecture diagrams show you a transformer. TokenPrint runs one and lets you look inside. Load a real model, run a real forward pass, and watch attention, RoPE, the KV cache and the residual stream as they happen.
- Every number is real. No
Math.random, no placeholder tensors. Each value traces tonamed_parameters(), a real forward pass, or the GGUF header, and CI fails if fake data reaches app code. Values are taggedREAL,DERIVED,CONCEPTUALorSIMULATION. - A debugger, not a viewer. Breakpoints, watch expressions, activation ablation with before/after diff, logit lens, induction-head lab, and trace record, replay and branching.
- Grouped-query attention you can see. Qwen2.5-0.5B's 14 query heads and 2 KV groups render as geometry clustered exactly that way.
- Cited, not hand-waved. Click RoPE, SwiGLU, RMSNorm, GQA or an induction-head pair and get the primary source.
- Private by default. GGUF files are parsed client-side. Nothing is uploaded.
What you can inspect
| View | What it shows |
|---|---|
| Architecture | Every layer, parameter and tensor of the loaded model, from the real named_parameters() list. |
| Generation | Token-by-token decoding over WebSocket with the real top-k distribution and per-layer activation stats. |
| Walkthrough | A guided tour: tokenization, embedding, RMSNorm, self-attention, MLP, softmax and output. |
| Debugger | Breakpoints, ablation, activation patching, logit lens and the induction-head lab. |
How it works
flowchart LR
U["Prompt"] --> B["FastAPI backend<br/>PyTorch + forward hooks"]
B -->|"one WebSocket frame per token"| F["Next.js frontend"]
F --> R["React Three Fiber<br/>3D renderer"]
B --> T["Trace recorder<br/>record, replay, diff"]
Supported models
Qwen 2.5 runs live by default. Llama 2/3/3.2, Gemma, Mistral/Mixtral, DeepSeek (including MoE), Phi and GPT-2/Pythia load as GGUF, and any local .gguf works. GPT-2 also runs fully in the browser. Per-family notes are in the wiki; to add one, see the developer guide.
Three ways to run
| Mode | Runtime | What you get | Best for |
|---|---|---|---|
| Python backend | PyTorch + Transformers (CUDA, Apple MPS or CPU) | Full instrumentation: attention, hidden states, ablation, patching | Real debugging |
| Quantized GGUF | llama.cpp via llama-cpp-python |
Real quantized token probabilities and KV-cache accounting | Inspecting quantized weights |
| In the browser | GPT-2 on WebGPU + ONNX Runtime | Fully client-side, greedy decoding, desktop only | Zero-install demos |
Quick start
Requires Python 3.11 or 3.12 and Node 20.9+.
git clone https://github.com/Sudharsanselvaraj/Token-Print.git
cd Token-Print
python3 scripts/start.py
The launcher installs dependencies, downloads Qwen2.5-0.5B-Instruct with progress, starts the backend and frontend, and waits until the model is ready. Then open http://localhost:3000.
No GPU or no time? Choose Try a recorded demo on the home page to replay a real trace offline. Stuck on setup? See local setup and troubleshooting or ask in the Discord.
Manual setup
# backend (Apple MPS, CUDA or CPU fallback)
cd backend && python3 -m venv .venv --system-site-packages
source .venv/bin/activate && pip install -r requirements.txt
python -m uvicorn app.main:app --app-dir . --port 8000
# frontend
cd frontend && npm install && npm run dev # http://localhost:3000
For quantized GGUF execution: pip install -r backend/requirements-gguf.txt. To force CPU: TOKENPRINT_DEVICE=cpu.
Hosted deployment: Hugging Face Spaces + ZeroGPU
The public site at tokenprint.in is a static Next.js export on GitHub Pages. It talks to a FastAPI backend running as a Hugging Face Space with ZeroGPU.
flowchart LR
B["Browser<br/>tokenprint.in<br/>(GitHub Pages)"] -->|"HTTPS + WSS"| P["Hugging Face<br/>edge proxy"]
P --> S["Space: Gradio ASGI wrapper<br/>+ TokenPrint FastAPI routes"]
S -->|"@spaces.GPU slice"| G["ZeroGPU<br/>CUDA forward pass"]
S -->|"quota or CUDA error"| C["CPU fallback<br/>same model, same API"]
G --> M["Qwen2.5-0.5B-Instruct"]
C --> M
| Topic | Behavior |
|---|---|
| Default model | Qwen/Qwen2.5-0.5B-Instruct, loaded once at startup. |
| GPU path | Forward-pass, debug, ablation, patching and generation run inside @spaces.GPU slices (60 s). |
| Quota | ZeroGPU has a daily per-user quota. When it is exhausted, or CUDA fails, the request falls back to CPU instead of erroring. Results are the same, only slower. |
| Cold starts | A sleeping Space takes roughly 10 to 25 seconds to wake. |
| GGUF | Quantized generation is a local feature: the hosted Space does not ship llama-cpp-python. GGUF files are still parsed in your browser. |
| Storage | The Space disk is ephemeral. Files placed in data/gguf are lost on restart. |
| Models | Only the default model is served. The compatibility registry (GET /api/model/compatibility) lists what each other checkpoint has and has not been tested for. |
Point your own frontend at any backend with NEXT_PUBLIC_API_URL. Full details: Hugging Face deployment guide, limitations, post-deployment verification.
Why you can trust the numbers
GET /architecturereports 494,032,768 parameters on live Qwen, the exact sum of all 290 real tensors.- The op catalog lists 219 ops in true forward order, matching the actual module graph.
- Five independent verification scripts and a CI regression gate back this up: docs/verification.md.
Known limits, stated plainly:
- Quantized GGUF inference is real, but
llama.cppexposes no per-layer activations, so layer lighting is disabled there instead of faked. - Attention weight is not causal proof. It is a signal, not evidence the model needed that token (details).
- Per-layer timings are unsynchronized wall-clock on MPS and CUDA, and are badged
PROXY · NOT MSwhen unbacked. - Browser inference currently covers GPT-2 on desktop WebGPU with greedy decoding.
If you find a wrong number, that is a top-priority bug.
Repository layout
backend/ FastAPI service: model engine, adapters, GGUF engine, tracing, tests
frontend/ Next.js + React Three Fiber app, unit and visual-regression tests
docs/ Architecture, API, deployment, verification, visual mapping
wiki/ User guide, transformer concepts, developer guide
scripts/ Launcher, trace tools, demo generation
fixtures/ Reference traces and tiny test models
deploy/ Self-hosting scripts
Documentation
Architecture · API reference · Visual mapping · GGUF format · Browser inference · Experiments · Development · Deployment · Roadmap
Community
Join the TokenPrint community on Discord
Questions · Bug reports · Shared traces · Feature ideas · Show and tellContributing
First-timers are welcome. Pick a task from GOOD_FIRST_ISSUES.md or the open issues, read CONTRIBUTING.md, and open a PR. Working examples to copy from are in docs/contributor-examples.md.
The one rule for every change: every number shown must be real.
Every person who has contributed to Token-Print. Thank you.
License
MIT © Sudharsan Selvaraj. If TokenPrint helps you, you can support the project.
Explorer des projets similaires
Chargement…