CS 162: Natural Language Processing
Saadia Gabriel
Lecture 8:
Language Modeling Part 5
Announcements
Quiz #3
https://forms.gle/MxUjCaDb3rEeceau5
The weights are the same (same transformation of the input), but the resulting query, word and value vectors are word-specific.
Increasing the complexity of the network usually improves performance because more information can be captured (same rationale for why we use multiple, varying numbers of attention heads).
Yes, efficient NLP is a whole area of research which you can explore for your final project! Often components or entire layers can be removed for certain tasks (pruning), or a smaller model can be trained to mimic the behavior of a larger model (knowledge distillation).
You can also reduce the precision of numbers used to store the model’s parameters (quantization) to save memory.
Computational Limitations of Self-attention
Good question. BPE is used in most modern models, though there are now a number of tokenization variations and some may use a variation.
On a side note, you can use the tiktoken package to see how GPT models will tokenize an input prompt.
Saadia is teaching a class right now.
Sa
adia
is
teaching
a
class
right
now
.
Sparse attention, key-value caching and other modifications allow us to have longer context sizes.
Goals of This Lecture
Following slides courtesy of Violet Peng and Jia-Chen Gu
Residual Connections
Residual Connections
Say we want to do movie review classification with our transformer.
Should we train from scratch on our labeled movie review dataset?
Language Model
The Illustrated GPT-2, https://jalammar.github.io/illustrated-gpt2/
Word Embeddings
Contextualized Representations
The Pre-train
Fine-tune Paradigm
Image from Gu et al. (2020)
Why Pre-training?
The Pretraining Revolution
Scale Unsupervised Learning and Generalize
Parametric knowledge
acquisition
Pre-training Model Architectures
Jacob Devlin, et al. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. NAACL 2018.
Unidirectional Pre-training
GPT Pre-training and Fine-tuning
GPT Architecture
https://jalammar.github.io/illustrated-gpt2/
GPT Technical Details
Fine-tuning GPT for Downstream Tasks
GPT for Natural Language Inference (Entailment)
GPT Results on NLI
Effect of Pre-training in GPT
Effect of Pre-training in GPT
You don’t even have to fine-tune! Tasks can be performed “zero-shot” meaning the task instructions are specified in natural language at test-time in a prompt:
Effect of Pre-training in GPT
Stronger GPT-2
Actually 124M, this was an error in the original release
GPT-2 Results
Stronger GPT-3
https://ourworldindata.org/grapher/artificial-intelligence-training-computation
GPT-3 with In-context Learning
GPT-3 with In-context Learning
Independently Bidirectional Pre-training
ELMo Technical Details and Results
Limitations of ELMo and GPT series
Elmo: Shallow bi-directionality
GPT: no bi-directionality
Bidirectional Pre-training
Masked Language Models
Next Sentence Prediction
BERT was also trained on a next sentence prediction objective to improve its capabilities for capturing long-range dependencies.
Next Sentence Prediction
BERT performance with/without next sentence prediction (NSP)
Devlin et al. (2019)
BERT Input Representation
BERT Technical Details
BERT Fine-tuning
BERT Results
Extension of BERT
Domain-specific BERTs
Extension of Pre-training Encoder-Decoders
Resources for Coding
Scaling Laws
Scaling Laws
*** Discuss ***
Does it matter how we scale our LLMs?
Scaling Laws
Large Language Models and Beyond
Image from https://blogs.cfainstitute.org/investor/2023/05/26/chatgpt-and-large-language-models-six-evolutionary-steps/
Many components of LLM development have been scaling up….
Training LLMs: Data
Training LLMs: Context Size
Next Time…
Post-training
LLM Hallucination
Why does this happen and what can we do about it?
In general, LLM Safety
Lecture Take-aways