LLM Basics
Complete learning notes
1. Introduction
Large Language Models (LLMs) are, at the time of this course's writing, one of the most prominent and rapidly evolving applications of everything you've learned in this module — Neural Networks (Topic 2), the Transformer architecture (Topic 6), and Generative AI (Topic 7) all come together directly in how LLMs work. This topic builds a clear, honest, foundational understanding of what LLMs actually are and how they behave.
2. What is an LLM?
Term: Large Language Model (LLM)
Simple definition: An LLM is a very large neural network (built on the Transformer architecture, Topic 6) trained on enormous amounts of text, capable of understanding and generating human-like language.
In simple words: It's a system that has "read" a staggering amount of text — books, articles, websites, code — and learned the statistical patterns of language well enough that it can carry on a conversation, answer questions, write text, and even generate code, all by predicting what text should plausibly come next, one piece at a time.
Technical explanation: LLMs are Transformer-based (Topic 6) generative models (Topic 7) with billions (or more) of parameters, trained via pretraining — learning general language patterns from massive, broad text datasets by repeatedly predicting the next word/token in a sequence — often followed by fine-tuning on more specific, curated data (and sometimes further refined via human feedback) to improve their usefulness, helpfulness, and safety for specific applications like conversational assistants.
3. Why is it Important?
- LLMs power the conversational AI assistants that have rapidly become part of daily life and work for hundreds of millions of people.
- Understanding LLMs' basic mechanics — and honestly, their limitations — is essential for using them effectively and responsibly.
- This topic represents the practical culmination of nearly everything covered in this module: neural networks, Transformers, and generative AI, all combined at massive scale.
4. Prerequisites
Comfort with Neural Networks (Topic 2), NLP (Topic 6, especially the Transformer architecture), and Generative AI (Topic 7).
5. Core Concepts
- Tokens — the basic unit LLMs process
- Pretraining and fine-tuning
- Prompting — how users interact with LLMs
- Key limitations: hallucination and knowledge cutoffs
6. Detailed Explanation
a) Tokens
Term: Token
Simple definition: A token is a small chunk of text — often a word, part of a word, or a punctuation mark — that an LLM processes as its basic unit (directly connecting to the subword tokenization concept from Topic 6).
In simple words: Rather than reading a sentence letter by letter or purely word by word, an LLM breaks text into these convenient chunks first, then works with sequences of tokens as numbers (via embeddings, Topic 6).
b) Pretraining and Fine-Tuning
Term: Pretraining
Simple definition: The initial, massive-scale training phase where an LLM learns general language patterns by repeatedly predicting the next token in enormous amounts of text.
In simple words: Imagine reading an almost unimaginable amount of text and, after each sentence, covering up the next word and guessing what it probably is — then checking your guess and adjusting your understanding slightly, repeated billions of times. That's essentially pretraining.
Term: Fine-tuning
Simple definition: A subsequent, more targeted training phase where a pretrained model is further adjusted on smaller, more specific or carefully curated data — often including human feedback — to make it more helpful, safe, and aligned with how it's actually meant to be used (e.g., as a conversational assistant).
c) Prompting
Term: Prompt
Simple definition: The text input a user provides to an LLM, which the model uses as the starting context for generating its response.
In simple words: It's essentially the "question" or "instruction" you give the model — and how you phrase it (how much detail, what format you request, what examples you provide) can meaningfully affect the quality and relevance of what you get back, a skill often called "prompt engineering."
d) Key Limitations: Hallucination and Knowledge Cutoffs
Term: Hallucination
Simple definition: When an LLM generates text that sounds fluent and confident but is factually incorrect or entirely made up.
In simple words: Since an LLM is fundamentally predicting plausible-SOUNDING text (Topic 7's generative principle) rather than looking up verified facts from a database, it can sometimes state incorrect information with the same fluent confidence as correct information — this is a genuine, actively-studied limitation, not a rare edge case.
Term: Knowledge Cutoff
Simple definition: The point in time after which an LLM has no direct knowledge of events, since its training data was collected up to a specific date.
In simple words: An LLM only "knows" what was in its training data — anything that happened after that data was collected is something it simply cannot know about directly, unless given that information as part of the current conversation (e.g., via a search tool).
7. How It Works
- Input text is broken into tokens.
- Each token is converted into a numeric embedding (Topic 6).
- The Transformer architecture processes the entire sequence of embeddings, using attention to understand relationships between tokens.
- The model predicts a probability distribution over what the NEXT token is likely to be.
- A token is selected (based on this probability distribution), added to the sequence, and the process repeats — generating text one token at a time until a complete response is formed.
8. Real-World Example
When you ask an LLM-based assistant a question, it doesn't "look up" an answer in a database the way a search engine might. Instead, based on everything it learned during pretraining and fine-tuning, it generates a response one token at a time, each token chosen because it's statistically likely to plausibly continue the conversation given everything said so far — which is why it can sometimes produce wrong information with just as much apparent fluency and confidence as correct information (hallucination), and why it's essential to verify important factual claims independently.
9. Advantages
- Capable of understanding and generating remarkably fluent, contextually appropriate language across an enormous range of topics and tasks.
- A single well-trained LLM can perform many different tasks (writing, summarizing, coding, answering questions) without needing separate specialized models for each.
- Continues to improve rapidly as training techniques, data, and computational scale advance.
10. Limitations
- Hallucination — can generate fluent but factually incorrect content, requiring independent verification for important claims.
- Knowledge cutoff — has no direct knowledge of events after its training data was collected.
- Requires enormous computational resources to train, limiting who can practically build these systems from scratch.
- Can reflect and potentially amplify biases present in its training data.
11. Common Mistakes
- Trusting LLM-generated factual claims (especially specific numbers, dates, or citations) without independent verification.
- Assuming an LLM "knows" about very recent events beyond its training data's knowledge cutoff.
- Confusing an LLM's fluent, confident tone with actual certainty or correctness — these are not the same thing.
12. Best Practices
- Verify important factual claims from an LLM independently, especially for high-stakes decisions.
- Be aware of and account for the model's knowledge cutoff when asking about recent events.
- Provide clear, detailed prompts (Topic 8's core skill) to get more useful, relevant responses.
- Understand that an LLM is a powerful pattern-completion tool, not an infallible oracle.
13. Real-World Applications
- Conversational AI assistants for answering questions, drafting content, and coding help.
- Automated summarization of long documents.
- Language translation and writing assistance.
- Customer service chatbots handling a wide range of inquiries.
14. Interview-Oriented Points
- Be ready to explain what a token is and how pretraining works at a high level.
- Understand the difference between pretraining and fine-tuning.
- Be able to explain hallucination and knowledge cutoffs as genuine, important limitations, not minor technicalities.
15. Exam-Oriented Points
- LLMs are large, Transformer-based generative models trained via pretraining (predicting the next token on massive text data) and often fine-tuned further.
- Tokens are the basic text units LLMs process; prompts are the user's input guiding generation.
- Key limitations: hallucination (fluent but incorrect output) and knowledge cutoffs (no awareness of events after training data collection).
16. Comparison Table — Pretraining vs Fine-Tuning
| Aspect | Pretraining | Fine-Tuning |
|---|---|---|
| Data scale | Enormous, broad, general text data | Smaller, more specific/curated data |
| Goal | Learn general language patterns and knowledge | Adapt the model for specific, helpful, safe use (e.g., as an assistant) |
| Computational cost | Extremely high | Lower than pretraining, though still significant |
| Typically done by | Only large organizations with massive resources | Sometimes by smaller teams, building on an existing pretrained model |
17. Quick Revision
- LLMs are large Transformer-based models trained to predict the next token, enabling fluent language understanding and generation.
- Pretraining learns general language patterns from massive data; fine-tuning adapts the model for specific, safe, helpful use.
- Prompts are the user's input guiding what the model generates.
- Key limitations: hallucination (confident but incorrect output) and knowledge cutoffs (no awareness of post-training-data events) — always verify important facts independently.