Skip to main content
AmigoFish

How AI Chatbots Work: LLMs, Tokens & Hallucination | Stanford CS193T Lecture 1 with Cynthia Bailey

From Stanford Online · · 1 hr 12 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.

If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.

Watch on YouTube

Not rated yet

Description

Explore AI courses and programs from Stanford Online: https://stanford.io/4BYTekh

What's happening when you chat with an AI? In this Stanford CS193T: Thinking with AI lecture recording, Senior Lecturer Cynthia Bailey demystifies large language models from the ground up: tokens, neural networks, weights and layers, and the two-stage journey from training to inference that turns raw text into a working chatbot. She introduces the concepts (context windows, transformers, attention) that explain both what makes modern AI so capable and why it still confidently gets things wrong, including hallucination, sycophancy, and the pull to anthropomorphize a fundamentally statistical tool. No coding or technical background required: by the end, you'll have a working mental model for what AI can and can't do.

Key questions answered in this lecture recording: Q: What is the definition of AI? A: Bailey argues AI is inherently ill-defined: it has meant whatever computers do that amazes us, from arithmetic in the 1950s to chess to today's text and video generation. In CS193T, AI means LLMs and multimodal generative AI.

Q: How does a large language model generate text? A: An LLM is a statistical fingerprint of how language is used across huge amounts of text; it repeatedly predicts the next token from your prompt plus the response so far until the reply is finished.

Q: Does ChatGPT learn from my conversations? A: Not in the sense of changing its weights: once training ends, the weights are fixed and shared by everyone. A chat seems to adapt because the model responds to what is in your context window.

Q: Why do AI chatbots hallucinate? A: Picking the most probable next word produces text that sounds normal, not text that is true. The same ability to generalize to unseen input that makes LLMs powerful means hallucination will always be a risk.

Q: Is 'hallucination' the right word for AI errors? A: Bailey notes the term is contested because it anthropomorphizes AI, making a statistical tool seem human. Alternatives include confabulation and fact fabrication, though some of those also come from describing human behavior.

Q: What is a context window in AI? A: It is the input the model processes for each prediction, with a maximum size set by the vendor (roughly 200,000 to 10 million tokens at top companies). Bailey says to treat it as a large but finite resource you actively manage.

Chapters: 0:00 Course overview: context engineering 1:10 Meet instructor Cynthia Bailey 5:55 What is AI? A moving target 8:59 LLMs, multimodal and generative AI defined 12:58 Next-token prediction: fill-in-the-blank demo 18:16 Inside a neural network: nodes and concepts 23:16 Weights, parameters and deep learning 28:58 How AI models are trained 33:38 Pre-training, data centers and GPUs 36:58 Fine-tuning and RLHF 39:31 Inference and student Q&A 45:38 Why context matters and transformers 52:25 The context window as a finite resource 54:58 Explainability, hallucinations, anthropomorphism

About the speaker: Cynthia Bailey is a Senior Lecturer in the Computer Science Department at Stanford University. In 2023-2024, she served as an AI Policy Fellow in the United States Senate through the American Association for the Advancement of Science (AAAS). Her scholarship focuses on computer science education, AI/machine learning, and the social impacts of technology, including creating courses such as Equity and Governance for Artificial Intelligence and Race and Gender in Silicon Valley. Her teaching and research awards include the Lloyd W. Dinkelspiel Award for exceptional contributions to undergraduate education at Stanford, the Lasting Impact Award from the International Computing Education Research conference, a "Top 10 Papers of All Time" award at the 50th anniversary of the ACM SIGCSE Technical Symposium, and the Stanford Society of Women Engineers' Professor of the Year. She has consulted for Apple, NASA, law firms, and machine learning startups. She holds a Ph.D. in…

Back to Stanford Online · Report a problem