Module · AI Engineer
LLM Fundamentals
Tokens, context windows and inference.
TOPIC 01
Tokens and Context Windows
Why LLMs bill and think in tokens, and how the context window shapes what a model can see.
Tokens and Context Windows
Language models do not read text — they read tokens: chunks of a few characters that the model turns into numbers. Every API call is priced per token, and every model has a hard ceiling called the context window: the maximum number of tokens it can consider at once, prompt and answer combined.
What you'll practice
- Set a Token Budget — guided · beginner
- Count the Turns in a Chat Log — challenge · beginner
A command you'll meet
wc -l transcript.txtOpen any task below to get the full step-by-step walkthrough — every command is explained, and the lab validator checks what you actually built.
Hands-On Tasks in This Topic (2)
Set a Token Budget
Every LLM API call carries two cost knobs — which model you call and how many tokens it may generate. Write a small config file that captures both, the way real applications do.
Count the Turns in a Chat Log
Applications log every user turn so they can be replayed and analyzed later. Build a four-line chat transcript, count its lines with wc, and record the turn count in a summary file.
TOPIC 02
Sampling & Output Contracts
The knobs that shape an answer, and the schema that makes it machine-readable.
What you'll practice
- Configure the Sampling Knobs — guided · beginner
- Define a Structured Output Schema — practice · intermediate
A command you'll meet
cat ~/llm-lab/sampling.jsonTemperature decides how creative the answer is allowed to be. Open the task below for the full walkthrough.
Hands-On Tasks in This Topic (2)
Configure the Sampling Knobs
temperature, top_p and max_tokens decide how a model answers. Write the sampling configuration your application will send with every request.
Define a Structured Output Schema
Free text has to be parsed. A JSON Schema makes the model answer with a shape your code can rely on - write one for a ticket classifier.