NLP Study Notes (3): Pretrained Models and Large Language Models
Friday, June 5, 2026 / , ,
Before reading this article, you may want to read the following articles first to better understand the context.
AI TranslationSimplified ChineseEnglish
Summary:
NLP study notes from the University of Melbourne's COMP90042: GPT, BERT, T5 and RLHF, plus prompting, instruction tuning, PEFT and LoRA.
These are my notes from COMP90042, the NLP course I took at the University of Melbourne. This installment covers pretrained models and large language models, including GPT, BERT, T5, RLHF, prompting, instruction tuning, PEFT and LoRA.
1. Pretrained models: GPT / BERT / T5
1.1 What is a pretrained model?
1.2 GPT (Generative Pre-trained Transformer)
GPT-1 (2018)
Training and model details
Item
Details
Subword tokenization
Byte-Pair Encoding (BPE)
Size
12-layer Transformer, 117M parameters
Pretraining corpus
BookCorpus
Corpus characteristics
Contains 7,000 distinct books in a variety of styles, providing large amounts of continuous text (making long-range dependencies easier to learn)
Adapting to downstream tasks
Fine-tuning example: sentiment classification
W_y, using the final word's outputh_nas input:P(y\mid x) = \text{softmax}(h_n W_y)= -\log(0.4)(when the model assigns a probability of only 0.4 to positive)Fine-tuning example: question answering
GPT results: GLUE and other benchmarks
Benchmark
Task type
MNLI, RTE
Textual entailment
QQP, STS-B, MRPC
Sentence similarity
QNLI
Answerability prediction
SST-2
Sentiment analysis
CoLA
Sentence acceptability
1.3 BERT (Bidirectional Encoder Representations from Transformers, 2018)
Key distinction: it uses bidirectional self-attention.
Pretraining objective: masked word prediction (masked language modeling, MLM)
Training and model details
Item
Details
Subword tokenization
WordPiece
BERT-base
12-layer Transformer, 110M (110 million) parameters
BERT-large
24-layer Transformer, 340M (340 million) parameters
Pretraining corpus
Wikipedia + BookCorpus
Training cost
Multiple GPUs and several days of training
Adapting to downstream tasks
P(y \mid x) = \text{softmax}(h_{[\text{CLS}]} W_y)Example: spam detection
BERT results: the original paper achieved leading results at the time on language understanding benchmarks such as GLUE and SQuAD. These comparisons concern specific datasets, models and experimental settings.
Encoder
1.4 Decoder and encoder–decoder
Decoder
Encoder–decoder
Comparing the three architectures
Architecture
Examples
Attention
Strengths
Encoder-only
BERT
Bidirectional
Classification, extractive QA, sequence labeling
Decoder-only
GPT family, LLaMA
Unidirectional (causal)
Generation, few-shot learning, dialogue
Encoder-Decoder
T5, BART, original Transformer
Bidirectional encoding + unidirectional decoding + cross-attention
Seq2seq tasks such as translation and summarization
1.5 T5 (Text-to-Text Transfer Transformer, 2019)
Pretraining objective: span corruption
Other possible objectives: a comparison
Objective
Example
Description
Prefix language model (prefix LM)
cows love to → eat grass
Given a prefix, predict what follows (similar to GPT, but implemented with an encoder–decoder)
Masked language model (masked LM)
cows <M> <M> eat grass → cows love to eat grass
Randomly mask words and predict them (similar to BERT)
Shuffling (word-order corruption)
grass cows to love eat → cows love to eat grass
Shuffle the word order and train the model to restore it
Drop tokens (token deletion)
cows love grass → cows love to eat grass
Delete some input words and train the model to reconstruct the complete original text
Pretraining corpus: filtered C4 (Colossal Clean Crawled Corpus)
Fine-tuning
T5 results
Item
Details
Model sizes
small (60M), base (220M), large (770M), 3B, 11B
GLUE
A benchmark containing nine language understanding tasks
CNN/DM
Summarization
WMT
Machine translation
Conclusion
The largest version achieved leading results at the time on several benchmarks evaluated in the paper; this does not imply human-level general language ability
2. Large language models and RLHF
2.1 What is an LLM?
A large language model (LLM) generally refers to a large model pretrained on substantial amounts of text; there is no universally agreed parameter threshold. This section focuses on Transformer models and their zero-shot generalization, in-context learning and instruction-following abilities.
The development of these methods can be summarized as: statistical language models → neural language models → whole-model pretraining → scaling models and data → instruction tuning and preference alignment. Word2Vec is a method for word representations, and should not be equated with a complete language model; scaling and alignment are also distinct.
2.2 Generative Pre-trained Transformers and emergent abilities
The role of pretraining and fine-tuning in NLP: pretraining can improve downstream task performance through parameter initialization.
Model
Parameters
Layers
Dimension
Training data
Training approach
GPT-1
117M
12
768
BookCorpus (~1B words)
Self-supervised pretraining + supervised fine-tuning
GPT-2
1.5B
48
1600
WebText (~10B words)
Self-supervised pretraining
GPT-3
175B
96
12288
A mixture of Common Crawl, WebText, books and Wikipedia
Self-supervised pretraining
GPT-2's emergent ability: zero-shot learning
GPT-3 and in-context learning
Traditional fine-tuning vs In-context Learning
Aspect
Traditional Fine-tuning
In-context Learning
Parameters
Model parameters must be updated
No parameters are updated
Data
Many labeled examples are required
Only a few demonstrations are needed (possibly none)
Process
Pretrain → fine-tune separately for each task → deploy multiple models
One model + different prompts
Cost
Training and storage for each task
Higher inference cost with long prompts, but no training cost
Limitations of in-context learning
2.3 InstructGPT and RLHF (Reinforcement Learning from Human Feedback)
Overall idea: collect human demonstrations and preferences, then use supervised learning and reinforcement learning to adjust model behavior. The following example uses the three-stage process published in the InstructGPT paper. It also helps explain the training ideas behind ChatGPT, but InstructGPT's data volumes and model configurations should not be treated as ChatGPT's complete training details.
Step 1: supervised fine-tuning (SFT)
1. Collect high-quality data
2. Fine-tune the pretrained model
Step 2: reward model (RM)
1. Generate outputs
2. Human ranking
3. Train the reward model
Step 3: proximal policy optimization (PPO)
1. Sample a prompt: sample a prompt from the dataset, such as "Write a story about Melbourne." The paper's PPO dataset contains about 31,000 prompts; this stage does not require a human demonstration answer for each prompt;
2. Generate a response: generate text with the current policy model. The policy is initialized from the SFT model and then updated by PPO during training iterations; its parameters are not updated on the fly every time it responds to a user;
3. Compute the reward: the reward model trained in Step 2 evaluates the generated output and returns a scalar reward;
4. Update the policy: use the reward to update the policy with the PPO algorithm.
Additional constraint: training adds a KL penalty relative to the SFT reference model to limit policy drift and mitigate problems from overoptimizing the reward model. This does not guarantee that all reward hacking is eliminated.
Adapting for dialogue
Dialogue models also need data and evaluation for formats such as multiturn conversations, addressing context continuity, refusal of inappropriate requests and format compliance. These are choices of training objectives and data design, rather than a fixed "fourth step" in the three-stage process above.
References: InstructGPT paper.
2.4 Other LLMs: LLaMA
LLaMA (Large Language Model Meta AI)
This refers to the first generation of LLaMA, released in 2023 with model sizes ranging from 7B to 65B parameters.
References: LLaMA paper.
2.5 Three core LLM abilities
Ability
Meaning
Example
In-context learning
Adapt to a task using instructions, examples and information in the current input, without updating model parameters; memory across sessions requires additional system mechanisms
Perform a new task after seeing two examples
Step-by-step reasoning
Break a complex problem into smaller steps
Mathematics, programming, logical reasoning
Instruction following
Follow the user's explicit instructions, serving as an effective tool for a range of tasks
Write an email to specification, generate steps from a recipe, execute a sequence of commands in a software environment
3. Prompting and chain of thought
3.1 Zero-shot and few-shot in-context learning
Setting
Number of examples
Description
Zero-shot
0
Only an instruction, such as "Translate to French: cheese"
One-shot
1
One example
Few-shot
Several
Several examples, typically improving performance
3.2 Limitations of prompting
Failure example: standard prompting
The incorrect answer in this example fails to compute
23-20+6correctly; 27 cannot be explained as23+6, because the latter equals 29.Alternative: change the prompting style ✅ (using CoT, described next).
3.3 Chain-of-thought prompting (CoT)
Definition: provide intermediate reasoning steps in examples, or prompt the model to generate such steps before the final answer. The original paper observed improvements on various arithmetic, commonsense and symbolic reasoning tasks, but intermediate steps are not guaranteed to be correct.
Comparison
Approach
Prompt
Output
Standard Prompting
Only questions and answers
The answer is 27 ❌
Chain-of-Thought Prompting
Guide the model through reasoning step by step
The answer is 9 ✅
Example
3.4 Emergent properties of model scale
3.5 Two CoT variants
Zero-shot CoT
Advantages
Disadvantages
No manually constructed examples are needed
Reasoning quality depends on the model itself and is less stable
Manual CoT
Advantages
Disadvantages
Explicitly demonstrates the desired reasoning format; effectiveness depends on how well the examples match the task
Examples must be manually constructed and checked; their errors may also be imitated
3.6 Additional dataset notes
3.7 Prompt injection and jailbreaking
3.8 Advantages and disadvantages of in-context learning
Pros
Cons
4. Instruction tuning
4.1 Scaling up fine-tuning: the traditional two-stage paradigm
Step 1: pretraining
Item
Details
Approach
Use large amounts of text (books, Wikipedia, etc.) for self-supervised learning
Model
BERT and others
Datasets
Wikipedia and others
Objective
Predict masked words (language modeling)
Step 2: fine-tuning
Item
Details
Approach
Use a labeled dataset for supervised learning
Model
The model pretrained in Step 1
Datasets
For example, spam messages and their labels
Objective
Train a classifier for a specific task, such as spam detection
4.2 Instruction tuning
Definition: instruction fine-tuning is supervised fine-tuning (SFT) on instruction data that describes tasks in natural language. It is one form of post-training, which can also include preference optimization and other steps; these terms are not fully synonymous.
(x, y), pairs: a natural-language instruction and its desired response;SFT details
4.3 Alpaca (Stanford Alpaca)
Result: in the authors' preliminary, small-scale, single-turn instruction-following evaluation, Alpaca 7B performed similarly to text-davinci-003. This does not establish equivalence across all tasks, safety or reliability.
Training process
Step 1: seed generation (Self-Instruct)
Step 2 – Fine-tuning
References: Stanford Alpaca project description.
4.4 The T5 perspective: pretraining and multitask training
Approach: pretrain first, then fine-tune on multiple specific tasks (Tasks A, B, C…) and evaluate on those same tasks.
A trend in newer language models: GPT-3 and LLaMA
4.5 Three paradigms: pretrain–fine-tune, prompting and instruction tuning
Paradigm
Examples
Steps
Characteristics
Pretrain–Finetune
BERT, T5
Pretrained LM → fine-tune on Task A → inference for Task A
Train a dedicated model for each task; usually requires many task-specific examples
Prompting
GPT-3
Pretrained LM → few-shot prompting or prompt design → Task A
No parameter updates, enabling flexible use; sensitive to prompts, with performance depending on prompt quality
Instruction Tuning
FLAN
Pretrained LM → instruction-tune using natural-language instructions across multiple tasks → generalize to a new Task A
Language instructions teach the model to perform multiple tasks and generalize to unseen tasks
4.6 FLAN (Instruction Fine-Tuning)
Core approach: collect examples of (instruction, output) pairs spanning multiple tasks and fine-tune a language model.
Task setup
Item
Details
Task type
12 types (including classification and generation)
Datasets
62
Constructing unseen tasks
Tasks in the same cluster must appear in either the training or test set, never both (preventing leakage between related tasks and testing generalization)
Templates
For each task, manually create multiple templates to increase instruction diversity
Results: after instruction tuning, zero-shot FLAN's performance on three unseen task types, compared with zero-shot and few-shot GPT-3, improved substantially.
Generalization to new tasks
Scaling the number of tasks: later FLAN versions
Item
Number
Scale of expansion
Later work expanded instruction tuning to about 1.8K tasks and examined the effects of model scale and CoT data
Held-out tasks
Excluded from fine-tuning and used to test generalization
Other findings
References: Original FLAN, Scaling Instruction-Finetuned Language Models.
4.7 Benefits and limitations
Benefits
Limitations
4.8 Discussing capabilities and limitations
Fluent text does not mean reliability and generalization have been solved. The following distinguishes research observations from broader conclusions.
Topic
Key points
Facts and planning
Models can assist with writing, but may also fabricate facts or propose infeasible plans. Instruction tuning and human feedback provide no guarantee of correctness; specific abilities require empirical evaluation
Self-correction
Research finds that, in certain reasoning settings without external feedback, merely asking a model to check and revise its answer may fail to improve accuracy and can even turn a correct answer into an incorrect one. This does not establish that all correction methods using tools or verifiers are ineffective
Reversal Curse
In some experiments, a model trained on "A is B" failed to answer the corresponding "B is A" query automatically. Fitting one form of expression does not necessarily produce generalization to its reverse; this does not mean every natural-language relation is directly reversible
References: Large Language Models Cannot Self-Correct Reasoning Yet, The Reversal Curse.
5. Parameter-efficient fine-tuning and LoRA
5.1 Why PEFT?
PLM and LLM: the former emphasizes pretraining, the latter scale. They are not mutually exclusive categories, and there is no universal parameter boundary. This section asks how to reduce task adaptation costs as models grow.
Fine-tuning becomes more expensive as models grow
Larger models bring greater costs and risks for full fine-tuning:
Issue
Description
Scalability
High computational cost (a complete model copy must be stored for each task)
Training instability
For example, overfitting and gradient interference
Catastrophic forgetting
After fine-tuning on a new task, the model loses its original general abilities
In-context learning and fine-tuning are complementary forms of adaptation. ICL requires no parameter updates, but still has limitations:
Limitation
Description
Inefficiency
Each inference must process the entire prompt again (long prompts are costly)
Performance
Prompting alone may not meet the target task's performance needs; comparisons with fine-tuning require the same settings
Sensitivity
Prompt wording, example order and similar choices can make performance highly sensitive
Lack of clarity
Success with one prompt does not establish stable generalization to other inputs and prompts
→ This motivates a shift from fine-tuning to parameter-efficient fine-tuning.
5.2 Historical context
5.3 Fine-tuning only some parameters
1. Full fine-tuning is difficult for large models
2. State-of-the-art models are heavily overparameterized
3. PEFT can approach full fine-tuning performance
5.4 Modular and compositional representations
a) Models are increasing in size
b) Unseen scenarios
c) Catastrophic interference
d) Efficient model updates
5.5 Architecture overview: three computation functions
PEFT methods can be grouped into three ways of modifying a frozen pretrained model:
Type
Approach
Examples
Addition-based
Attach small trainable modules to the model
Adapter, Prefix Tuning, Prompt Tuning
Selection-based
Select a subset of parameters or sparse updates to train
BitFit (bias terms only), Diff Pruning
Reparameterization
Learn low-rank or compressed changes to the weights
LoRA, Compacter
5.6 Sparse subnetworks and pruning
Sparsity is related to parameter-efficient adaptation, but ordinary pruning is not equivalent to PEFT.
Sparse subnetworks
5.7 LoRA (Low-Rank Adaptation)
Core idea
W; instead, learn only its change\Delta W:W' = W + \Delta W\Delta W = B \cdot AThe commonly used scaling factor
\alpha/ris omitted here to emphasize the structure of the low-rank update.What does "low-rank" mean?
Wis the original weight matrix; it need not itself be full-rank;r \ll d.Efficiency: counting parameters
Whas shape1024 \times 1024(a total of 1,048,576 ≈ 1 million parameters);A\,(r \times d)andB\,(d \times r), wherer \ll d;d = 1024,\ r = 8:A:8 \times 1024,B:1024 \times 82 \times 1024 \times 8 = \mathbf{16{,}384}1 - \frac{16{,}384}{1{,}048{,}576} \approx 98.4\%Forward computation: low-rank composition
\text{Output} = (W + B\cdot A)\,x = W\cdot x + B\cdot(A\cdot x)Symbol
Meaning
WFrozen pretrained weights (not updated)
A, BOnly these two matrices are trainable
xInput vector, usually a token embedding or the previous layer's output
Backpropagation: compute and store gradients only for trainable parameters; the optimizer updates only
AandB;Wremains frozen. Gradients may still propagate through the frozen linear layer; this does not mean the layer is entirely excluded from backpropagation.Advantages
AandB, rather than the entireW;BAcan be merged intoW'without changing the architecture);LoRA and its variants
Variant
Characteristics
LoRA
Standard low-rank adaptation, placed alongside linear layers in attention or FFNs
LoRA-FA
Freeze the down-projection matrix
Aand train only the up-projection matrixB, reducing activation memoryQLoRA
4-bit quantization of the base model + LoRA fine-tuning, enabling large-model training on a single GPU
HydraLoRA
Use an asymmetric structure with a shared
Aand multipleBmatrices, routing between components to handle different constituents of mixed data5.8 Comparing PEFT methods
The parameter proportions below indicate typical orders of magnitude. Actual values depend on the model, module sizes and number of trainable layers.
Method
Trainable parameters
Architecture changes?
Inference overhead
Full Fine-tuning
100%
No
None (but a separate model per task)
LoRA
Depends on rank and insertion points; usually far fewer than all parameters
Adds a training branch that can be merged for deployment
Usually none after merging
Adapter
1%–5%
Yes (inserted layers)
Slight increase (sequential computation)
Prefix/Prompt Tuning
<0.1%
No
Uses context length
BitFit
~0.01% (bias terms only)
No
None
Sparse selection / pruning
Method-dependent; ordinary compression pruning is not necessarily PEFT
Selects connections or updates
Fewer sparse parameters do not automatically produce practical speedups
References: LoRA, LoRA-FA, QLoRA, HydraLoRA.