Writing

Notes on what I'm learning, in my own words.

188 posts found

/AI/5 min read

Stopping speech the instant the user interrupts

Deciding to stop is only half of barge-in; the audio already on its way keeps playing. A server that pushed 3 s of speech ahead talks over the user for 3.2 s after it decides to stop. Pace the stream and flush the client and it is 280 ms; mute on the device itself and it is about 210.

  • voice-agents
  • barge-in
  • streaming

/AI/5 min read

Markov decision processes

An MDP is the mathematical frame for decisions whose effects ripple forward. In a tiny machine that earns 2 for running fast but overheats if pushed when warm, always-slow is worth 10, always-fast −4.55 — and value iteration finds the policy "fast when cool, slow when warm" worth 15.5.

  • mdp
  • reinforcement-learning
  • value-iteration

/AI/5 min read

Decision trees and random forests

A decision tree asks one yes/no question at a time, choosing each by how much purer it makes the groups: splitting 10/10 into 8/2 and 2/8 cuts Gini impurity from 0.5 to 0.32. A forest averages hundreds of deliberately different trees — 100 trees with correlation 0.3 keep only 30.7% of one tree's variance.

  • decision-trees
  • random-forests
  • ensembles

/AI/4 min read

Backchannels in voice agents

"Mm-hmm" means keep going. Over four minutes of agent speech a caller might say it 24 times; a barge-in rule that stops for any 300 ms of sound halts the agent about 15.6 times in that call. Recognising backchannels as words brings it to about 1.2 — and a good agent says them too.

  • voice-agents
  • backchannels
  • barge-in

/AI/4 min read

Jailbreaking in LLMs

A jailbreak is an input crafted to get a model to do what its training told it not to. Attackers get unlimited retries: a trick that works 2% of the time succeeds within 100 attempts 86.7% of the time. That is why defence is layered — three independent filters that each miss 10% let through 0.1%.

  • jailbreaking
  • llm-safety
  • guardrails

/AI/4 min read

Log probabilities (logprobs) in LLMs

Logprobs are the model's own probability for each token it wrote, on a log scale. Four tokens at 0.9, 0.6, 0.95 and 0.05 sum to −3.663 — a sequence probability of 2.6% — and the single −2.996 is where to look for a guess. They turn a fluent answer back into a measure of how sure the model was.

  • logprobs
  • llm
  • uncertainty

/AI/4 min read

How the context window works

The context window is everything a model can see at once — about 100,825 words, or 306 pages, at 128k tokens. Filling it costs 256 times the attention arithmetic of an 8k context and 42.9 GB of cache on a 70B model, and a 20-turn chat re-sends 105,000 tokens to hold a 10,000-token conversation.

  • context-window
  • llm
  • kv-cache

/AI/4 min read

KL divergence, step by step

KL divergence measures the extra bits you pay for using the wrong distribution. For P = [0.5, 0.3, 0.2] and Q = [0.4, 0.4, 0.2] it is 0.0365 bits one way and 0.0372 the other — not a distance — and if Q gives an outcome that P considers likely just one in a million, it jumps to 3.30.

  • kl-divergence
  • information-theory
  • cross-entropy

/AI/4 min read

Telling an interruption from a cough

While a voice agent speaks, the user's microphone picks up interruptions, coughs, "mm-hmm"s and the TV. Stop after 150 ms of sound and the agent halts for 98.3% of backchannels and 84.7% of coughs; wait 700 ms and those fall to 4.2% and 2.0% — but every real interruption takes 700 ms to obey.

  • voice-agents
  • barge-in
  • vad

/AI/4 min read

The bias-variance tradeoff

Fit 15 noisy points with a straight line and it is wrong in the same way every time (bias). Fit them with a degree-12 polynomial and it is wrong in a different way every time (variance). Across 400 simulated datasets the line scores 0.304 on new data, degree 12 scores 0.587 despite the lowest training error, and degree 3 wins at 0.116.

  • bias-variance
  • overfitting
  • underfitting

/AI/4 min read

Why weights are initialised randomly

Start every weight at the same value and every hidden neuron computes the same thing, gets the same update, and stays identical forever. A 4-neuron XOR network started at 0.5 ends 5,000 steps later with all four neurons still exactly equal and the problem unsolved; started randomly, it solves it.

  • initialisation
  • neural-networks
  • symmetry

/AI/4 min read

Optimizers: SGD, momentum, RMSProp and Adam

On a bowl 50 times steeper one way than the other, plain SGD must keep its step under 0.04 or diverge, and then crawls: 137 steps at best. Momentum gets there in 83, Adam in 80. Every popular optimizer is a fix for the same problem — one learning rate for directions that need different ones.

  • optimizers
  • adam
  • sgd

/AI/4 min read

Half-duplex vs full-duplex voice agents

A half-duplex agent takes turns: it listens, then speaks. A full-duplex one listens and speaks at once, deciding every 80 ms whether to talk. That makes overlap, backchannels and instant yielding natural — and means running the model 7,500 times in a 10-minute call instead of about 936.

  • voice-agents
  • full-duplex
  • turn-taking

/AI/4 min read

Data augmentation

Teach a model what should not matter by showing it the same example changed in ways that keep the label. Random 4-pixel shifts and a horizontal flip turn each 32×32 image into 162 variants — 8.1 million from 50,000 — but flip the wrong thing and a 6 becomes a 9.

  • data-augmentation
  • training
  • overfitting

/AI/4 min read

Why voice agents cut people off

A 5% chance of interrupting on any single turn sounds tolerable. Over a 12-turn call it means 46.0% of callers are cut off at least once; at 10% it is 71.8%. Cut-offs have half a dozen distinct causes, and each needs its own fix.

  • voice-agents
  • turn-taking
  • endpointing

/AI/4 min read

How model serving works

Serving turns a trained model into an API that answers within a deadline at an affordable price. The same $2-an-hour GPU costs $11.11 per million tokens serving one request at a time and $0.28 when batching — and pushing it from 50% to 95% busy multiplies queueing delay nineteen-fold.

  • serving
  • inference
  • batching

/AI/4 min read

Epochs, batches and iterations

50,000 examples in batches of 32 is 1,563 iterations per epoch; ten epochs is 15,630 weight updates. Batches of 512 need only 980 updates for the same ten epochs and give gradients a quarter as noisy. A large language model, by contrast, sees most of its data less than once — 3.75 million steps, under one epoch.

  • training
  • batch-size
  • epochs

/AI/4 min read

Unfinished input in voice agents

