What the Model Sees When You Ask
Code PredictionCode Completion
A feature of an IDE that sends the code around your cursor to an LLM and shows the predicted next tokens as a suggestion, which you can accept or ignore.
In Positron:
Tab accepts, Esc dismisses, or just keep typing.TabA suggestion is the likely next code. Whether it’s the right next code depends on what you’re trying to do.
Does this code run? Does it do what the comment says?
The capital of France is Paris.
The biggest city in France is Paris. It has about 2.1 million residents
within its city limits, and its metropolitan area has roughly 12 to 13
million people.
It depends on how you measure "city":
- Largest metropolitan area: Tokyo, Japan, with about 37 million people
in its greater metropolitan area.
- Largest city proper (administrative limits): Chongqing, China, with
about 32 million people, though much of that population is rural.
- Largest by area: Chongqing (administrative area of about 82,000 km²).
If you meant a specific country or measure, let me know.
Same model, same prompt, different answer. What differed?
<Chat Anthropic/claude-haiku-5-5 turns=4 input=52 output=128>
── user ──────────────────────────────────────────────────────────
The capital of France is
── assistant [input=14 output=14] ────────────────────────────────
The capital of France is **Paris**.
── user ──────────────────────────────────────────────────────────
What is the biggest city?
── assistant [input=38 output=114] ───────────────────────────────
The biggest city in France is **Paris**. It has about 2.1 million
residents within its city limits, and its metropolitan area has
roughly 12 to 13 million people.
Stateless
A server is stateless if it keeps nothing from one request to the next. An LLM API is stateless: to continue a conversation, the client sends the whole conversation again.
Context
All of the text that a model reads when it generates a response: the instructions, the earlier turns of the conversation, and any code, data, or documentation sent along with the prompt.
The model has two sources for an answer:
The easiest way is with `dplyr`:
```r
penguins %>%
group_by(species) %>%
summarise(mean_body_mass = mean(body_mass_g, na.rm = TRUE))
```
**Base R alternative**:
```r
tapply(penguins$body_mass_g, penguins$species, mean, na.rm = TRUE)
```
tutor <- chat_claude(
model = "claude-haiku-5-5",
system_prompt = "You are a tutor for Stat 133. Students use the
tidyverse and the native pipe. Never write the code for them.
Reply in two sentences: name one function to look at, then ask
one question."
)
tutor$chat(
"How do I find the mean body mass for each species of penguin in R?"
)Look at `group_by()` and `summarize()` from dplyr, since grouping by
species and then summarizing the mean of body mass is the key idea. What
do you think the grouping variable should be called in the penguins
dataset, and which column holds body mass?
System Prompt
Instructions that the client places at the start of the context and sends with every request. It sets the model’s role, its conventions, and what it should and shouldn’t do.
What will it say?
I don't have any information about your bake sale. I can't see sales
records, receipts, or files unless you share them here.
Your bake sale brought in a total revenue of $185 (cookies $80,
brownies $75, scones $30).
The model produced $185 the way it produces every token: by prediction.
Your turn. Compute the total revenue from bake_sale yourself, with a dplyr pipeline.
01:00
An LLM is like a judge: it rules only on what’s entered into the record (the context). At every hearing, the clerk reads the whole record aloud again, starting with the law posted above the bench (the system prompt).
