Repository navigation
Supported Models HuggingFace
HuggingFace is the primary hub for open-source AI models. TokenPrint's backend uses the transformers library to download, load, and execute models hosted on HuggingFace.
To provide real-time Live Inference and capture intermediate layer statistics (like attention weights and hidden states), TokenPrint must execute a real forward pass. PyTorch and the HuggingFace transformers library are the gold standards for accessing these internal states during execution.
In backend/app/model.py, TokenPrint initializes the ModelEngine.
By default, it loads Qwen/Qwen2.5-0.5B-Instruct.
It enforces a specific flag: attn_implementation="eager".
This is critical. Modern PyTorch often defaults to FlashAttention or SDPA (Scaled Dot Product Attention) to speed up inference. However, these optimized kernels fuse operations and do not return the attention probability matrices. TokenPrint forces eager execution so it can extract the real [layer][head][from][to] attention tensors to render in the UI.
To load a different HuggingFace model:
- Stop the backend server.
- Edit the
MODEL_NAMEvariable inbackend/app/model.py. - Restart the server.
Warning TokenPrint loads models in
float32by default to ensure maximum precision of the extracted activations. Loading a 7B or 8B model will require significant RAM/VRAM. The default 0.5B model was chosen so anyone can run it locally on a standard laptop.
flowchart TD
HF[HuggingFace Hub] -->|Download Weights| Cache[Local HF Cache]
Cache --> Engine[ModelEngine (PyTorch)]
subgraph Execution Parameters
Engine --> Eager[attn_implementation="eager"]
Engine --> FP32[torch_dtype=float32]
end
Eager --> Output[Real Attention Tensors]
| Previous | Home | Next |
|---|---|---|
| GGUF | Home | Llama |
TokenPrint Wiki | Home | Getting Started | User Guide | Concepts | Architecture | API | GitHub
TokenPrint is an interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
- User Guide
- Architecture Explorer
- Live Inference
- Tensor Inspector
- Camera Controls
- HUD
- Timeline
- Scene Navigation
- Transformer Concepts
- Tokenization
- Embeddings
- Positional Encoding
- RoPE
- Multi-Head Attention
- KV Cache
- LayerNorm
- Feed Forward Network
- Residual Connections
- Logits
- Softmax
- Sampling
- Autoregressive Generation
- Visualization System
- Scene Graph
- Geometry
- Materials
- Animation System
- Color Mapping
- Camera System
- Interaction Model
- Architecture
- Overall Architecture
- Frontend
- Backend
- WebSocket Protocol
- Data Pipeline
- Renderer
- Event System