People read phone numbers in groups — 415, pause, 555, pause, 0134. If those pauses run a median 450 ms, a 500 ms endpointer cuts 66.0% of phone numbers in half and 80.1% of card numbers. Knowing how many digits are expected fixes it; a longer timer barely does.

  • voice-agents
  • endpointing
  • structured-input

/AI/4 min read

Cosine similarity

Cosine similarity compares the direction of two vectors and ignores their length: (3, 4) and (6, 8) score exactly 1. In high dimensions, unrelated vectors score near 0 — random 768-dimensional vectors land within about ±0.037 — which is what makes a score of 0.4 meaningful.

  • cosine-similarity
  • embeddings
  • vector-search

/AI/4 min read

How a vision-language model works

A VLM cuts an image into 14-pixel patches, encodes them, and feeds them to a language model as if they were words. A 336-pixel image becomes 576 tokens — about as much context as 443 words — and a minute of video at one frame a second is 34,560.

  • vlm
  • multimodal
  • vision-transformer

/AI/4 min read

Vanishing and exploding gradients

Backpropagation multiplies a gradient by one factor per layer. At 0.9 per layer, 50 layers leave 0.5% of it; at 1.1, it grows 117-fold. In a simulated 50-layer ReLU network, weights drawn slightly too small shrink the signal to 2.7 × 10⁻¹³, slightly too large grow it to 5.65 million, and He initialisation keeps it near 0.5.

  • gradients
  • deep-learning
  • initialisation

/AI/4 min read

One-hot encoding

One-hot encoding turns a category into a vector of zeros with a single 1. It makes no false claims about order or similarity — and that is also its limit: every pair of categories is equally unrelated, and a 50,000-word one-hot is 195 KB to say what a 4-byte index says.

  • one-hot
  • encoding
  • embeddings

/AI/4 min read

Logits

Logits are a model's raw scores before they become probabilities. A logit of 0 is a coin flip, 2.2 is 90% and 4.6 is 99% — every 2.3 is another factor of ten in the odds. A language model produces 128,000 of them per token, and editing them directly is how constrained decoding works.

  • logits
  • softmax
  • classification

/AI/4 min read

Long pauses in voice agents

Ask "what's your policy number?" and the caller goes looking for it. If their thinking pauses run a median 2.5 s, a 2-second ceiling interrupts 61.0% of them and even 4 seconds interrupts 27.8%. The fix is not a longer timer but recognising that the user is still holding the turn.

  • voice-agents
  • turn-taking
  • endpointing

/AI/5 min read

How a large language model works

An LLM does one thing — predict the next token — and repeats it. Learning to do that well on 15 trillion tokens takes about 6.3 × 10²⁴ operations for a 70B model, roughly 18 days on 10,000 GPUs; answering one question with what it learned takes 70 trillion.

  • llm
  • transformer
  • pretraining

/AI/4 min read

The softmax function

Softmax turns any list of scores into probabilities that sum to 1: [3, 1, 0.2] becomes [0.836, 0.113, 0.051]. Adding 100 to every score changes nothing — which is the trick that stops it overflowing, since a float16 exponential breaks above 11.09 and float32 above 88.7.

  • softmax
  • probability
  • logits

/AI/4 min read

Dynamic endpointing

A fixed 500 ms silence rule is a different rule for every speaker: it cuts off 13.7% of a quick talker's turns and 39.0% of a slow one's. Scaling the wait to each person's own pauses — 350 ms for one, 800 ms for the other — gives both the same 21.7%, and the quick talker faster replies.

  • voice-agents
  • endpointing
  • turn-detection

/AI/4 min read

Train, validation and test sets

Three slices of data, three jobs: learn, choose, and report. Skip the middle one and tune on the test set, and the best of 20 equally good models scores 91.71% on a 1,000-example test that all of them would really score 90% on — an improvement that does not exist.

  • machine-learning
  • evaluation
  • overfitting

/AI/4 min read

Activation functions

Without a bend between layers, a deep network is one linear layer in disguise. Which bend matters too: a sigmoid's slope is at most 0.25, so ten sigmoid layers can shrink a gradient by a factor of a million — 9.54 × 10⁻⁷. ReLU's slope is 1, which is most of why deep networks became trainable.

  • activation-functions
  • relu
  • sigmoid

/AI/4 min read

Silence-based vs model-based turn detection

A fixed 500 ms silence rule answers every turn after 500 ms and cuts off 21.7% of turns. A model that reads the words can answer clear endings after 150 ms and wait a full second on doubtful ones — 405 ms on average, with turns cut off 12.9% of the time. Faster and politer at once.

  • voice-agents
  • turn-detection
  • endpointing

/AI/4 min read

Endpointing in voice agents

Endpointing is a classifier that fires on every pause and must say "finished" or "still talking". Over 1,000 real endings and 3,000 mid-sentence pauses, a 300 ms silence rule is right only 67.5% of the times it fires; 1,200 ms reaches 94.2% — and makes every reply 1.2 s late.

  • voice-agents
  • endpointing
  • vad

/AI/4 min read

Hiding slow tool calls in voice agents

Three lookups at a median 600 ms each take a median 1,984 ms one after another and 948 ms in parallel; the 95th percentile drops from 3,456 ms to 1,954. Parallelism, prefetching, fillers and honest timeouts are how a voice agent stays conversational while the backend is slow.

  • voice-agents
  • tool-calls
  • latency

/AI/4 min read

The multilayer perceptron

Stack layers of neurons with a bend between them and you can approximate any reasonable function. Each ReLU adds one kink: 4 of them fit a sine wave to within 0.21, 32 to within 0.0048. Inside every transformer, an MLP holds two-thirds of each layer's parameters.

  • mlp
  • neural-networks
  • relu

/AI/4 min read

Speculative generation in voice agents

Start writing the reply when the user merely seems to have finished, and throw it away if they keep talking. Starting at 150 ms of silence instead of 500 saves 350 ms on every turn it guesses right — at the cost of about half again as many generated tokens.

  • voice-agents
  • latency
  • speculation

/AI/4 min read

Filler phrases in voice agents

"Let me check that for you" is not politeness; it is latency engineering. If a lookup takes a median 800 ms with a 2.5 s tail, a 0.6 s filler covers it 33.9% of the time, a 1.2 s filler 72.2%, and a 2 s one 90.8% — and the remaining silences are the ones users notice.

  • voice-agents
  • latency
  • fillers

/AI/4 min read

Streaming TTS

A batch TTS engine synthesises a whole sentence before you hear any of it: 7.2 s of speech at 10× real time is a 0.72 s wait. A streaming engine starts speaking after a few words — but it has to commit to intonation before it knows how the sentence ends.

  • voice-agents
  • tts
  • streaming

