An interactive, visual deep-dive into the inner workings of Large Language Models. This simulator visualizes the entire Transformer pipeline—from raw tokenization to the final softmax decision—using a configurable, state-driven simulation engine.
The application breaks down the complex inference process into six manageable, interactive phases:
- Phase 0: Tokenization – See how raw text is split into semantic tokens and mapped to an index.
- Phase 1: Embedding & Position – Visualize how tokens are converted into high-dimensional vectors and mixed with positional information.
- Phase 2: Attention Mechanism – Explore the core of the Transformer. Toggle between Orbit and Matrix views to see how tokens "attend" to each other across multiple heads.
- Phase 3: FFN (Feed Forward Network) – Watch the vector transformation and activation within the semantic MLP layer.
- Phase 4: Decoding & Softmax – Manipulate Temperature, Top-K, and Min-P. Experience the Gumbel-Max Trick where token rankings shift dynamically with higher temperature.
- Phase 5: Final Analysis – Review the semantic output and the "winning" token path.
- Multi-View Attention: Switch between a spatial Orbit view and a precise Grid Matrix view.
- Gumbel-Max Dynamic Decoding: Realistic temperature scaling that doesn't just flatten probabilities but actually allows for creative "ranking shifts."
- Configurable Scenarios: Entirely data-driven logic. Add new behaviors, tokens, and attention rules via
scenarios.json. - Persisted UI State: Your view modes, selected heads, and active tokens are remembered during your session.
- Global Synchronized Reset: Reset the entire mathematical state without losing your visual configuration.
- Core: React 18, Vite
- Logic: Custom
LLMEngineclass for pure mathematical simulation - Styling: Vanilla CSS with a centralized semantic variable system for high performance and clean aesthetics.
- State Management: React Hooks & Context API for global scenario orchestration.
- Clone the repository
- Install dependencies:
npm install
- Run the development server:
npm run dev
- Open in browser:
http://localhost:5173
The simulator is powered by a JSON-based domain model located in public/data/scenarios.json. Developers can define:
base_vectorcoordinates for embeddings.attention_profileswith specific token-to-token rules per head.top_k_tokenswithbase_logitandnoise_sensitivityvalues.
Developed for educational exploration of Transformer architectures.