# bobofamily > Bilingual technical notes and essays by Niu Chun (牛群). 中英双语技术笔记与随笔。 Technical notes cover neural networks, language models, tokenization, and software engineering. Essays are separate personal writing. The linked HTML articles contain their readable text without requiring JavaScript. Figures and interactive demonstrations supplement that text. English uses the root path; Chinese uses /zh/. A language link below is included only when that version exists. Publication and revision dates belong to each article version. ## Site navigation - [About the author](https://bobofamily.space/about/) - [关于作者](https://bobofamily.space/zh/about/) - [Technical notes](https://bobofamily.space/notes/) - [技术笔记](https://bobofamily.space/zh/notes/) - [Essays](https://bobofamily.space/posts/) - [随笔](https://bobofamily.space/zh/posts/) ## Series in English - [Learning AI with AI](https://bobofamily.space/series/learn-ai-with-ai/): 44 articles in reading order. ## Recent articles (English) - [Where History Lives: Sliding Windows, Linear States, Gates and MLA](https://bobofamily.space/notes/hybrid-attention-and-state/): Follow seven numerical diagrams through global, sliding-window and linear attention, fixed-state reads and writes, Gated DeltaNet gradients, output gating, GQA/MLA caches and hybrid layer layouts. - [How a Token Selects Its Experts: Top-2 Routing, Shared Experts, and Load Balancing](https://bobofamily.space/notes/moe-routing-and-balance/): Follow three original figures from dense SwiGLU to Top-2 mixing and a shared expert, then use eight tokens to derive the balancing loss, softmax gradients, and a router weight update. - [One New Token, All the History: How a KV Cache Reuses Each Layer's Results](https://bobofamily.space/notes/kv-cache/): Compare full-prefix recomputation with cached decoding: prefill, unchanged historical K/V, per-layer storage, RoPE offsets, rectangular masks, and the separate costs of generation and caching. - [Architecture Companion · One Input, Two Projections: SiLU and SwiGLU](https://bobofamily.space/notes/silu-and-swiglu/): Separate an elementwise activation from a two-branch structure. Calculate SwiGLU from input projections through gating and output projection, then compare shapes, parameters, gradients, and residual connections with a GELU MLP. - [Math Catch-Up · Same Length, Different Dot Product: Rotation and RoPE](https://bobofamily.space/notes/rotation-and-rope/): Derive planar rotation from two basis vectors, then apply it to Q/K feature pairs. Work through angles, rotated coordinates, relative positions, and multiple frequencies with original worked diagrams. - [One Forward Route: Reading Llama 3 Through GPT-2](https://bobofamily.space/notes/gpt2-to-llama3-forward/): Place LayerNorm and RMSNorm, QKV head splitting, MHA and GQA, residual paths, SwiGLU, and vocabulary projection on one network map. Follow shapes and worked examples with original diagrams and step-by-step calculations. - [Inside One Training Update: Compilation, FlashAttention and AdamW](https://bobofamily.space/notes/gpt-execution-and-optimization/): Connect torch.compile, FlashAttention and vocabulary padding to one training update. Derive AdamW's bias correction, then follow four microbatches through gradient accumulation, global clipping, warmup and cosine decay, with bilingual diagrams and interactive walkthroughs. - [One GPT, Two Complete Paths: Training Updates and Token-by-Token Generation](https://bobofamily.space/notes/gpt-training-and-inference/): Follow Hi 你! through position embeddings, LN and QKV, two residual additions, the MLP, vocabulary logits, cross-entropy and AdamW, then trace fixed-parameter generation and incremental decoding. Three diagrams and two interactive walkthroughs distinguish parameters, activations, gradients and context. ## 中文系列 - [跟着 AI 学 AI](https://bobofamily.space/zh/series/learn-ai-with-ai/): 44 articles in reading order. ## 最近文章(中文) - [历史保留在哪里:从滑动窗口、线性状态到门控与 MLA](https://bobofamily.space/zh/notes/hybrid-attention-and-state/): 沿七张数值图对照全局、滑动窗口和线性注意力,推导固定状态的写入与读取,再展开 Gated DeltaNet 的门与梯度、输出门控,以及 GQA/MLA 的缓存和混合布局。 - [一个 Token 怎样选专家?从 Top-2 路由、共享专家到负载均衡](https://bobofamily.space/zh/notes/moe-routing-and-balance/): 沿三张原图,从稠密 SwiGLU 对照到 Top-2 专家混合,再接入共享专家;用八个 Token 手算负载均衡损失、softmax 梯度与路由矩阵更新。 - [只输入一个新 Token,怎样仍然读到全部历史:KV Cache 的逐层复用](https://bobofamily.space/zh/notes/kv-cache/): 沿完整前缀重算与缓存路径对照,解释 prefill/decode、历史 K/V 不变的原因、逐层缓存、RoPE 偏移与矩形遮罩,并算清生成长度和缓存成本。 - [结构补充 · 同一个输入,两路投影:SiLU 与 SwiGLU 的门控计算](https://bobofamily.space/zh/notes/silu-and-swiglu/): 区分逐元素激活与双分支结构。从 SiLU 数值、两套投影到门控乘法、输出投影和残差,完整手算 SwiGLU,并对照 GELU MLP 的形状与参数成本。 - [数学补课 · 长度没变,点积变了:二维旋转如何接入 RoPE](https://bobofamily.space/zh/notes/rotation-and-rope/): 从单位圆和两个基向量推导旋转矩阵,再把它用于 Q/K 的维度对。逐项计算角度、旋转输出与点积,解释相对位置、多频率及它们各自的边界。 - [沿同一条前向路线:从 GPT-2 看懂 Llama 3 的结构变化](https://bobofamily.space/zh/notes/gpt2-to-llama3-forward/): 把 LayerNorm 与 RMSNorm、QKV 拆头、MHA 与 GQA、两次残差、SwiGLU 和输出层放回同一张网络图。用输入形状、完整数值与原始配图,追踪每一步读取什么、计算什么、留下什么。 - [一次训练更新里发生了什么:编译、FlashAttention 与 AdamW](https://bobofamily.space/zh/notes/gpt-execution-and-optimization/): 把 torch.compile、FlashAttention、词表尺寸对齐接到同一次训练更新上:先看计算怎样执行,再推导 AdamW 的偏差修正,最后用四轮梯度累积串起裁剪、学习率预热与余弦衰减。附双语图解和逐步交互。 - [同一套 GPT,两条完整路线:训练更新与逐 Token 生成](https://bobofamily.space/zh/notes/gpt-training-and-inference/): 沿 Hi 你! 串起 GPT 的完整计算:位置向量、LN 与 QKV、两次残差、MLP、全词表 logits、交叉熵和 AdamW,再看固定参数怎样逐 Token 生成与增量解码。用三张双语图解、两份分步动画区分参数、激活、梯度与生成上下文。 ## Optional - [Complete sitemap index](https://bobofamily.space/sitemap-index.xml) - [All published article versions](https://bobofamily.space/sitemap-articles.xml) - [English RSS](https://bobofamily.space/rss.xml) - [中文 RSS](https://bobofamily.space/zh/rss.xml)