/AI/4 min read

Sentence chunking for TTS

Between the LLM's token stream and the voice sits a small piece of code deciding when there is enough text to speak. Waiting for a full 18-word sentence costs 0.47 s; speaking at the first comma costs 0.18 s; four words, 0.10 s — each cut trading a little naturalness for speed.

  • voice-agents
  • tts
  • streaming

/AI/4 min read

Measuring voice-to-voice latency

Voice-to-voice latency is the gap a person actually hears. A server that logs 620 ms is delivering about 800 ms over WebRTC and 1,020 ms over a phone line — and estimating the 95th percentile from 50 calls can land anywhere from 1,154 to 1,578 ms.

  • voice-agents
  • latency
  • measurement

/AI/4 min read

Time to first audio

A 60-word spoken reply lasts 24 seconds. Generating it takes 1.56 s and synthesising it 2.4 s — so a non-streaming agent stays silent for 4.21 s, while a streaming one can start talking in under one. Users judge the silence, not the total.

  • voice-agents
  • latency
  • streaming

/AI/4 min read

Matrix multiplication in neural networks

Almost all the arithmetic in a neural network is one operation: multiply a matrix of inputs by a matrix of weights. A 70B model does about 140 GFLOPs of it per token — and serving one user at a time uses 0.34% of a GPU's compute, because a matrix times a single vector reuses nothing.

  • matrix-multiplication
  • linear-algebra
  • gpu

/AI/4 min read

A latency budget for voice agents

Seven stages with medians adding up to 820 ms do not give an 820 ms agent. Simulated with realistic spread, the median turn takes 891 ms, the 95th percentile 1,407 ms, and a third of all replies take over a second. Adding up per-stage p95s would have predicted 1,890.

  • voice-agents
  • latency
  • percentiles

/AI/4 min read

Cascaded vs speech-to-speech voice agents

A cascade chains speech-to-text, a text LLM and text-to-speech; a speech-to-speech model hears audio and speaks audio. The second keeps tone and cuts hand-offs, but a 10-minute call at 25 audio tokens a second is about 30,000 tokens of context against roughly 1,950 as text.

  • voice-agents
  • speech-to-speech
  • stt

/AI/4 min read

What a neural network is

Layers of weighted sums, each followed by a bend. A network with 17 parameters learns XOR — something no single neuron can — going from outputs stuck near 0.41 to 0.01 / 0.99 / 0.99 / 0.013 in 5,000 steps. Every large model is the same idea with more of everything.

  • neural-networks
  • deep-learning
  • backpropagation

/AI/4 min read

Barge-in in voice agents

Barge-in is the user talking over the agent and the agent yielding. Detection takes ~200 ms; whatever audio is already buffered keeps playing — 500 ms of buffer means 700 ms of both talking at once. And the agent must forget the 85 words it planned but never said.

  • voice-agents
  • barge-in
  • interruptions

/AI/5 min read

Turn-taking in voice agents

Humans swap turns in about 200 ms without talking over each other. A voice agent that waits for silence has to pick a threshold — and in a simple model of real pauses, 300 ms cuts off 40.9% of turns while 1,200 ms still cuts 6.0% and adds over a second of dead air.

  • voice-agents
  • turn-taking
  • endpointing

/AI/4 min read

Why LLMs hallucinate: the token-level view

A model does not look facts up; it picks the next token from a distribution. When it is unsure, that distribution is spread over plausible wrong answers, and one gets written with the same fluency as the truth. A 25-token citation right at 97% per token is fully right 46.7% of the time.

  • hallucination
  • llm
  • sampling

/AI/4 min read

How ChatGPT remembers you

The model itself remembers nothing between conversations. What feels like memory is text placed into the prompt: a list of saved facts, and snippets retrieved from past chats. A 1,000-token memory block rides along with every message — 30,000 tokens a day for a moderate user.

  • memory
  • chatgpt
  • personalisation

/AI/4 min read

How browser agents work

A browser agent looks at a page, decides on one click or keystroke, and looks again. At 98% reliability per action a 20-step task finishes 66.8% of the time and a 50-step one 36.4% — which is why the design is mostly about taking fewer, surer steps.

  • agents
  • browser
  • computer-use

/AI/4 min read

Query rewriting and multi-query retrieval

Users write bad search queries, and a retriever can only find what the query resembles. Rewriting the question three ways lifts recall from 60% to 93.6% if the rewrites fail independently — 76.8% if they fail together half the time — and reciprocal rank fusion decides which results win.

  • rag
  • retrieval
  • query-rewriting

/AI/4 min read

Tree of Thoughts

Chain-of-thought commits to one line of reasoning; Tree of Thoughts explores several and keeps the best. A three-step problem solved 21.6% of the time in one chain becomes 97.0% with five candidates per step and a perfect judge — and 49.6% with a judge that is right 80% of the time.

  • reasoning
  • prompting
  • search

/AI/4 min read

Contextual retrieval

A chunk that says "revenue grew 3%" does not say whose revenue or when. Contextual retrieval has a model write that missing context onto each chunk before indexing. Anthropic measured a 49% cut in retrieval failures — and prompt caching makes the preprocessing 6.2× cheaper.

  • rag
  • retrieval
  • bm25

/AI/5 min read

How Ollama works

Ollama packages a quantized model, an inference engine and an HTTP server behind one command. On a laptop, the speed you get is set by one division: memory bandwidth over model size — 20.6 tokens a second for an 8B model at 100 GB/s, 2.4 for a 70B.

  • ollama
  • local-llm
  • gguf

/AI/4 min read

Stop tokens in LLMs

A model keeps generating until something tells it to stop. When that fails, a 200-token answer runs to the 4,096-token cap — 20.5× the cost and 82 seconds instead of 4. With a 1% miss rate, that is ten runaways in every thousand replies.

  • stop-tokens
  • eos
  • decoding

/AI/4 min read

Tokenization in LLMs

A model never sees text, only token IDs, and the split decides what it costs and what it can do. At 1.3 tokens per word a 128k window holds 100,824 words; at 4 tokens per word — common for languages the tokenizer under-trained on — it holds 32,768, at 3.08× the price.

  • tokenization
  • tokens
  • vocabulary

/AI/5 min read

CUDA kernels

A kernel is a function run by thousands of GPU threads at once. Whether it is fast depends on one ratio — arithmetic per byte moved. An element-wise add reaches 0.056% of an H100's peak; a 4,096-square matrix multiply can use nearly all of it. Fusing three element-wise ops is a free 3×.

  • cuda
  • gpu
  • kernels

/AI/4 min read

The future of software development

