androidengineers.Book a session

Tokens, context and model behavior

Tokens, context and model behavior

articleSelf-paced

Understand what a model receives and why its output varies.

1. Tokens and context windows

Text becomes tokens, not necessarily whole words. Instructions, conversation and retrieved material compete for a finite context budget. Reserve output space and shorten history intentionally instead of truncating arbitrary bytes.

2. Prompts and grounding

A prompt describes the task; grounding supplies relevant evidence. Evidence can still contain malicious or incorrect text. Delimit it as data and require an unknown result when the information is absent.

3. Variability and confidence

Sampling settings influence variation but do not make answers true. A confident tone is not calibrated confidence. Validate factual claims against sources and structured values against domain rules.

Worked scenario

An expense parser outputs a negative total for a receipt. Valid JSON only proves syntax; your amount and currency checks must reject impossible values.

Apply it

Write a prompt with task, input boundary, output shape and an unknown case. Try missing and contradictory input.

Check your understanding

You can distinguish formatting success from factual correctness. Explain the decision and show evidence from your implementation or design. If you cannot demonstrate it yet, revisit the relevant section before continuing.

YOUR LEARNING JOURNEY

0 of 13 available lessons completed

Progress saved in this browser. No account needed.
Tokens, context and model behavior | AI for Android Developers — Fundamentals | Android Engineers