Lecture 21
Cornell University
INFO 5001 - Fall 2025
November 11, 2025
TODO
ae-19Instructions
ae-19 (repo name will be suffixed with your GitHub name).renv::restore() to install the required packages, open the Quarto document in the repo, and follow along and complete the exercises.01_hello-llmInstructions
.Renviron.secret β .Renviron
secret.R01_hello-llm.RItβs okay to treat LLMs as black boxes. Weβre not going to focus on how they work internally
Just try it! When wondering if an LLM can do something, experiment rather than theorize
You might think they could not possibly do things that they clearly can do today
Donβt worry about ROI during exploration. Focus on learning and engaging with the technology
Failure is valuable! Those are some of the most interesting conversations that we have
It doesnβt have to be a success. Attempts that donβt work still provide insights
Weβre going to focus on the core building blocks.
All the incredible things you see AI do decompose to just a few key ingredients.
Our goal is to build intuition through hands-on experience.

| Role | Description |
|---|---|
system_prompt |
Instructions from the developer (thatβs you!) to set the behavior of the assistant |
user |
Messages from the person interacting with the assistant |
assistant |
The AI modelβs responses to the user |

β What are the user and assistant roles in this example?
<Chat OpenAI/gpt-4.1 turns=2 tokens=14/29 $0.00>
ββ user [14] ββββββββββββββββββββββββββββββββββββββββ
Tell me a joke about R.
ββ assistant [29] βββββββββββββββββββββββββββββββββββ
Why did the R programmer go broke?
Because he kept using `sample()` and lost all his data!<Chat OpenAI/gpt-4.1 turns=3 tokens=25/28 $0.00>
ββ system [0] βββββββββββββββββββββββββββββββββββββββ
You are a dad joke machine.
ββ user [25] ββββββββββββββββββββββββββββββββββββββββ
Tell me a joke about R.
ββ assistant [28] βββββββββββββββββββββββββββββββββββ
Why did the letter R get invited to all the pirate parties?
Because it always knows how to *arr-r-ive* in style!02_word-gameInstructions
Set up a chat with a system prompt:
You are playing a word guessing game. At each turn, guess the word and tell us what it is.
Ask: In British English, guess the word for the person who lives next door.
Ask: What helps a car move smoothly down the road?
Create a new, empty chat and ask the second question again.
How do the answers to 3 and 4 differ? Why?
clearbotπ¨βπ» _demos/03_clearbot
System prompt:
First question:
Second question:

You write some words
The ChatGPT continues writing words
You think youβre having a conversation
Chatting with a Generative Pre-trained Transformer
LLM β Large Language Model
If you read everything
ever writtenβ¦
Books and stories
Websites and articles
Poems and jokes
Questions and answers
β¦then you couldβ¦
un|con|ventionaltoken-possibilities| Console | Browser | |
|---|---|---|
![]() |
live_console(chat) |
live_browser(chat) |
05_liveInstructions
Your job: write a groan-worthy roast of students at Cornell University
Bonus points for puns, rhymes, and one-liners
Donβt be mean
04:00

Start with the shinyapp snippet
Load {shinychat} and {ellmer}
Use the shinychat chat module
Create and hook up a chat client to use in the app
06_word-gamesInstructions
Iβve set up the basic Shiny app snippet and a system prompt.
Your job: create a chatbot that plays the word guessing game with you.
The twist: this time, youβre guessing the word.
07:00
[1] β The secret word is bicycle.