If writing code is 30% of the job, making it ten times faster makes the job 1.37× faster — and infinitely faster only 1.43×. The work that is left is deciding what to build and proving it works, and that is where the profession is heading.

  • software-engineering
  • ai-coding
  • agents

/AI/4 min read

The evolution of LLM architecture

The 2017 transformer block is still recognisable in every frontier model, but nearly every part of it has been replaced. Most of the replacements are about one thing: a GPT-3-style cache needs 4.72 MB per token, which at 128k tokens is 618 GB for a single conversation.

  • transformer
  • architecture
  • gqa

/AI/4 min read

Top-k and top-p sampling

Both cut off the long tail of unlikely tokens before sampling, and each fails where the other works. On a confident step, top-p at 0.9 keeps 4 tokens where top-k keeps 40; on a flat one it keeps 15,996 where top-k keeps 40 — and leaves 62.5% of the probability out.

  • sampling
  • top-k
  • top-p

/AI/4 min read

System One models

Using a 70B language model to route a support ticket spends 241 times the arithmetic a small decision model needs — and returns a string that might not be one of the five queues. A System One model returns a typed answer with a calibrated probability instead.

  • classification
  • calibration
  • decisions

/AI/5 min read

Designing a real-time voice agent

A voice agent is five components in a pipeline with a deadline. Assembled naively, the gap after the user stops speaking is 1,100 ms; people expect about 200. The design is mostly the work of taking those 900 milliseconds back.

  • voice-agents
  • system-design
  • latency

/AI/4 min read

Recursive self-improvement

A system that improves the thing that improves it. Ten cycles at a steady 10% compound to 2.59×; with returns halving each cycle the ceiling is 1.21×. And on a 500-question benchmark, a change that makes the model 1% worse passes as an improvement 36.5% of the time.

  • rsi
  • self-improvement
  • evaluation

/AI/4 min read

Temperature in LLMs

Temperature divides the logits before the softmax. On the same four candidates, T = 0.2 gives the wrong answer a 0.0% chance and T = 1.5 gives it 5.2% — which across 100 users means nobody sees it, or 99.5% of the time somebody does.

  • sampling
  • temperature
  • softmax

/AI/4 min read

N-gram speculation

Speculative decoding without a draft model: guess the next tokens by finding the last few tokens earlier in the context and copying what followed. On a code edit that is 4.59 tokens per step; in open chat it is 1.10 — and it never makes anything slower.

  • inference
  • speculative-decoding
  • prompt-lookup

/AI/4 min read

Prefill-decode disaggregation

One 32k-token prompt arriving on a shared server freezes every running conversation for 1.16 seconds — 178 decode steps. Splitting prefill and decode onto separate machines removes the freeze, at the price of shipping a 10.74 GB cache across the network.

  • inference
  • serving
  • prefill

/AI/5 min read

KV cache compression

A 70B-class model stores 320 KB of keys and values per token — 10.74 GB for one 32k-token conversation, so 40 GB of free memory serves three. Quantizing and evicting the cache together takes that to 66, and the three methods that get there fail in different ways.

  • kv-cache
  • inference
  • quantization

/AI/4 min read

Vectorless RAG

Instead of embedding chunks, give the model a table of contents and let it navigate. A 300-page report is answered by reading 2,320 tokens instead of 150,000 — but every level of the tree is a chance to take the wrong branch, and 95% per step is 85.7% after three.

  • rag
  • retrieval
  • reasoning

/AI/5 min read

Chunking strategies for RAG

Chunk size is a trade between two failure rates that both scale as L/C: a 60-token fact is cut in half 23% of the time at 256-token chunks, and makes up only 23% of the chunk when it survives. Overlap is how you stop paying both.

  • rag
  • chunking
  • retrieval

/AI/4 min read

Attention Sinks

Attention weights must sum to exactly one, so "nothing here is relevant" cannot be expressed. The first token becomes where the surplus goes — and dropping it makes every remaining weight 2.63× sharper than the model intended.

  • attention-sinks
  • softmax
  • streaming

/AI/4 min read

Sliding Window Attention

Limiting each token to a 4,096-position window cuts the attention cost 32× at 131k tokens — and cuts the memory a sequence holds from 17.18 GB to a fixed 537 MB, which is 3 concurrent requests becoming 122.

  • attention
  • long-context
  • kv-cache

/AI/4 min read

TensorRT-LLM

A decode step launches 384 tiny kernels and spends 1.92 ms of CPU time just asking for them. Replaying the whole step as one recorded graph makes that 5 microseconds, which is 1.27× more tokens per second for no change in arithmetic.

  • tensorrt-llm
  • inference
  • cuda-graphs

/AI/4 min read

LPU

Putting the weights in on-chip SRAM makes a single stream 27× faster and costs 732× the throughput per chip. That one exchange rate explains every design decision in the architecture.

  • lpu
  • inference
  • sram

/AI/4 min read

Decoding EAGLE

Guessing the model's next hidden state instead of its next token removes the sampling noise from the guess. Going from 2.5 to 3.5 accepted tokens per pass is only an 11-point accept-rate gain, and a 40% speedup.

  • eagle
  • speculative-decoding
  • inference

/AI/4 min read

Decoding Medusa

Extra prediction heads on the same model replace a separate draft model — 134 MB instead of 2 GB. The acceptance chain multiplies, so the fourth head adds 0.044 tokens and the sixth adds 0.001.

  • medusa
  • speculative-decoding
  • inference

/AI/4 min read

RNNs vs Transformers

Attention costs n²d and recurrence costs nd², so they cross exactly at n = d — 768 tokens for a typical model. Transformers won on training parallelism, and pay for it past that crossover.

  • rnn
  • transformers
  • attention

/AI/4 min read

Definition of Done

A loop stops when its checker passes, so the checker sets a ceiling on quality that no number of attempts can lift. Tightening the checker buys more than improving the model does.

  • verification
  • agents
  • evaluation

/AI/4 min read

Prefix Tuning

Prefix tuning trains 48× more parameters than prompt tuning, and that factor is exactly twice the layer count. What the extra numbers buy is influence at every depth rather than only at the input.

  • prefix-tuning
  • peft
  • attention

/AI/5 min read

Graph Engineering

A graph with one three-way decision and a cycle capped at three has fifteen possible paths. The same work as a free loop with six tools and twelve steps has 2.61 billion. Only one of those numbers can be tested.

  • graphs
  • agents
  • testing

/AI/5 min read

Loop Engineering

An agent's cost grows with the square of its step budget, so doubling the budget nearly quadruples the bill. In one accounting the last six of twelve turns served 12% of runs and carried 71% of the tokens.

  • agents
  • loops
  • context

