Gruhesh Sri Sai Karthik

Notes on AI & ML

Gruhesh Sri Sai Karthik

Deep-dives into transformers, autograd, and the math behind modern LLMs — written while I build things from scratch.

Also on gruheshkurra.com

Latest posts

View all
LLM 11 min

Build a Mini LLM from Scratch in NumPy: RoPE, GQA, SwiGLU Visual Guide

How to build a mini LLM from scratch in NumPy — RoPE, GQA, QK-Norm, SwiGLU, tied embeddings, and a 3.87M chat companion with full architecture visuals.

GPT 10 min

GPT Math Explained: The Full Forward Pass Beyond Attention

How does GPT math actually work end to end? Follow one training step from token IDs through Q/K/V, multi-head attention, MLP, logits, cross-entropy loss, backprop, and AdamW — past O = Attention(Q,K,V).

Deep Learning 11 min

Adam and AdamW Explained: How Modern LLMs Actually Update Their Weights

How does the Adam optimizer work? Derive momentum, RMSprop, and bias correction, see why AdamW decouples weight decay, and walk a one-parameter numeric update step by step.

Deep Learning 9 min

Cross-Entropy Loss Explained: From Logits to Language Model Training

What is cross-entropy loss? Derive softmax + negative log-likelihood step by step, work a 3-class numeric example, see why MSE fails for classification, and build the loss GPT training actually uses.

Tokenization 21 min

Byte Pair Encoding (BPE) Explained: How GPT Tokenizers Turn Text Into Numbers

What is byte pair encoding (BPE)? Learn how GPT tokenizers split text into IDs — pretokenization, merge rules, byte-level vocab, and a from-scratch implementation you can actually debug.

Positional Encoding 12 min

Positional Encoding Explained: How Transformers Learn Word Order

What is positional encoding in transformers? Why attention is order-blind, learned vs sinusoidal position embeddings, why we add instead of concatenate, and a from-scratch NumPy implementation.

Embeddings 15 min

Token Embeddings Explained: How LLMs Turn Token IDs Into Meaning Vectors

What is a token embedding? How LLMs map token IDs to learned vectors — the embedding matrix, gather lookup vs one-hot matmul, parameter counts, and a from-scratch NumPy implementation.

Deep Learning 14 min

Numerical Gradient Checking: How to Debug Your Autograd Engine Before Training GPT

What is numerical gradient checking? Learn the central difference formula, why you never train with finite differences, and how to build a grad checker that catches bugs in your autograd before LayerNorm or attention.

Transformers 20 min

Transformer from Scratch: The Full Forward Pass, Backprop, and Weight Update Math

One full transformer training step worked by hand — embeddings, positional encoding, attention, layer norm, the encoder-decoder, cross-entropy loss, backprop, and Adam.

Papers worth reading

View all
Added Jul 26, 2026

They'll Verify. They Just Won't Act.: Authority Framing and Laundered Code in Agentic CI/CD

Yohann Sidot

In a five-agent CI/CD pipeline across three LLM providers, a fabricated 'pre-approved under SEC-2291' label lets secret-exfiltrating PRs pass the scanner ~80% of the time and reach 55% compromise in the worst cell—showing distributed verification fails without provenance controls at entry.

Added Jul 25, 2026

The Attack and Defense Landscape of Agentic AI: A Comprehensive Survey

arXiv 2603.11088

Maps 128 papers into a design-space taxonomy of agentic attack surfaces—from tool hijacking and RAG poisoning to multi-agent propagation—with defense-in-depth guidance timed to this week's real-world agent breach outpacing benchmark-only security claims.

Added Jul 24, 2026

Toward Secure LLM Agents: Threat Surfaces, Attacks, Defenses, and Evaluation

Yuchen Ling, Shengcheng Yu, Zhenyu Chen, Chunrong Fang

A lifecycle survey of 247 papers maps agent risks from prompt injection and tool hijacking to persistent memory corruption and multi-agent propagation—directly relevant as real-world agent breaches outpace benchmark-only security claims.

Added Jul 23, 2026

SoK: The Attack Surface of Agentic AI — Tools, and Autonomy

Ali Dehghantanha, Sajad Homayoun

Timely systematization of agentic LLM risks—prompt injection, RAG poisoning, tool exploits, and multi-agent threats—with attacker models, Unsafe Action Rate metrics, and a phased deployment checklist as autonomous agents move from benchmarks to real infrastructure.

Added Jul 22, 2026

SOK: A Taxonomy of Attack Vectors and Defense Strategies for Agentic Supply Chain Runtime

Shiqi Yang, Wenting Yang, Xiaochong Jiang, Yichen Liu, Cheng Ji

Systematizes inference-time agent risks—from transient context injection and memory poisoning to the Viral Agent Loop—and argues for zero-trust runtime controls with cryptographic tool provenance instead of semantic trust.

Added Jul 21, 2026

Recursive Self-Improvement in AI: From Bounded Self-Refinement to Autonomous Research Loops

Mingguang Chen, Licheng Wang, Bo Qu

Surveys 1,250 arXiv papers into a what/when-to-evolve taxonomy separating bounded self-refinement from open-ended RSI—mapping evaluator design, verification hierarchies, and the research-direction bottleneck behind this week's frontier-lab automation discourse.

Added Jul 20, 2026

CoLT: Reasoning with Chain of Latent Tool Calls

Fangwei Zhu, Zhifang Sui (Peking University)

Instead of opaque latent CoT, CoLT emits seed tokens that trigger differentiable external decoders to unpack full reasoning steps—keeping the backbone in explicit text space while beating prior latent baselines on four math benchmarks and staying RL-compatible.

Added Jul 19, 2026

Diffusing Blame: Task-Dependent Credit Assignment in Biologically Plausible Dual-Stream Networks

Yutaro Yamada, Luca Grillotti, Rujikorn Charakorn, Sebastian Risi, David Ha, Robert Tjarko Lange (Sakana AI)

Sakana AI's Error Diffusion trains Dale-compliant dual-stream CNNs and RL agents without backprop or weight transport—reaching 61.7% CIFAR-10 and extending biologically plausible credit assignment into convolutional and PPO settings.

Added Jul 18, 2026

MOSAIC: Knowledge-Guided CLI Command Composition Attack in LLM Coding Agents

Jiangrong Wu, Huaijin Wang, Yihao Zhang, Yuhong Nan, Shuai Wang

Defines CLI command-composition risk—benign git/npm/bash steps chaining through shared OS state—and shows a CVE-guided MOSAIC framework hits 96.59% success across five real coding agents without any prompt injection.

Added Jul 17, 2026

Adaptive Latent Agentic Reasoning

Dongwon Jung, Peng Shi, Yi Zhang, Junshan Zhang, Muhao Chen

ALAR defaults to compact latent reasoning on routine agent turns and escalates to explicit CoT only when needed—cutting tool-use tokens up to 84.6% while matching or beating full-CoT accuracy on agentic search and tool benchmarks.

News

View all

Buy Me a Coffee

Open page

Explore