[1] 10.725
wk9-d01-llms-intro
Chico State
DATA 385 - Fall 2026
October 20, 2026
Turn to your neighbor. Share one thing you found interesting in the Drexel paper. (2 minutes)
Thankfully we can do better now.
Wikipedia contributors. (2026, October 9). Office Assistant. In Wikipedia, The Free Encyclopedia. Retrieved October 15, 2026, from https://en.wikipedia.org/wiki/Office_Assistant. Image © Microsoft Corporation, via Wikipedia (File:Clippy-letter.PNG).
That is all it does. Answering a question, explaining an error, or writing R code is next-piece prediction, repeated one piece at a time.
Text is chopped into tokens: chunks that are often a word or part of a word (for example, “unbelievable” might become “un”, “believ” and “able”). At each step the model gives every possible next token a probability, then picks one.
These numbers are made up. A real model spreads probability over tens of thousands of tokens at every step.
Being tuned to be helpful is part of why it sounds so sure of itself, and feels like it’s always .
There is randomness built in. The model samples from its probabilities instead of always taking the top choice, so the same prompt can give different answers.
Prompt
Write R code that counts how many penguins are in each species.
With no data in front of it, the model has to guess what your data looks like.
Good at
Bad at
# Step 1: make sure penguins is a data frame
library(palmerpenguins)
if (!is.data.frame(penguins)) {
stop("penguins must be a data frame")
}
print("Confirmed: penguins is a data frame.")
# Step 2: make a working copy so we do not modify the original
penguins_copy <- as.data.frame(penguins)
print(paste("There are", nrow(penguins_copy), "rows in this data set."))
# Step 3: check the column types
if (!is.character(penguins_copy$species) && !is.factor(penguins_copy$species)) {
penguins_copy$species <- as.character(penguins_copy$species)
}
if (!is.numeric(penguins_copy$body_mass_g)) {
penguins_copy$body_mass_g <- as.numeric(penguins_copy$body_mass_g)
}
# Step 4: find the unique groups
species_list <- unique(as.character(penguins_copy$species))
species_list <- species_list[!is.na(species_list)]
species_list <- sort(species_list)
print(paste("Found", length(species_list), "unique species:",
paste(species_list, collapse = ", ")))
# Step 5: split the data into one chunk per species
chunks <- list()
for (i in seq_along(species_list)) {
keep <- penguins_copy$species == species_list[i] & !is.na(penguins_copy$species)
chunks[[species_list[i]]] <- penguins_copy[keep, ]
}
# Step 6: calculate the mean body mass for each chunk
results <- data.frame(species = character(0), mean_mass = numeric(0),
stringsAsFactors = FALSE)
for (j in seq_along(chunks)) {
chunk <- chunks[[j]]
values <- chunk$body_mass_g
values <- values[!is.na(values)]
if (length(values) > 0) {
m <- sum(values) / length(values)
} else {
m <- NA_real_
}
new_row <- data.frame(species = names(chunks)[j], mean_mass = m,
stringsAsFactors = FALSE)
results <- rbind(results, new_row)
}
# Step 7: sort, reset the row names, and print
results <- results[order(results$species), ]
rownames(results) <- NULL
print("All done! Here are the results:")
print(results)Talk with your neighbor - what does this do? (5 min)
In the Drexel paper, the LLM’s difficulty labels were consistent and confident, and they did not match how hard students found the questions. Consistent is not the same as correct.
mean(), filter(), read_csv()You will get more formal instruction on how to create a function next week.
add_tax is the name.price and rate are the inputs. rate has a default value.We will use functions in AE07