/AI/4 min read

Lost in the Middle

Accuracy follows a U-shape across a long input, which means the order you pass chunks in is worth real points. Ten chunks arranged well beat twenty in rank order, using half the tokens.

  • long-context
  • rag
  • retrieval

/AI/5 min read

LLM Watermarking

Detecting a watermark is a coin-flip test. At full strength 64 tokens is enough; every halving of the signal quadruples the text you need, which is exactly why paraphrasing defeats it.

  • watermarking
  • detection
  • statistics

/AI/5 min read

Deep RL from Human Preferences

Nine hundred comparisons — one hour of someone's attention — taught a simulated robot to backflip. That is 11,111× fewer human decisions than scoring every step, and the trick is what the comparison is asked about.

  • rlhf
  • reward-modelling
  • reinforcement-learning

/AI/5 min read

Decoding InstructGPT

Thirteen thousand written examples is 0.002% of the pretraining text, and the whole alignment run was 1.6% of the compute. It made a 1.3-billion-parameter model preferred over a 175-billion one.

  • instructgpt
  • rlhf
  • alignment

/AI/4 min read

Decoding ColBERT

Keeping one vector per token instead of one per passage lets every query term find its own best match. On a worked example that widened the gap between the right document and a plausible wrong one from 64% to 113%.

  • colbert
  • late-interaction
  • maxsim

/AI/4 min read

LLM Guardrails

A guardrail catching 90% of harmful requests with a 1% false-positive rate blocks 1,267 requests a day, of which 997 are legitimate. The visible effect of most guardrails is refusing real users.

  • guardrails
  • safety
  • false-positives

/AI/5 min read

Cloud vs On-device

In the cloud the data travels to the model; on a device the model travels to the data. Three numbers decide which: the latency budget, the crossover request count, and the fraction of users who never take your update.

  • deployment
  • on-device
  • latency

/AI/4 min read

Encoder vs Decoder

One mask setting separates the two, and it decides two things that look unrelated: how much training signal a corpus yields, and whether generation can be made incremental. Both favour the decoder by a wide margin.

  • transformers
  • encoder
  • decoder

/AI/4 min read

Generative AI

A classifier picks one of a handful of labels. A generator picks one of 10^470 possible answers, which is why it cannot work by choosing from a list — and why its characteristic failure is being fluent and wrong.

  • generative-ai
  • llm
  • autoregression

/AI/5 min read

Prompt Injection in LLMs

A filter that blocks 95% of attempts sounds strong and falls to a coin flip in fourteen tries. Which is why the defences that work are the ones enforced in code, where the number is 100% by construction.

  • prompt-injection
  • security
  • agents

/AI/4 min read

Precision vs Recall

The trade-off everyone describes is real and it is not the main problem. When positives are rare, a 98%-accurate classifier produces alerts that are wrong 91% of the time — and the fix is not a better model.

  • precision
  • recall
  • base-rate

/AI/4 min read

Embeddings

Two numbers can hold two distinguishable concepts. Sixteen can hold twenty-one. That measured curve is the reason real embeddings have hundreds of dimensions, and it is rarely the explanation given.

  • embeddings
  • vectors
  • cosine-similarity

/AI/4 min read

Agent Skills

Loading fifty procedures eagerly costs 210,000 tokens and does not fit. Loading their descriptions costs 4,750, which makes the whole thing work — and turns the real problem into a fifty-way choice made from twenty words.

  • agent-skills
  • context
  • progressive-disclosure

/AI/4 min read

MCP

A protocol turns an N×M integration problem into N+M, which is 8.6× less work at a dozen apps and thirty systems. The part that needs more attention is that a server's own text reaches the model's context.

  • mcp
  • protocol
  • agents

/AI/4 min read

Fine-tuning

Fine-tuning is good at changing how a model behaves and bad at teaching it facts. It also has a break-even point — about 6,750 requests in one worked case, and ten times that if the prompt it replaces was being cached.

  • fine-tuning
  • lora
  • training

/AI/4 min read

OKF

An agent can work out a column's type by looking. It cannot work out that status 'H' means excluded from revenue, because that fact is in someone's head — and four rules out of five are like that.

  • okf
  • metadata
  • agents

/AI/4 min read

Semantic Search

Matching by meaning solves the vocabulary problem and creates a new one: one vector per chunk averages everything together, so a single distinguishing term contributes about 1/√n of the direction. At 200 tokens that is 7%.

  • semantic-search
  • embeddings
  • cosine-similarity

/AI/5 min read

Cursor

Three different models do three different jobs, and the reason is a latency budget. A completion has about 210 ms of model time before it feels late, and a large model needs six times that.

  • cursor
  • code-editors
  • latency

/AI/4 min read

Context Compaction

Replacing old turns with a summary buys room, and each summary is lossy. Summarise a summary eight times and 43% of the original detail is left — which is why the facts that matter must never be summarised twice.

  • context-compaction
  • summarisation
  • agents

/AI/4 min read

Claude Code

A coding agent is a model plus tools plus a loop. The two things that make it work are searching instead of reading — a 700× reduction in what enters the context — and being able to check its own answer, which turns 55% into 96%.

  • claude-code
  • coding-agents
  • tools

/AI/4 min read

llama.cpp

Running a model on a laptop CPU is a memory-bandwidth problem, not an arithmetic one — which sets a hard ceiling of about 12 tokens a second. It also explains why offloading half the layers to a GPU barely helps.

  • llama-cpp
  • local-inference
  • cpu

/AI/4 min read

Model Quantization

Fewer bits per number is the easy part. What decides whether it works is how many numbers share a scale — and in one measured case the average error looked fine at 5% while the ordinary features were off by 42%.

  • quantization
  • int8
  • outliers

/AI/4 min read

Chain-of-Thought Prompting

A model has no scratchpad except the tokens it has already written, and each token gets one fixed pass through the network. Asking for the steps is asking for more computation — sixty tokens of working is sixty times as much.

  • chain-of-thought
  • prompting
  • reasoning

/AI/4 min read

Prompt Chaining

Splitting a task across several prompts makes each step more reliable and makes more steps that all have to work. Those pull against each other, and the result is an optimal chain length that is shorter than most people assume.

  • prompt-chaining
  • prompting
  • reliability

/AI/4 min read

PyTorch

PyTorch builds the computation graph by running your code, which is why ordinary Python control flow works inside a model. The same decision explains its two most common bugs.

  • pytorch
  • autograd
  • tensors

/AI/4 min read

Semantic Caching

