Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 0.1 — What a Large Language Model Is
LLM Engineering · Example 2 of 2

The model remembers nothing: the app re-sends the conversation

The fake model can only know your name if the app sends the earlier message again.

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.

01

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.

02

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

01

Explain what a large language model does, in two sentences, to someone who has never programmed.

02

Why does a chat app need to send the earlier messages again on every call?

03

What is the difference between training and inference, and which one does an LLM engineer usually do?

04

Why can an LLM state something false with confidence?

The model remembers nothing: the app re-sends the conversation
Sign in to run this example in your browser.

Expected output

App A sends the whole conversation every time:
  you: Hi, I'm Asha.
  bot: Hello Asha! How can I help?   (sent 1 message(s))
  you: What is my name?
  bot: Your name is Asha.   (sent 3 message(s))
App B sends only the newest message:
  you: Hi, I'm Asha.
  bot: Hello Asha! How can I help?   (sent 1 message(s))
  you: What is my name?
  bot: I don't know your name yet.   (sent 1 message(s))