About NanoGPT Attention Lens — Transformer Visualizer
NanoGPT Attention Lens is an interactive zero-dependency Transformer self-attention and Q/K/V tensor interpretability sandbox packed into a single HTML file.
Type custom prompts or switch between coreference resolution, code syntax, and bilingual presets to inspect how four specialized causal attention heads route context across tokens.
It renders real-time multi-head Bezier attention arcs, a scaled dot-product causal attention matrix heatmap, 16-dimensional Q/K/V embedding activation bars, and next-token probability distributions.
Users can dynamically tune Temperature (τ) and Top-P nucleus sampling thresholds, step through autoregressive token generation, and export 2x high-resolution PNG snapshots.
All tensor projections, softmax normalizations, and Canvas 2D visualizations execute 100% locally inside OneHTML's isolated zero-trust sandbox with zero external scripts.
NanoGPT Attention Lens(注意力机制实时透视沙盒)是一款纯单文件零外部依赖的 Transformer 多头因果自注意力(Multi-Head Self-Attention)可视化实验作品。
支持自由输入中英文或代码短句,也可一键切换指代消解(如 it 指向 trophy)、代码语法绑定等经典预设,直观透视 4 个专职注意力头的上下文路由机制。
同屏实时渲染多头贝塞尔注意力权重连线束、缩放点积因果注意力热力图(A = softmax(QKᵀ/√dₖ))、16 维 Q/K/V 隐空间投影激活条以及 Next-Token 预测概率分布。
支持滑动调节采样温度(Temperature)与 Top-P 核采样截断阈值,提供单步自回归采样生成下一词(Sample Next Token)与一键导出高清 PNG 透视图功能。
所有张量投影、因果掩码 Softmax 计算与高帧率 Canvas 2D 脉冲渲染均在 OneHTML 双域隔离沙盒内 100% 本地运行,无任何外部依赖。
Key Highlights
- 4-Head Causal Self-Attention Routing Arcs & Scaled Dot-Product Heatmap
- Live d_k=16 Q/K/V Embedding Projections & Autoregressive Next-Token Sampler
- Interactive Temperature (τ) & Top-P Nucleus Filtering with HD PNG Export
- 4 头因果自注意力贝塞尔连线束与缩放点积注意力热力图实时联动
- 16 维 Q/K/V 隐空间向量通道透视与单步自回归 Next-Token 采样推演
- 支持 Temperature 温度与 Top-P 核采样动态调节及一键导出高清 PNG







Be the first to leave a little thought.