Subjects·12 topics·243 terms
Applied AI
Models, tokens, retrieval, agents, evals and the production patterns around them.
Start with these 53, in order
Everything between calling a model and running one in production: tokens, prompts, retrieval, tools, evals, cost and the security boundary.
Read in order · tick what you already know
- 01
you asked for a citation and got a real-looking one that does not exist, delivered with the same confidence as the parts that were true.
Hallucination
- 02
you sent the same prompt twice and got two different answers, and nothing in your code changed between the calls.
Non-determinism
- 03
you asked about a library released last month and the model has never heard of it.
Knowledge cutoff
- 04
the conversation got long enough that the call started failing, and you have to drop or summarise the old turns before you can keep going.
Context overflow
- 05
you put the important instruction halfway down a long prompt and the model behaved as if it were not there.
Lost in the middle
- 06
your calls start coming back 429 once traffic climbs, and what you are hitting is requests per minute or tokens per minute, not a bug in your code.
Rate limits (RPM, TPM)
- 07
everything it does, the chat and the code and the reasoning, comes out of one trained habit of guessing the next token.
Large language model (LLM)
- 08
every API call you make is inference, and nothing you send in one of them changes the weights for the next.
Inference
- 09
'the model learns from our conversations' is false for API usage; nothing you send updates the weights.
Training vs inference
- 10
extremely sophisticated autocomplete, run one token at a time.
Next-token prediction
- 11
every bill, rate limit and context error you will ever see is denominated in tokens, not words or requests.
Token
- 12
the same string cost a different number of tokens on the other provider, because each model family ships its own.
Tokeniser
- 13
everything you send and everything it says has to fit one budget, and the retrieved documents are what usually blow it.
Context window
- 14
you halved the prompt and the bill barely moved, because the long generated answer was where the money actually went.
Input vs output tokens
- 15
when you say the prompt you mean the parts your application controls, which is most of what actually got sent.
Prompt
- 16
you put the standing instructions at the top once, instead of repeating who the model is and what it must never do in every user message.
System prompt
- 17
you resend the whole conversation on every call, because the server is not keeping it for you.
Messages array
- 18
every message carries a label, and the model weights the system one above the user one, though not absolutely.
Role (system, user, assistant)
- 19
it is HTTP. Each request stands alone, exactly like a REST endpoint without sessions.
Statelessness
- 20
for anything you will parse with code, run at or near 0.
Temperature
- 21
you set it too low and the answer got cut off mid-sentence, then set it too high and a runaway response ate the budget.
max_tokens
- 22
you treated a truncated response as a complete one, because nothing in your code branched on the finish reason.
Stop reason / finish reason
- 23
the twenty-second wait becomes an answer that visibly starts in under a second, without the model getting any faster.
Streaming
- 24
examples teach format and edge-case handling far more reliably than prose descriptions of the format.
Few-shot / in-context learning
- 25
you tell the model to work through it step by step, and the answer gets better on anything with arithmetic or several constraints at once.
Chain of thought
- 26
the prompt lives in version control with named placeholders, not concatenated inline at three different call sites.
Prompt template
- 27
you add answer only from the provided documents, and say so if they do not cover it, and the invented details stop.
Grounding via context
- 28
a coordinate for meaning; similar meanings land close together.
Embedding
- 29
you were about to stand up a dedicated vector product and realised the database you already operate has an extension for it.
Vector database
- 30
you look up the relevant bits of your own documents first and paste them into the prompt, so the answer comes from your data instead of the model's memory.
Retrieval-augmented generation (RAG)
- 31
you split the document into pieces before you store it, because embedding a whole 40-page PDF as one blob retrieves nothing useful.
Chunking
- 32
you cut at four hundred tokens and lost the sentence that straddled the boundary, so you make adjacent chunks overlap and try again.
Chunk size and overlap
- 33
you fetch fifty candidates cheaply and then have a slower, better model reorder them before you show the top five.
Reranking
- 34
you need JSON your code can parse rather than prose, so you constrain the shape of the response instead of writing a regex over the answer.
Structured output
- 35
you write out the types, required fields and enums once, and use the same thing for tool parameters and for the response shape.
JSON schema
- 36
the model replies with the name of one of your functions and its arguments instead of an answer, and your code runs it and hands the result back.
Function calling / tool calling
- 37
the model kept picking the wrong tool until you rewrote the description like documentation for a junior engineer.
Tool definition / schema
- 38
you stop capping it at one tool call and let the model keep calling tools until it decides it is finished.
Agentic loop
- 39
you stop scripting the steps and let the model choose which tool to call next, in a loop, until it decides it is finished.
Agent
- 40
you stop saying the answers feel better and produce a number you can put next to last week's number.
Eval
- 41
you have a second model score the first one's output against a rubric, because there is no exact answer to diff against.
LLM-as-judge
- 42
you re-run the whole scored set after a prompt tweak or a model upgrade, so you find out you broke case 12 before your users do.
Regression testing
- 43
nothing in your code changed but the outputs are worse than they were in March, because the traffic or the model underneath moved.
Drift
- 44
you retry the failed call, wait twice as long, retry again, and add a little randomness so your whole fleet does not retry in lockstep.
Exponential backoff
- 45
put static instructions and documents at the top, volatile user input at the bottom; caching works on prefixes.
Prompt caching
- 46
the second person asks roughly the same question in different words and you serve them the stored answer without calling the model.
Semantic caching
- 47
you allocate the window in code, so much for retrieved context and so much for the answer, instead of discovering the ceiling at 2am.
Token budgeting
- 48
you finally attribute spend per feature and find that a summariser almost nobody uses is a third of the bill.
Cost per request
- 49
the provider had an incident and your feature stayed up, because a second model was configured and had actually been tested.
Multi-provider failover
- 50
SQL injection's cousin, except there is no clean equivalent of parameterised queries, so you defend in depth instead.
Prompt injection
- 51
you validate and allowlist what the model returned before your code acts on it, because that output is untrusted input to everything downstream.
Output validation as a security boundary
- 52
you put deterministic checks around the model, allowlists and schema validation and refusal filters, because you cannot rely on it policing itself.
Guardrails
- 53
you redact before the text leaves your network, and you know what the provider retains and for how long.
PII handling
All of applied ai
Every term in this subject, 243 of them, grouped into 12 topics. Each topic is a track of its own.
How models work
01 · 32 termsThe mental model. You do not need the maths, but you need to know what a model is, how it was made, and why it behaves the way it does. Read this section once before writing any code, then come back when a term resurfaces.
- Artificial intelligence (AI)
- Machine learning (ML)
- Deep learning
- Neural network
- Layer
- Parameters / weights
- Training data / corpus
- Transformer
- Attention
- Large language model (LLM)
- Next-token prediction
- Autoregressive
- Training vs inference
- Pretraining
- Post-training
- Alignment
- Base model
- Instruct model / chat model
- Inference
- Checkpoint
- Model size naming (7B, 70B)
- Scaling laws
- Emergent capabilities
- Knowledge cutoff
- Frontier model
- Open weights vs closed models
- Dense model
- Mixture of experts (MoE)
- Distillation
- Reasoning model / extended thinking
- Test-time compute
- Multimodal
Tokens
02 · 13 termsTokens are the unit of everything: cost, latency, context limits and most odd model behaviour. Internalise this section and half the API layer explains itself. Pair with scripts 1 to 3.
The API layer
03 · 30 termsThe layer you will live in. It is ordinary HTTP and JSON with a handful of new parameters and failure modes. Pair with scripts 1 to 3, and type these calls yourself at least once without an SDK.
- Messages API / chat completions
- Messages array
- Role (system, user, assistant)
- System prompt
- Turn / multi-turn
- Statelessness
- Completion / response object
- max_tokens
- Stop sequence
- Stop reason / finish reason
- Context overflow
- Logits
- Sampling
- Greedy decoding
- Temperature
- Top_p (nucleus sampling)
- Top_k
- Logprobs
- Seed and determinism
- Streaming
- Server-sent events (SSE)
- Time to first token (TTFT)
- Inter-token latency
- Latency vs throughput
- Rate limits (RPM, TPM)
- Exponential backoff
- Batch API
- Prompt caching
- Pricing model
- API key hygiene
Prompting
04 · 15 termsPrompting is interface design for a probabilistic component. The vocabulary is small but heavily used, and most of it is about being unambiguous.
Structured outputs and tool calling
05 · 16 termsThe bridge between free text and code you can actually run. This is the most-used capability in production LLM features and the subject of scripts 4 and 5.
- Structured output
- JSON mode
- JSON schema
- Schema conformance
- Constrained decoding
- Grammar-based decoding
- Validation and retry loop
- Function calling / tool calling
- Tool definition / schema
- Tool choice
- Tool result
- The tool loop
- Agentic loop
- Parallel tool calls
- Side effects and idempotency in tools
- Model Context Protocol (MCP)
Embeddings and retrieval
06 · 27 termsHow machines compare meaning, and how relevant knowledge gets into the context window. This section backs scripts 6 and 7, and as a Postgres person you will feel at home: half of it is indexing and ranking.
- Embedding
- Vector / dimension
- Embedding space
- Embedding model
- Cosine similarity
- Dot product and Euclidean distance
- Nearest neighbour search (k-NN)
- Approximate nearest neighbour (ANN)
- Vector database
- pgvector
- HNSW
- IVFFlat
- Chunking
- Chunk size and overlap
- Semantic chunking
- Contextual retrieval
- Top-k retrieval
- Metadata filtering
- Lexical search / BM25
- Hybrid search
- Reranking
- Bi-encoder vs cross-encoder
- Retrieval-augmented generation (RAG)
- Grounded / faithful answer
- Recall@k
- MTEB
- Embedding model versioning
Agents
07 · 20 termsAn agent is the tool loop from section 5 given autonomy, memory and boundaries. The vocabulary here is young and marketing-polluted; the definitions below are the load-bearing ones.
- Agent
- Workflow vs agent
- ReAct pattern
- Planning and decomposition
- Orchestration
- State management
- Memory (short-term vs long-term)
- Context engineering
- Context rot
- Trajectory
- Stop conditions
- Checkpointing and resumability
- Subagent
- Multi-agent system
- Handoff
- Computer use / browser agents
- Sandboxing
- Least privilege for tools
- Guardrails
- Human in the loop
Evaluation and reliability
08 · 23 termsEvals are to LLM features what tests are to code: the only alternative to superstition. This vocabulary backs script 8 and will dominate any serious applied AI interview.
- Eval
- Test case / golden set
- Ground truth / labels
- Pass rate / pass@k
- Exact match and rule-based scoring
- Rubric
- LLM-as-judge
- Judge biases
- Eval harness
- Regression testing
- Offline vs online evaluation
- A/B testing
- Canary deployment
- Hallucination
- Faithfulness / groundedness
- Non-determinism
- Self-consistency / majority voting
- Drift
- Benchmark
- Benchmark contamination
- Leaderboards and Elo
- Observability
- Tracing / spans
Fine-tuning and customisation
09 · 16 termsChanging the weights instead of the prompt. Reached for less often than newcomers expect: the decision rule comes first, the techniques after.
Local and self-hosted inference
10 · 20 termsRunning models on hardware you control: your M1 Air, your Hetzner box. The vocabulary of memory budgets and speed, and the domain where your infrastructure instincts pay off directly.
- Hugging Face
- Model licences
- Safetensors
- GGUF
- VRAM and unified memory
- Precision (FP32, FP16, BF16, INT8, INT4)
- Quantisation
- Quantisation levels
- Offloading
- Perplexity
- Inference engine
- Model server / serving
- llama.cpp
- Ollama
- vLLM
- KV cache
- Batching / continuous batching
- Speculative decoding
- Cold start / model loading
- Throughput benchmarking
Security and safety
11 · 14 termsNew attack surface, old discipline. The core fact: the model reads instructions and data through the same channel, and everything here follows from that.
Production patterns and cost
12 · 17 termsWhere LLM calls meet the disciplines you already run: caching, routing, failover, budgets and logging. Almost every pattern here is a backend pattern with tokens flowing through it.
- LLM gateway / proxy
- Model routing
- Cascade / fallback chain
- Multi-provider failover
- Circuit breaker
- Graceful degradation
- Queueing and async processing
- Streaming UX patterns
- Exact-match caching
- Semantic caching
- Token budgeting
- Cost per request
- Percentile latency (p50, p95, p99)
- Structured logging of LLM calls
- Prompt and configuration versioning
- Shadow deployment
- Frameworks: build vs buy