An exact cache is never wrong. A semantic cache answers a question nobody asked, which makes the similarity threshold a decision about how often you are willing to be confidently incorrect.

  • semantic-caching
  • embeddings
  • similarity

/AI/4 min read

Hybrid Search

Keyword and vector search fail on opposite queries, so run both. The hard part is combining two ranked lists whose scores are not on the same scale — and the constant in the standard fix quietly decides your ordering.

  • hybrid-search
  • bm25
  • rrf

/AI/4 min read

HyDE in RAG

A question and its answer barely resemble each other, which is a problem when retrieval works by resemblance. HyDE has the model write a fake answer first and searches with that instead.

  • hyde
  • rag
  • retrieval

/AI/4 min read

Prefill vs Decode

Serving a model is two workloads wearing one name, and their metrics pull against each other. Time to first token is 1.5% of a long answer's duration and almost all of how responsive it feels.

  • prefill
  • decode
  • latency

/AI/5 min read

GPU for Deep Learning

A GPU is thousands of simple cores, which suits the arithmetic of a neural network perfectly. What actually decides what you can build on one is not the cores — it is that training a model needs eight times the memory of running it.

  • gpu
  • vram
  • training

/AI/4 min read

LangGraph

The point is not that graphs are more flexible than lines. It is that the graph's position is stored alongside its data, so a run can be paused, resumed after a crash, or held for a human — none of which a straight-line pipeline can do.

  • langgraph
  • agents
  • state-machines

/AI/4 min read

LangChain

The framework's actual content is one interface that every piece implements. That is what makes the pipe operator work, what makes batching and streaming propagate through a chain you assembled — and what makes a broken prompt hard to find.

  • langchain
  • llm
  • composition

/AI/4 min read

SGLang

SGLang keeps every in-flight request's attention cache in one prefix tree, so any overlap between any two requests is reused automatically — including overlaps nobody declared. Its second trick is not calling the model for output that was never in doubt.

  • sglang
  • radix-tree
  • serving

/AI/4 min read

Approximate Nearest Neighbour Search

Giving up the guarantee of finding the true nearest vector buys enormous speed for almost no accuracy. In a measured run, scanning 3.4% of the data found the exact answer 99.8% of the time.

  • ann
  • vector-search
  • hnsw

/AI/4 min read

Google TPU

A TPU is built around a grid of multipliers that pass values to each other instead of fetching them. That one decision is where its speed and its power efficiency come from — and also where its awkwardness comes from.

  • tpu
  • systolic-array
  • hardware

/AI/3 min read

Image Embeddings

Comparing images by their pixels fails badly — the same object moved twelve pixels can look less like itself than a different object does. An embedding is a representation trained so that stops happening.

  • image-embeddings
  • computer-vision
  • similarity

/AI/4 min read

Computer-Use Agents

An agent that drives a screen with a mouse and keyboard needs no integration at all, which is its whole appeal. It also has to be right at every single step, and that requirement is much harsher than it sounds.

  • computer-use
  • agents
  • vision

/AI/4 min read

Decoding Sakana Fugu

Fugu does not answer questions. It decides which frontier model should, and in its larger form how several of them should divide the work — which makes the interesting question how much capability is actually available to be routed to.

  • orchestration
  • routing
  • multi-model

/AI/3 min read

Diffusion Language Models

Instead of writing left to right, a diffusion language model starts from an all-masked sequence and fills it in over a few rounds. The speedup is real, and so is the reason it cannot be pushed as far as it looks.

  • diffusion
  • language-models
  • parallel-decoding

/AI/4 min read

Embedding Cache

The same text embeds to the same vector every time, so recomputing it is pure waste. What makes the cache worth building is that query traffic is wildly lopsided — a few megabytes of memory removes most of the calls.

  • embeddings
  • caching
  • rag

/AI/4 min read

World Models

A world model is a learned simulator an agent can practise inside. The whole design question is how many steps it can imagine before its own small errors compound into fiction.

  • world-models
  • reinforcement-learning
  • planning

/AI/4 min read

vLLM

vLLM's central idea is to stop giving each request a contiguous slab of GPU memory and instead hand it small blocks through a lookup table — which removes the waste, and as a side effect makes sharing memory between requests almost free.

  • vllm
  • paged-attention
  • serving

/AI/5 min read

LLM Inference Optimization

Generating a token barely uses the GPU's arithmetic — it spends almost all its time moving weights from memory. Once you see that, every serving optimization sorts itself into one of three piles.

  • inference
  • gpu
  • memory-bandwidth

/AI/4 min read

Function Calling in LLMs

The model never runs anything. It writes a structured request and stops, and your code decides whether to honour it — which is both why function calling is safe and where every mistake with it comes from.

  • function-calling
  • tools
  • json-schema

/AI/4 min read

GGUF

GGUF is one file holding the weights, the tokenizer and everything needed to run a model — laid out so the runtime can map it into memory instead of parsing it, and quantized in small blocks so 4 bits per weight is actually usable.

  • gguf
  • quantization
  • local-inference

/AI/4 min read

Knowledge Distillation

A trained model knows more than the answer it gives — it knows how close the wrong answers were. Distillation trains a small model on that whole distribution instead of the single correct label, which is a far richer target.

  • knowledge-distillation
  • training
  • softmax

/AI/4 min read

Token Streaming

A model produces its answer one token at a time, so the answer exists in pieces long before it is finished. Streaming is the decision to send those pieces instead of holding them, and it works because reading is far slower than generating.

  • token-streaming
  • sse
  • llm-inference

/AI/4 min read

Prompt Caching

Most of a long prompt is the same on every request. Prompt caching stores the work already done on that unchanging opening so the model never has to redo it — but only if the opening really is unchanged, character for character.

  • prompt-caching
  • kv-cache
  • llm-inference

/AI/4 min read

JEPA

Predict what a hidden part of an image means rather than what it looks like. The objective that makes that work has a perfect and useless solution, and the architecture exists to keep it out of reach.

  • jepa
  • self-supervised
  • representation

/AI/4 min read

Rerankers

Retrieval is fast because it never reads the question and the document together. A reranker does read them together, which is why it is better and why it can only be used on a shortlist.

  • reranking
  • retrieval
  • rag

/AI/5 min read

Vector databases

Storing meaning as coordinates is the easy half. The hard half is finding the nearest ones among a hundred million without reading all of them — which is why the answer is allowed to be slightly wrong.

  • vector-database
  • ann
  • embeddings

/AI/4 min read

Dropout

Switch off a random half of the neurons at every training step. It stops the network relying on any particular one, and the scaling factor that makes it work is more interesting than it looks.

  • dropout
  • regularisation
  • overfitting

