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.
The progression: word2vec (pretrained word vectors only, independent of context) → ELMo/GPT/BERT (whole-model pretraining, contextual representations) → T5 (a unified text-to-text framework for multiple tasks) and larger language models.
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 output h_n as 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 |
Key distinction: it uses bidirectional self-attention.

Figure 1-1 BERT's two stages: unsupervised pretraining on the left (Masked LM + NSP), and fine-tuning for downstream tasks on the right (classification, QA and sequence labeling). Source: Devlin et al., BERT, NAACL 2019, Figure 1.
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
[CLS] Congratulations! You won $1000 ... [SEP]
↓ (BERT bidirectional encoding)
h_[CLS] → classification layer → spam / not spamBERT 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

Figure 1-2 Three pretrained architectures: BERT (bidirectional Transformer, encoder-only), OpenAI GPT (unidirectional, decoder-only), and ELMo (bidirectional LSTM). Source: Devlin et al., 2019, Figure 3.
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 |

Figure 1-3 T5's text-to-text framework expresses translation, classification, summarization and regression as "input text → output text." Source: Raffel et al., Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer, JMLR 2020, Figure 1.
Pretraining objective: span corruption

Figure 1-4 Span corruption: replace contiguous spans with sentinels <X> <Y> <Z> and train the model to generate the removed content. Source: Raffel et al., 2020, Figure 2.
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 |
T5 ultimately uses span corruption: it was competitive in the paper's comparisons and shortened the target sequence to be generated. This is an experimental design trade-off, rather than evidence that it outperforms other objectives on every task.
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 |
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.
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

Figure 2-1 Four ways to use GPT-3: fine-tuning (parameter updates) versus zero-shot, one-shot and few-shot settings (examples without parameter updates). Source: Brown et al., Language Models are Few-Shot Learners, NeurIPS 2020, Figure 2.1.
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
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.

Figure 2-2 Three RLHF stages: (1) supervised fine-tuning (SFT) → (2) train a reward model → (3) optimize the policy using PPO and rewards. Source: Ouyang et al., Training language models to follow instructions with human feedback (InstructGPT), 2022, Figure 2.
1. Collect high-quality data
2. Fine-tune the pretrained model
1. Generate outputs
2. Human ranking
3. Train the reward model
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.
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.
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 |
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 |
Failure example: standard prompting
Q: A cafeteria has 23 apples, uses 20 for lunch and buys 6 more. How many does it have now? A: The model outputs 27 ❌
The incorrect answer in this example fails to compute 23-20+6 correctly; 27 cannot be explained as 23+6, because the latter equals 29.
Alternative: change the prompting style ✅ (using CoT, described next).
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
Q: A cafeteria starts with 23 apples, uses 20 for lunch and buys 6 more. How many does it have now? A: It starts with 23 and uses 20, leaving 3. Buying 6 more brings the total to 9 apples.

Figure 3-1 Left: standard prompting gives a direct, incorrect answer. Right: chain-of-thought prompting reasons step by step to a correct answer. Source: Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, NeurIPS 2022, Figure 1.
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 |
Pros
Cons
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 |
Limitation: each task needs its own model and labeled dataset, which does not scale as the number of tasks grows.
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
This corresponds to the SFT stage of the InstructGPT process in Section 2. SFT → RM → PPO is the specific process used in that paper; RLHF is not restricted to this combination of algorithms.
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.
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
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 |

Figure 4-1 Three paradigms: (A) pretrain–fine-tune uses one model per task; (B) prompting changes the prompt without changing parameters; (C) instruction tuning across multiple tasks can support generalization to unseen tasks. Source: Wei et al., 2022, Figure 2.

Figure 4-2 Instruction tuning overview: express multiple tasks as natural-language instructions, fine-tune, then use instructions for zero-shot inference. Source: Wei et al., Finetuned Language Models Are Zero-Shot Learners (FLAN), ICLR 2022, Figure 1.
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.
Benefits
Limitations
We may therefore go on to use RLHF to optimize model behavior.
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.
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.
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
a) Models are increasing in size
b) Unseen scenarios
c) Catastrophic interference
d) Efficient model updates
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 |
Sparsity is related to parameter-efficient adaptation, but ordinary pruning is not equivalent to PEFT.
Sparse subnetworks
Initial training → pruning(mask) → retraining → pruning again → retraining again → … → sparse subnetwork
(one-shot pruning: prune once; iterative pruning: multiple rounds)
Figure 5-1 One iterative pruning workflow: train → prune with a binary mask → retrain, repeating as needed.
W; instead, learn only its change \Delta W: W' = W + \Delta W\Delta W = B \cdot AThe commonly used scaling factor \alpha/r is omitted here to emphasize the structure of the low-rank update.
W is the original weight matrix; it need not itself be full-rank;r \ll d.W has shape 1024 \times 1024 (a total of 1,048,576 ≈ 1 million parameters);A\,(r \times d) and B\,(d \times r), where r \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\%
Figure 5-2 LoRA reparameterization: freeze
Wand train only the low-rank matricesBandA, giving the forward computationh = Wx + BAx. Source: Hu et al., LoRA: Low-Rank Adaptation of Large Language Models, ICLR 2022, Figure 1.
\text{Output} = (W + B\cdot A)\,x = W\cdot x + B\cdot(A\cdot x)Symbol | Meaning |
|---|---|
| Frozen pretrained weights (not updated) |
| Only these two matrices are trainable |
| Input vector, usually a token embedding or the previous layer's output |
Backpropagation: compute and store gradients only for trainable parameters; the optimizer updates only A and B; W remains frozen. Gradients may still propagate through the frozen linear layer; this does not mean the layer is entirely excluded from backpropagation.
A and B, rather than the entire W;BA can be merged into W' without changing the architecture);Variant | Characteristics |
|---|---|
LoRA | Standard low-rank adaptation, placed alongside linear layers in attention or FFNs |
LoRA-FA | Freeze the down-projection matrix |
QLoRA | 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 |
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 |