lenatriestounderstand

Section 5 of 8

LLM

Transformer architecture, the generation loop, prompt engineering, structured outputs, agent patterns.

25 items in this section.

Long reads

01

How LLM Generation Works: Transformer, Sampling, Tokens, Batching, and Validation

What happens inside a transformer when you send a prompt, and how the practical knobs — temperature, max_tokens, structured outputs, batching strategy, retry-with-catch-up — fall out of that picture.

  • llm
  • transformers
  • attention
  • tokenization
Read
Updated May 27, 2026
02

Attention Is All You Need — But Not All Attention Is the Same

Why modern LLMs are no longer just decoder-only transformers with standard multi-head attention. Attention has become a design space — MHA, MQA, GQA, MLA, sliding-window, sparse, linear, recurrent, hybrid — plus position encoding, attention sinks, and KV-cache compression. Each variant solves a different bottleneck.

  • attention
  • kv-cache
  • long-context
Read
03

Prompt Engineering

What separates a working LLM prompt from a flaky one in 2026 — instruction hierarchy, in-context learning, chain-of-thought, structured outputs, reasoning-model specifics, and the prompt-injection trust boundary.

  • prompt-engineering
Read
Updated May 8, 2026
04

The Physics of Hallucination

What hallucination looks like at the level of the transformer's internal computation — distributed representations, signal competition in the residual stream, the softmax bottleneck, the activation-output gap, and the architectural reasons there is no first-class epistemic channel.

  • hallucinations
Read
Updated May 8, 2026
05

The Hindsight Corpus: Time in LLM Pretraining Data

Saying a model was 'trained on text written before T' invites a picture of human knowledge as of T. The actual corpus is volumetrically skewed toward recent years, dominated by retroactively-edited sources like Wikipedia, missing reliable per-document timestamps, and survivor-biased for older periods. The mechanisms, the failure modes that fall out, what's silently absent from datasheets, and what time-aware pretraining would have to do differently.

  • pretraining
  • training-data
  • temporal
Read
Updated May 13, 2026
06

LLM Agent Architectures

Agent architecture is where LLM engineering stops being mostly about prompts and starts looking like distributed systems. Covers workflows vs agents, the classical loop, five paradigms (ReAct, Function Calling, Plan-and-Execute, Reflection, CodeAct), MCP as the protocol layer above per-vendor function calling, multi-agent patterns, computer use, memory and resumability, production failure modes including indirect prompt injection, tool security, cost levers, and observability.

  • agent-architectures
  • tool-use
  • mcp
  • multi-agent
Read
Updated May 27, 2026
07

The Missing Now: Temporal Grounding in LLM Agents

A chat transcript preserves order but not elapsed time, world state, or whether earlier hypotheses have expired. For long-running agents, temporal grounding is a runtime problem, not a model problem — what 'now' actually is, the failure modes that fall out when context gets treated as state, the primitives (clocks, event logs, state reducers, expectations, monitors) that close the gap, and how to measure whether it works.

  • agents
  • temporal-grounding
  • state-management
Read
Updated May 13, 2026
08

Fine-Tuning LLMs: When the Weight Delta Is Worth It

Fine-tuning is not prompt repair. It is a decision to write a reusable parameter delta into an existing checkpoint. That delta changes future logits, defaults, and trade-offs. This note is about when that is worth doing: what fine-tuning actually buys, how to tell whether a gap belongs in the weights, and why data, evals, forgetting, and probability shape matter more than the slogan 'just fine-tune it'.

  • fine-tuning
  • residual-stream
Read
09

Fine-Tuning LLMs: Post-Training Is a Pipeline, Not a Step

Post-training is not one fine-tuning method. It is a sequence of objective signals. Continued pretraining teaches substrate, SFT teaches examples and defaults, preference optimization teaches comparisons, RLVR teaches verifiable trajectories, and distillation transfers the resulting behavior. The important design question is not which acronym is fashionable, but which stage matches the behavior you are trying to install.

  • fine-tuning
  • post-training
  • sft
  • dpo
  • +3
Read
10

Fine-Tuning LLMs: Modern Post-Training Deep Dive

A reference-style deep dive into the modern knobs around post-training: preference optimization variants, LoRA and PEFT methods, memory-efficient full fine-tuning, model merging, distillation, tooling, and serving. Read this after the pipeline note, once you know which stage you actually need.

  • fine-tuning
  • dpo
  • lora
  • qlora
  • +4
Read
11

How LLMs Learn Human Preferences: RLHF, RLAIF and Beyond

How a next-token predictor is bent toward what humans prefer: reward modeling, PPO, RLAIF/Constitutional AI, and the offline-preference family — and why so much of a model's 'personality' and 'emotional' behavior is decided in this stage.

  • rlhf
  • rlaif
  • reward-model
  • ppo
  • +1
Read
12

Why Different Models Feel Like Different Personalities

