1.01 – What are LLMs? | AI Course

🧠 1.01 – What are LLMs?

📑 On this page

🤖 What are LLMs?

📌 Definition

Large Language Models (LLMs) are AI models trained on massive amounts of text data to understand, generate, and manipulate human language. They predict the next word in a sequence based on the context of previous words.

💡 Simple Analogy

Think of an LLM as an extremely advanced autocomplete. When you type "The capital of France is..." an LLM predicts "Paris" based on patterns it learned from millions of texts.

Popular examples:

⚙️ How do LLMs work?

📌 The Transformer Architecture

LLMs are built on a neural network architecture called the Transformer (introduced by Google in 2017). Key innovation: self-attention – the model learns which words in a sentence are most relevant to each other.

🧠 Simplified Mental Model
Input: "The cat sat on the ___"
        
Step 1: Break into tokens (words/subwords)
Step 2: Apply attention (which words matter?)
Step 3: Predict probability distribution over all possible next tokens
Step 4: Select the most likely completion → "mat"
TermMeaning
TokenA piece of text (word, part of word, or character). GPT-4 uses ~2-3 tokens per word on average.
Context WindowHow many tokens the model can "see" at once. GPT-4 Turbo: 128k tokens (~300 pages of text).
ParametersTrainable weights in the neural network. GPT-3: 175 billion.
TemperatureControls randomness. Low (0.1) = deterministic/predictable. High (0.9) = creative/unpredictable.

📚 Training vs. Inference

📌 Two Main Phases
🔄 Training Pipeline Summary
1. Pre-training: Learn from huge internet corpus (unsupervised)
   ↓
2. Fine-tuning: Train on human-created examples (supervised)
   ↓
3. RLHF: Reinforcement Learning from Human Feedback (align with preferences)

⚠️ Limitations of LLMs

⚠️ Important Limitations to Understand

📊 Popular LLMs Comparison

ModelCompanyContext WindowMultimodalOpen Source
GPT-4 TurboOpenAI128k tokensYes (vision)No
Claude 3 OpusAnthropic200k tokensYes (vision)No
Gemini 1.5 ProGoogle1M tokensYes (native)Limited
Llama 3 70BMeta8k tokensNoYes
Mixtral 8x7BMistral32k tokensNoYes

✍️ Exercises

Exercise 1.01.1 – Check your understanding

Answer the following questions in your own words:

  1. What does LLM stand for and what do these models do?
  2. Explain the difference between training and inference.
  3. What is a "hallucination" in the context of LLMs?
  4. What is the purpose of the "temperature" parameter?
Sample Answers:
1. Large Language Model – AI models trained on massive text data to understand and generate human language.
2. Training = learning patterns from data (expensive, one-time). Inference = using the trained model to generate responses (cheap, repeated).
3. When the model confidently produces false or nonsensical information that isn't based on training data.
4. Temperature controls randomness: low = deterministic/predictable, high = creative/unpredictable.
Exercise 1.01.2 – Hands-on exploration

Choose an LLM (ChatGPT, Claude, or Gemini) and ask it:

Prompting Tips:
For best results, be specific: "Explain your knowledge cutoff date and what that means for users."
Most LLMs will honestly describe their limitations when asked directly.
Exercise 1.01.3 – Research task

Research and write a one-paragraph explanation of the "Transformer architecture" and why it was revolutionary.

Key Points to Include:
- Introduced in 2017 by Google in "Attention Is All You Need"
- Replaced RNNs (recurrent neural networks)
- Key innovation: self-attention mechanism that processes all words in parallel
- Enabled training on much larger datasets (hence "Large" language models)
- Foundation for GPT, BERT, and all modern LLMs
📌 Key Takeaways
📘 Next Module: 1.02 – API Basics →