Large Language Models (LLMs)
Large Language Models (LLMs) are Transformer-based (previous lesson) language models (recall the definition from Unit 2) scaled up to billions or trillions of parameters and trained on enormous text corpora — producing systems capable of fluent generation, reasoning, translation, summarization, and conversation, often with little or no task-specific training.
From N-grams to LLMs — The Full Arc of This Course
Every model in this progression estimates P(next word | previous words) — exactly the language modeling objective introduced in Unit 2 — but each step captures longer, richer context more effectively than the last.
What Makes a Language Model "Large"?
| Dimension | Small statistical LM (Unit 2) | LLM |
|---|---|---|
| Parameters | Just word/n-gram counts | Billions to trillions of learned weights |
| Training data | A modest text corpus | Trillions of words from books, web text, code |
| Context length | 1-2 previous words (n-gram) | Thousands to millions of tokens |
| Capability | Predicts next word statistically | Generation, reasoning, summarization, translation, code, conversation |
How LLMs Are Trained — Two Key Stages
- Pre-training — the model is trained on massive unlabeled text to predict the next token (or masked tokens), learning grammar, facts, and reasoning patterns purely from raw text — an extension of the language modeling task from Unit 2 at enormous scale.
- Fine-tuning / alignment — the pre-trained model is further trained on smaller, curated datasets (often with human feedback — RLHF) to follow instructions, be helpful, and avoid harmful outputs.
Using an LLM API for NLP Tasks (Conceptual Example)
# Example structure of calling an LLM for a downstream NLP task --
# note this single call can replace an entire classical pipeline
# (Units 1-3: preprocess -> TF-IDF -> Naive Bayes) for many use cases.
prompt = """
Classify the sentiment of this review as Positive, Negative, or Neutral.
Review: "The camera is great but the battery drains too fast."
"""
# response = llm_client.generate(prompt)
# print(response)
# -> "Mixed/Neutral: positive about the camera, negative about battery life."
LLMs vs the Classical NLP Pipeline Covered in This Course
| Task | Classical approach (this course) | LLM approach |
|---|---|---|
| Tokenization | NLTK/regex word tokenizer (Unit 1) | Subword tokenization (e.g. Byte-Pair Encoding) built into the model |
| POS tagging / NER (Unit 2) | HMM/CRF trained on tagged corpora | Zero-shot or few-shot prompting, no task-specific training needed |
| Sentiment analysis (Unit 3) | TF-IDF + Naïve Bayes, needs labeled training data | Prompt the LLM directly, often with zero labeled examples |
| Summarization (Unit 3) | Extractive TF-IDF/TextRank scoring | Native abstractive generation |
| Translation | Statistical phrase-based MT | Native multilingual generation |
Why the Classical Pipeline Still Matters
Even with powerful LLMs available, the foundations in this course remain essential: preprocessing (Unit 1) is still needed to clean data feeding into any pipeline; understanding tokenization, embeddings, and attention (this unit) is necessary to debug, fine-tune, or optimize LLM-based systems; and classical models (Naïve Bayes, TF-IDF) remain the right choice for lightweight, fast, interpretable, low-resource use cases where a full LLM is unnecessary or too costly.
Limitations of LLMs to Be Aware Of
| Limitation | Description |
|---|---|
| Hallucination | Generating fluent but factually incorrect text |
| Cost/latency | Much more compute-intensive than classical models (Unit 3) for simple tasks |
| Bias | Can reflect biases present in training data |
| Context window limits | Even "long context" LLMs have a maximum input length |
| Lack of true reasoning guarantees | Can fail at tasks requiring precise logic or up-to-date facts unless augmented (e.g. retrieval-augmented generation) |
LLMs represent the current state of the art built directly on every concept in this course — n-gram language modeling (Unit 2), word embeddings (this unit), and the Transformer architecture (previous lesson). The final lesson surveys the real-world applications these techniques power.