/AI/4 min read

GANs

Two networks trained against each other, one making fakes and one catching them. Because each is graded by the other, the loss numbers stop meaning what loss numbers usually mean.

  • gan
  • generative
  • adversarial

/AI/5 min read

Continual learning in LLMs

Teaching a trained model something new tends to erase what it already knew. Every fix for that is a different way of deciding which weights are allowed to move.

  • continual-learning
  • forgetting
  • fine-tuning

/AI/5 min read

Variational autoencoders

An ordinary autoencoder compresses well and generates nothing, because its latent space is full of holes. A VAE fills the holes by encoding to regions instead of points — and pays for it with a second loss term.

  • vae
  • latent-space
  • generative

/AI/4 min read

Diffusion models

Destroy an image with noise in a thousand small steps, then train a network to undo one step at a time. Each individual step is easy, which is the entire reason the method works.

  • diffusion
  • generative
  • noise-schedule

/AI/4 min read

Multi-head attention

Running several attention operations side by side costs nothing extra — the parameters and the cache are identical to one big head. What you actually spend is the width each head gets to work in.

  • attention
  • transformers
  • heads

/AI/4 min read

Cross attention

One sequence asks the questions and a different sequence answers them. Two useful things follow from that split: the attention matrix stops being square, and the answering side is computed once.

  • attention
  • transformers
  • encoder-decoder

/AI/4 min read

Self attention

The word self means the queries, keys and values all come from the same sequence. The consequence is that a word's representation is built from its neighbours, so the same word comes out different in different sentences.

  • attention
  • transformers
  • context

/AI/5 min read

AI agent observability

An agent's answer is the smallest part of what it did. Recording the rest produces far more data than ordinary logging — around seventy times more — which makes what you keep a real decision.

  • observability
  • agents
  • tracing

/AI/4 min read

How AI agents communicate

Once several agents work on one task, they have to pass things to each other. The shape of who-talks-to-whom is the decision that matters, and the arithmetic makes it for you.

  • agents
  • messaging
  • protocols

/AI/4 min read

AI subagents

A subagent is an agent called like a function: it runs its own loop, returns a value, and throws its working away. That discarded working is the entire point.

  • agents
  • subagents
  • context

/AI/4 min read

The agent loop

The loop is about twenty lines of ordinary code. Its cost is not ordinary — because the whole history is re-sent every turn, tokens grow with the square of the turn count.

  • agents
  • loop
  • cost

/AI/4 min read

AI orchestration

Wiring several model calls and tools into one workflow. The shape you choose is not a style preference — it decides latency, cost, and how much you can debug.

  • orchestration
  • workflows
  • latency

/AI/4 min read

AI agent evaluation

Judging an agent by whether it finished is not enough, because per-step reliability compounds. A 95%-per-step agent completes a twenty-step task about a third of the time.

  • agents
  • evaluation
  • trajectory

/AI/4 min read

LLM evaluation

There is no formula for whether an answer was any good, so evaluation becomes a choice about what to trade away. The costs differ by two orders of magnitude, which is what decides the shape of a real setup.

  • evaluation
  • benchmarks
  • metrics

/AI/4 min read

LLM as a judge

Using one model to grade another scales in a way human review cannot. It also brings biases that are measurable — and at least one of them cancels exactly if you run the comparison twice.

  • evaluation
  • judge
  • bias

/AI/4 min read

Contrastive learning

Teach a model what things mean by showing it what is the same and what is different. Almost all the learning signal comes from the few negatives it nearly got wrong.

  • contrastive
  • embeddings
  • self-supervised

/AI/4 min read

Recursive language models

Rather than reading a huge input, the model writes code that reads it — calling other models on the pieces and seeing only what comes back. What that buys is not fewer tokens.

  • long-context
  • recursion
  • agents

/AI/5 min read

GRPO

Generate several answers to the same question, and score each one against how the others did. The group's own average replaces a whole second network — and it fails in a way that is easy to measure.

  • grpo
  • reinforcement-learning
  • baseline

/AI/4 min read

DPO

DPO removes the reward model by noticing that a language model already contains one. What it optimises is a difference, and that turns out to matter more than it sounds.

  • dpo
  • alignment
  • preferences

/AI/4 min read

PPO

PPO improves a policy while refusing to move it far in one step. The clipping that enforces this is not symmetric, and the asymmetry is the part worth understanding.

  • ppo
  • reinforcement-learning
  • clipping

/AI/4 min read

BatchNorm vs LayerNorm

Same formula, different axis. One averages a feature across the examples in a batch, the other averages all the features within one example — and that choice decides which architectures each one suits.

  • normalisation
  • batchnorm
  • layernorm

/AI/5 min read

Large reasoning models

A reasoning model spends thousands of tokens working before it answers. Those tokens are billed, they set the latency, and they are the reason it gets harder problems right.

  • reasoning
  • test-time-compute
  • rlvr

/AI/5 min read

RLHF

People cannot score an answer out of ten consistently, but they can say which of two is better. RLHF is the machinery for turning a pile of those comparisons into a model that behaves.

  • rlhf
  • alignment
  • reward-model

/AI/4 min read

Autoregressive models

Generate one token, append it to what you have, and use that to generate the next. The whole design follows from one identity in probability, and so does its main weakness.

  • autoregressive
  • generation
  • chain-rule

/AI/4 min read

Continuous batching

Waiting for every request in a batch to finish leaves most of the GPU's slots idle most of the time. Refilling each slot the moment it empties is a scheduling change, and it roughly doubles what the same hardware serves.

  • inference
  • batching
  • throughput

/AI/5 min read

Small language models

Under about ten billion parameters, a model stops needing a datacentre. What actually decides where it can run is not the parameter count but how many gigabytes it occupies.

  • slm
  • quantisation
  • on-device

/AI/4 min read

Multimodal AI

A picture and the sentence describing it are completely different kinds of data. Multimodal models work by turning both into vectors that land in the same place.

  • multimodal
  • embeddings
  • vision

/AI/5 min read

LLM routing

Sending every request to the largest model means paying premium prices for questions a small model answers perfectly. Routing picks a model per request — and it tolerates being wrong far more than you would expect.

  • routing
  • cost
  • inference

/AI/4 min read

Context engineering

Everything a model knows about your task is in one window, and the pieces compete for space. Deciding what goes in, in what order, and what gets dropped is most of the work.

  • context
  • prompting
  • rag

/AI/4 min read

Reflection agents

The agent writes something, criticises its own draft, and rewrites. It works because judging is an easier job than writing — and it fails in a specific way when the critic asks for facts it cannot check.

  • agents
  • reflection
  • critic

