How malleswarikosuri/transformer-forward-pass-explorer works
This is a small Streamlit dashboard for exploring a fixed-weight Transformer forward pass, not a trained language model. A user enters text and sets a temperature; the dashboard calls the core simulator, which tokenizes the prompt, builds representations, computes causal attention and feed-forward outputs, then produces next-token probabilities. The dashboard presents token IDs, numeric representations, an attention heatmap, probability rankings, and a sampled token. The core source shows the computation; README capability descriptions supplement the sampled UI excerpt.
Main entry points: app.py Results + Visualizations · transformer_core.py Tokenizer
Components 11
Dashboard
- Streamlit Dashboard
app.py - Results + Visualizations
app.py
Transformer Forward Pass
- Tokenizer
transformer_core.py - Embeddings + Position
transformer_core.py - Causal Attention
transformer_core.py - Residual + Feed Forward
transformer_core.py
Token Prediction
- Output Logits
transformer_core.py - Temperature + Softmax
transformer_core.py - Top Predictions
transformer_core.py - Token Sampling
transformer_core.py
Other components
- Prompt User
Connections 17
- Prompt User → Streamlit Dashboard: enters prompt
app.py - Streamlit Dashboard → Tokenizer: runs forward pass
app.py - Tokenizer → Embeddings + Position: maps token IDs
transformer_core.py - Embeddings + Position → Causal Attention: projects Q K V
transformer_core.py - Causal Attention → Residual + Feed Forward: provides attention output
transformer_core.py - Residual + Feed Forward → Output Logits: projects final state
transformer_core.py - Output Logits → Temperature + Softmax: applies temperature
transformer_core.py - Streamlit Dashboard → Top Predictions: requests top predictions
app.py - Streamlit Dashboard → Token Sampling: requests sampled token
app.py - Streamlit Dashboard → Results + Visualizations: renders results
app.py - Temperature + Softmax → Top Predictions: ranks probabilities
transformer_core.py - Temperature + Softmax → Token Sampling: samples token
transformer_core.py - Tokenizer → Results + Visualizations: displays token IDs
app.py - Embeddings + Position → Results + Visualizations: displays numeric vectors
app.py - Causal Attention → Results + Visualizations: plots attention weights
app.py - Top Predictions → Results + Visualizations: displays rankings
app.py - Token Sampling → Results + Visualizations: displays sampled token
app.py