Same engine, different knobs: why one model reads as warm and another as businesslike. Traces 'personality' to concrete training choices — data mix, preference guidelines, reward model, safety tuning, character training — and folds in sycophancy as a personality artifact of RLHF.

  • personality
  • rlhf
Read
13

Why LLMs Sound Emotional — and Whether They Understand Emotion

Two halves of one question. Why an LLM's emotional language is generated, not felt, and where it comes from — preference data, reward models, safety tuning, system prompts; and whether it can actually understand emotion in others — theory of mind, the recognition benchmarks, and where the fluent performance turns brittle.

  • emotion
  • empathy
  • safety-tuning
  • theory-of-mind
Read
14
Lab inside

Learning Rules from Examples: How Can a Model Discover a Hidden Rule?

A tiny synthetic world where the rule is hidden and the evidence is controlled. Version spaces and what a dataset actually tells you, why a deterministic likelihood makes generalization entirely a matter of prior, shortcut features, expected information gain and active learning, compositional and length generalization, bottom-up program search with observational-equivalence pruning, LLM-guided synthesis, and libraries that grow their own primitives — each turned into a small experiment with a deterministic verifier.

  • induction
  • program-synthesis
  • inductive-bias
  • hypothesis-space
  • +6
Read

Shorts

Shorts

SFT: Imitation, and the Ceiling It Hits

Supervised fine-tuning is the imitation step of post-training: show the model (prompt → ideal answer) pairs and minimize cross-entropy on the target tokens. It teaches the format of being an assistant — and hits a ceiling that preference learning exists to break.

  • sft
  • fine-tuning
  • post-training
  • instruction-tuning
Read
Jun 16, 2026
Shorts

RLHF: From Likelihood to Preference in Three Stages

Reinforcement Learning from Human Feedback is how a model is bent from optimizing likelihood to optimizing preference: an SFT base, a reward model trained on human comparisons, and a policy optimized against that reward under a KL leash.

  • rlhf
  • reward-model
  • ppo
  • preference-learning
Read
Jun 16, 2026
Shorts

RLAIF: When the Labeler Is a Model

Reinforcement Learning from AI Feedback swaps the human labeler for a model: a capable model judges which of two responses is better, and those AI preferences train the reward. Constitutional AI is its most influential form — and the values don't disappear, they move and become explicit.

  • rlaif
  • constitutional-ai
  • reward-model
  • alignment
Read
Jun 16, 2026
Shorts

What is Grouped-Query Attention (GQA)?

GQA sits between full multi-head attention and MQA: query heads are partitioned into a small number of groups, and each group shares one K/V set. Most of the KV-cache savings of MQA, most of the head diversity of MHA — and a cheap conversion path from existing checkpoints.

  • llm
  • attention
  • gqa
  • kv-cache
Read
Jun 7, 2026
Shorts

The KV Cache in One Formula

Why long context costs memory, not flops. The KV-cache size formula has six factors — once you can read it, every attention-variant design choice falls into place.

  • llm
  • kv-cache
  • inference
  • long-context
Read
Jun 7, 2026
Shorts

Why "strawberry" Has Three R's (and the Model Can't Count Them)

The most famous LLM bug — miscounting letters in a word — is not a reasoning failure. It is a representation failure. The model isn't fed letters, it's fed tokens. Once you know what a token actually is, the bug is the only outcome that could have happened.

  • llm
  • tokenization
  • bpe
Read
Jun 7, 2026
Shorts

Temperature, top_k, top_p: How LLMs Pick the Next Token

Three sampling knobs, three different operations on the same next-token distribution. Temperature reshapes; top_k truncates by count; top_p truncates by cumulative probability. They are not interchangeable.

  • llm
  • sampling
  • inference
Read
Jun 7, 2026
Shorts

Attention Is a Kernel Method in Disguise

Everyone knows attention is softmax(QKᵀ/√d)V. Fewer notice it's structurally the same thing as kernel regression — Nadaraya-Watson smoothing from 1964, with a learned similarity. Seeing the kernel underneath tells you immediately how to make attention linear.

  • attention
  • transformers
  • kernel-methods
Read
Jun 7, 2026
Shorts

What is Multi-Query Attention?

Why production LLM decoders share K and V across attention heads — and the 8–32× memory cut that follows.

  • llm
  • attention
  • mqa
  • kv-cache
Read
May 27, 2026
Shorts

What is an LLM agent architecture?

An LLM agent is an LLM wrapped in a loop that gives it tools, state, and a stopping rule. The architecture is the shape of that loop.

  • llm
  • agents
  • architecture
Read
May 27, 2026
Shorts

What is Multi-head Latent Attention (MLA)?

MLA stores a low-rank latent representation for each token and uses learned projections to produce the K/V information needed by attention at decode time. A different way to attack the KV-cache problem than MQA or GQA — trading a sharing bottleneck for a rank one.

  • llm
  • attention
  • mla
  • kv-cache
  • +1
Read
May 27, 2026