/AI/5 min read

Speculative decoding

A small model guesses the next few tokens and a large one checks them all in a single pass. Done properly the output is not an approximation of the large model — it is exactly what the large model would have produced.

  • inference
  • speculative-decoding
  • latency

/AI/4 min read

GraphRAG

Chunk search finds passages that look like the question. When the answer is a chain running through documents that mention none of the question's words, that is not enough.

  • rag
  • knowledge-graph
  • retrieval

/AI/4 min read

Plan-and-execute agents

Instead of deciding one step at a time, the agent writes the whole plan first and then works through it. Cheaper and steadier when the path is knowable, and useless when it is not.

  • agents
  • planning
  • execution

/AI/4 min read

Agentic RAG

Ordinary retrieval searches once and hopes the result was good. Agentic RAG puts an agent in charge of searching, so it can judge what came back, rewrite the query, and go again.

  • rag
  • retrieval
  • agents

/AI/4 min read

ReAct agents

ReAct makes an agent write down its reasoning before every action. The thought is not decoration — it is what the model reads back on the next step, and it is the only place you can see why anything happened.

  • agents
  • react
  • reasoning

/AI/5 min read

Multi-agent systems

Splitting a job across several specialised agents buys parallelism and focus, and costs latency, tokens and the ability to debug easily. It is worth it less often than it looks.

  • agents
  • multi-agent
  • orchestration

/AI/5 min read

Decoding DeepSeek-V4

A million tokens of context is unaffordable with ordinary attention. DeepSeek-V4 gets there by summarising the distant past into far fewer entries and attending to those instead.

  • deepseek
  • moe
  • attention

/AI/4 min read

AI agent memory

A language model remembers nothing between calls. Everything that looks like memory is machinery around it deciding what to write down and what to put back in front of the model.

  • agents
  • memory
  • context-window

/AI/4 min read

AI agents

An agent is a language model wrapped in a loop that lets it call tools and see what happened. The loop is the whole difference between answering a question and doing a job.

  • agents
  • tools
  • llm

/AI/4 min read

RMSNorm

Layer normalisation does two things: it recentres values and it rescales them. RMSNorm drops the recentring, keeps the rescaling, and modern language models have almost all switched to it.

  • rmsnorm
  • layernorm
  • normalisation

/AI/4 min read

LoRA

Fine-tuning normally means updating every weight in the model. LoRA freezes them all and learns a pair of thin matrices alongside, which turns out to be enough.

  • lora
  • fine-tuning
  • adapters

/AI/5 min read

The math behind RoPE

RoPE gives a transformer position information by rotating query and key vectors instead of adding anything to them. The rotation cancels in the dot product, leaving only the gap between two tokens.

  • rope
  • position-embedding
  • attention

/AI/4 min read

Grouped query attention

Every attention head keeping its own keys and values makes the cache enormous. Grouped query attention has heads share them in small groups, cutting the memory by the size of the group.

  • attention
  • gqa
  • kv-cache

/AI/5 min read

The math behind cross-entropy loss

Cross-entropy turns a set of predicted probabilities into one number saying how wrong they were. It is built so that being confidently wrong costs far more than being unsure.

  • cross-entropy
  • loss
  • softmax

/AI/5 min read

The math behind gradient descent

Training a model means finding the weights that make the error smallest. Gradient descent does it by repeatedly stepping downhill, and the size of those steps decides whether it works at all.

  • gradient-descent
  • training
  • learning-rate

/AI/4 min read

Vision transformers

A vision transformer runs an image through the same machinery a language model runs text through. Almost all of the work is in turning a picture into something shaped like a sentence.

  • vit
  • transformers
  • computer-vision

/AI/4 min read

Feed-forward networks in LLMs

Attention gets the attention, but two thirds of a transformer layer's parameters sit in the feed-forward network. It is where the model keeps what it knows.

  • llm
  • transformers
  • feed-forward

/AI/5 min read

Decoding flash attention

Flash attention produces exactly the same numbers as ordinary attention. It is faster because it never writes the score matrix to memory at all.

  • attention
  • gpu
  • flash-attention

/AI/4 min read

Mixture of experts in LLMs

A mixture-of-experts layer holds many small networks and sends each token through only two of them. The model gets to be large without every token paying for all of it.

  • llm
  • moe
  • router

/AI/5 min read

Decoding the transformer architecture

A transformer takes tokens in and gives tokens out. Between those two ends sits a short list of components, each with one job — and the same list underpins BERT, GPT and everything since.

  • transformers
  • architecture
  • encoder

/AI/5 min read

The math behind backpropagation

Training a network means working out how much each weight contributed to the error. Backpropagation does it with one rule from calculus, applied backwards through the network.

  • neural-networks
  • backpropagation
  • chain-rule

/AI/3 min read

Why attention divides by √dₖ

The scaling factor in scaled dot-product attention is not a tuning knob. It is the one number that keeps the attention scores at a usable size no matter how wide the vectors are.

  • llm
  • attention
  • softmax

/AI/4 min read

The math behind attention: Q, K and V

Attention is one formula built from three matrices. Working it end to end on a three-word sentence shows exactly what Q, K and V are doing.

  • llm
  • attention
  • transformers

/AI/4 min read

Harness engineering in AI

A model on its own can only turn text into more text. The harness is everything you build around it — tools, memory, guardrails, retries — and it is usually where most of the work lives.

  • llm
  • agents
  • harness

/AI/5 min read

Byte pair encoding in LLMs

A model cannot read text, only numbers, so text has to be cut into pieces first. Byte pair encoding decides where to cut by repeatedly merging the most common pair of neighbours.

  • llm
  • tokenization
  • bpe

/AI/5 min read

Paged attention in LLMs

Serving an LLM means reserving memory for a reply before you know how long it will be. Paged attention stops that reservation from wasting most of the GPU.

  • llm
  • inference
  • paged-attention

/AI/3 min read

KV cache in LLMs

An LLM generates one token at a time, and each new token needs the keys and values of every token before it. The KV cache stores them instead of recomputing them.

  • llm
  • inference
  • kv-cache

/AI/4 min read

Causal masking in attention

Causal masking is what stops a token from attending to the tokens that come after it. Without it, a language model can see the answer it is being asked to predict.

  • llm
  • attention
  • transformers

Writing next

Android

  • Compose performance: when to use derivedStateOf vs remember
  • Modularising a multi-million-line Android monorepo
  • On-device LLM inference with Foundation Models

AI

  • Building an autonomous job-application agent with LangGraph
  • Prompt caching cost math: when it actually pays off
  • Playwright as a tool surface for agents
Back home