CS 212, AI Programming 1
[TOC]
Generative AI is a subset of machine learning (ML) that is used for creating new content. Generative models use neural networks to generate data based on, but different from, the data they were trained on.
graph TD
subgraph AI ["Artificial Intelligence"]
subgraph ML ["Machine Learning"]
subgraph NN ["Neural Networks"]
GenAI["<b>Generative AI and LLMs</b><br>(Creating New Content)"]
end
end
end
style AI fill:#f8f9fa,stroke:#adb5bd,stroke-width:2px
style ML fill:#e9ecef,stroke:#6c757d,stroke-width:2px
style NN fill:#dee2e6,stroke:#495057,stroke-width:2px
style GenAI fill:#d0ebff,stroke:#1971c2,stroke-width:3px,color:#1864ab
Figure: Generative AI sits within the broader fields of Neural Networks, Machine Learning, and Artificial Intelligence (Source: Wikimedia Commons, CC BY-SA 4.0).
OpenAI released a public demo of ChatGPT on November 30, 2022 that took the world by storm and suddenly generative AI was the new sensation.
A Generative Pretrained Transformer (GPT) chatbot, like ChatGPT, works by taking a prompt (often a question or instruction) as input and generating a response (an answer) based on statistical probabilities.
A Large Language Model (LLM) is an AI model built on the transformer architecture, scaled up across billions of parameters and immense amounts of text data. What makes an LLM unique compared to older, single-purpose language software is its versatility: rather than being trained for only one specific task, a single LLM can draft essays, write and debug software code, translate between languages, summarize research, and reason through conversational problem-solving out of the box.
A token is the basic unit of text that a language model reads and generates. Tokens can be whole words, subwords, or even individual characters and punctuation marks, depending on the tokenizer used.
For example, a common phrase might tokenize word-for-word, but longer, rare, or compound words are broken into smaller chunks (e.g., “unbreakable” might split into “un”, “break”, and “able”). A helpful rule of thumb for English text is that 1 token roughly corresponds to 0.75 words (or 100 tokens ≈ 75 words).
A large language model is primarily trained using self-supervised learning on vast amounts of text data from diverse sources like books, articles, code repositories, and websites.
In self-supervised pretraining, the model learns grammar, facts, and reasoning patterns simply by repeatedly predicting masked or missing next tokens without needing human labels. Training frontier models requires massive computational clusters running thousands of GPUs for weeks or months.
Self-supervised learning (SSL) is a form of machine learning where the system creates its own labels directly from raw, unlabelled data by hiding parts of the input and trying to predict them. Unlike traditional unsupervised learning, which simply looks for patterns or groupings across data without grading itself, self-supervised learning invents a prediction task with a clear right-or-wrong answer so it can automatically check its work.
After initial pretraining, models undergo fine-tuning and Reinforcement Learning from Human Feedback (RLHF). This alignment step teaches the model to behave as a safe, helpful conversational assistant rather than just an unpredictable text predictor. The result is a tool capable of generating coherent, human-like responses.1
LLM parameters are the internal numerical values that define how the network processes information. These parameters primarily consist of the weights and biases across the neural network layers, which are adjusted during training to minimize prediction error.
The number of parameters in models varies widely: compact models built to run on personal computers or phones typically have 3 to 8 billion parameters, whereas flagship frontier2 models that power tools like ChatGPT, Claude, and Gemini have 1 to 2 trillion or more parameters. (The exact numbers aren’t revealed by the companies providing these models.)
When a user submits a prompt, the trained model generates output through a process called inference.
The process of generating output is iterative:
%%{init: {"xyChart": {"width": 900, "height": 450}}}%%
xychart-beta
title "Next Token Probability: The best thing about cats is that they ..."
x-axis ["are", "purr", "make", "don't", "can", "sleep", "require", "fly"]
y-axis "Probability (%)" 0 --> 40
bar [32, 21, 14, 11, 9, 7, 5, 0.001]
The context length (or context window) of an LLM refers to the maximum number of tokens it can hold in its active memory at one time, encompassing both the input prompt and the generated response.
Early generative models like GPT-3 had a context length of 4,096 tokens, while GPT-4 initially expanded to 8,192 and 32,768 tokens. Modern frontier models feature context windows ranging from 128,000 tokens up to 1,000,000+ tokens—allowing them to analyze hundreds of pages of documentation, entire books, or extensive codebases in a single session.
Are my prompts used to train the LLM?
By default on many free consumer services, input prompts and conversations may be reviewed and used to train future iterations of the model unless users explicitly opt out in privacy settings or use enterprise/API tiers.
Is my feedback (thumbs up/down) used to train the LLM?
Yes. Thumbs up/down ratings, corrections, and alternate completions provide feedback data used in reinforcement learning (RLHF) and model alignment pipelines.
Are my prompts kept private?
Not necessarily. Cloud chatbots transmit your prompts over the internet to remote data centers. Prompts may be logged for trust and safety audits, reviewed by human evaluators, or retained in service logs. Sensitive personal data, passwords, or confidential materials should never be pasted into public AI tools.
Have current AI models attained Artificial General Intelligence (AGI)?
By most scientific standards, no. While there is debate over how to define AGI, current models are pattern-matching and probabilistic reasoning engines. They excel at specific benchmark tests, professional exams, and digital workflows, but they still lack common-sense causal reasoning, continuous real-world learning, and independent agency. Whether scaling current architectures will eventually bridge this gap or if entirely new breakthroughs are required remains one of the central debates in computer science.
How do I know if a chatbot is hallucinating?
Because models predict plausible word sequences rather than querying a verified truth database, they can confidently state incorrect facts or generate fictitious references. The only reliable way to catch a hallucination is to manually verify claims against primary sources, check provided citations independently, and test assertions when factual accuracy is critical.
Tokenizer—OpenAI. Visualizes the tokenization process.
Generative AI Exists because of the Transformer— Visual Storytelling Team and Madhumita Murgia . Financial Times. 2023
Transformer Explainer—Aeree Cho, Grace C. Kim, Alexander Karpekov, Alec Helbling, Jay Wang, Seongmin Lee, Benjamin Hoover, and Polo Chau. Georgia Institute of Technology. 2024.
How Transformers Work: A Detailed Exploration of Transformer Architecture—Josep Ferrer, DataCamp, 2024
Large language model—Wikipedia
AI’s understanding and reasoning skills can’t be assessed by current tests—Ananya, Science Direct, 2024.
Levels of AGI: Operationalizing Progress Toward Artificial General Intelligence—Morris, M. R., Sohl-Dickstein, J., Fiedel, N., Warkentin, T., Dafoe, A., Schmitt, M., et al. ACM Queue, 22(2). 2024
GPT-4—OpenAI
Microsoft Copilot with GPT-4 was used to draft parts of these notes, Gemini 4.0 Argon was used to assist with revisions.
Intro to AI lecture notes by Brian Bird, written in 2024, revised in , are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
LLMs don’t actually “understand” text in the way humans do. Instead, they analyze and process text based on patterns they have learned from training data. They are sophisticated tools that excel at mimicking human-like text but do not possess genuine understanding, comprehension or awareness. ↩
A frontier model is an AI system at the leading edge of current capabilities, trained on the largest scale of compute and data to deliver state-of-the-art performance across broad reasoning, coding, and problem-solving tasks. ↩