A model turns text into next-word probabilities
A toy lookup table stands in for the model. Switch between Python, Java and JavaScript: all three print the same lines.
A large language model (LLM) is a program that reads text and predicts what text should come next, one small piece at a time. Chat assistants are an ordinary app wrapped around that one ability.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Extend the toy model so predict returns the single most likely word (or None if the text is unknown), and print it for the three prompts.
Write trim_history(history, keep) that returns the last keep messages but always keeps the first message if its role is system.
Explain it without notes
Explain what a large language model does, in two sentences, to someone who has never programmed.
Why does a chat app need to send the earlier messages again on every call?
What is the difference between training and inference, and which one does an LLM engineer usually do?
Why can an LLM state something false with confidence?
Expected output
Input: the cat sat on the
mat 0.62
floor 0.21
sofa 0.17
Input: i would like a cup of
tea 0.55
coffee 0.40
water 0.05
Input: the capital of mars is
(the toy has never seen this text)