Foundations
What prompts are, how LLMs process them, and mental models for effective prompting.
Attention and Position Effects
LLMs exhibit a U-shaped attention curve — prioritizing information at the beginning and end of the context while partially losing content in the middle — with actionable placement rules that measurably improve output quality.
Context Window Mechanics
The context window is the fixed-capacity input buffer that constrains every LLM interaction, with sizes ranging from 8K to 2M+ tokens, where nominal capacity and effective capacity diverge significantly.
How LLMs Process Prompts
Understanding the four-stage pipeline — tokenization, embedding, attention, and generation — reveals why word choice, ordering, and structure mechanically alter LLM outputs.
In-Context Learning
In-context learning (ICL) is the emergent ability of large language models to learn tasks from examples provided in the prompt — without any parameter updates — enabling few-shot prompting and fundamentally changing how we program AI systems.
Mental Models for Prompting
Four mental models — completion engine, instruction follower, role player, and pattern matcher — provide complementary lenses for understanding LLM behavior, and knowing which model to apply in a given situation determines prompt effectiveness.
Prompt Engineering vs. Context Engineering
Prompt engineering crafts the instructions telling the model what to do, while context engineering designs the information environment — what documents, history, state, and tools enter the context window — and production systems require both.
Temperature and Sampling
Temperature, top-k, and top-p (nucleus sampling) are the control knobs that determine how the model selects from its predicted probability distribution, ranging from deterministic extraction to creative exploration.
Tokenization for Prompt Engineers
Tokenization determines how text is segmented into the fundamental units an LLM processes, directly affecting cost, multilingual performance, and prompt behavior in ways that are invisible but consequential.
What Is a Prompt
A prompt is the complete structured input sent to an LLM, composed of distinct segments — system message, user input, assistant prefill, and tool results — each influencing generation in specific, measurable ways.