Skip to content

Lab 097: Interactive: Tokens, Sampling, and Context WindowsΒΆ

Level: L50 Journey: llm-foundations Time: ~30 min Cost: Free

Free-first design

Complete the guided exercise with Copilot Free or the included simulation. Paid features are optional and explicitly labeled.

AI Credit impact

Low for guided work; medium/high for agentic or repeated runs. Prefer automatic model selection, plan before acting, keep context focused, and avoid unnecessary parallel sessions.

What You'll LearnΒΆ

  • Estimate tokens from text
  • Explain temperature, top-k, and top-p
  • Budget a context window
  • Recognize truncation and context dilution

GH-300 alignmentΒΆ

Prompt and context foundations. This mapping follows the GH-300 curriculum snapshot dated 2026-08-07. The official outline may retain older product wording such as β€œCopilot Edits”; this lab teaches the current product experience and calls out that difference.

Concept MapΒΆ

flowchart LR
  I[Instructions] --> W[Context window]
  U[User input] --> W
  R[Retrieved context] --> W
  T[Tool output] --> W
  W --> O[Reserved output]
  W --> M[Safety margin]

Hands-on ExerciseΒΆ

Step 1: Estimate tokensΒΆ

Use the widget below. The estimate uses a transparent approximation, not a model-specific tokenizer. Compare short prose, code, JSON, and accented text.

Step 2: Explore samplingΒΆ

Move temperature, top-k, and top-p. Predict whether output becomes more deterministic or diverse, then reveal the explanation.

Step 3: Budget the windowΒΆ

Allocate system instructions, user input, retrieved context, tool output, and response. Keep a safety margin and remove low-value context first.

Supporting kitΒΆ

The site build generates stable PDF and ZIP downloads. The ZIP contains the lab guide and every supporting file declared for this lab.