and Evaluation
Teaching a machine that meaning depends on context
Computer Science | Undergraduate (Level 6) | December 2026
WHAT IS INSIDE
1. Core Concepts and Theoretical Frameworks
2. Tokenisation, embeddings and the distributional hypothesis
3. Sequence models and attention
4. Pretraining, fine-tuning and prompting
5. Evaluation, bias and the limits of benchmarks
6. Real-World Case Studies
7. Comparative Summary Table
8. Common Exam Pitfalls and Essay Tips
9. Practice Exam Questions with Model Answers
10. Glossary of Exam-Ready Definitions
1. Core Concepts and Theoretical Frameworks
Natural language processing is examined as a progression of representations, each solving the failure of the
previous one. The table sets each representation against what it captures and what it still cannot do.
Representation Unit Strength Weakness
Bag of words Document Simple, interpretable Ignores order and context
TF-IDF Document and term Downweights common terms Still orderless
Static word embedding Word Captures similarity One vector per word regardless
of context
Contextual embedding Token in context Disambiguates meaning Compute and data heavy
Subword tokenisation Subword unit Handles rare and unseen words Longer sequences
Sentence embedding Sentence Efficient retrieval Loses fine-grained detail
Attention over tokens Token pair Long-range dependencies Quadratic cost in length
The mark-earning idea is context. The word bank means different things in a river bank and a bank account, so
any representation that assigns one vector per word type is wrong by construction. Contextual representations
fixed this and made the transformer the dominant architecture, at the cost of computation that grows quadratically
with sequence length.
2. Tokenisation, embeddings and the distributional hypothesis
Text must be converted into tokens before a model can process it. Word-level tokenisation produces a large
vocabulary and fails on misspellings and morphology. Subword tokenisation, using byte pair encoding or
WordPiece, builds a vocabulary of frequent units, so rare words are represented as compositions and unseen
words are never out of vocabulary. The trade-off is that sequences become longer, which matters because
attention cost grows with length.
The distributional hypothesis states that words occurring in similar contexts have similar meanings, and it is the
basis of static embeddings, which are learned from co-occurrence. Word2vec and GloVe produce vectors with
useful geometric properties, including analogy relations. Their limitation is that a single vector must represent all
senses, so the representation is an average over contexts rather than a representation of any particular use.
Natural Language Processing: Embeddings, Transformers and Evaluation Page 1 of 5
,Natural Language Processing: Embeddings, Transformers and Evaluation
Evaluation of embeddings has two forms. Intrinsic evaluation measures similarity and analogy on benchmarks,
which is fast and weakly related to downstream performance. Extrinsic evaluation trains a model for a task and
measures the task metric, which is expensive and definitive. Reporting only intrinsic results is a common
weakness in student work, because a higher similarity score does not imply a better classifier.
Tokeniser Vocabulary Handles unseen words Typical effect
Word level Large No Out-of-vocabulary tokens
Character level Small Yes Very long sequences
Byte pair encoding Medium Yes, by composition Balanced
WordPiece Medium Yes, by composition Used in BERT
SentencePiece Medium Yes, language agnostic Handles whitespace
languages
3. Sequence models and attention
Recurrent networks process a sequence one step at a time, carrying a hidden state. They handle variable length
naturally and are limited by the difficulty of propagating gradients over long distances, which long short-term
memory cells mitigate but do not eliminate. The sequential computation also prevents parallelisation across the
sequence, which is a practical limitation on modern hardware.
Attention computes a weighted combination of representations, where the weights depend on the similarity
between a query and a set of keys. Self-attention applies this within one sequence, so every position can attend to
every other position in a single layer. Multi-head attention runs several attention functions in parallel, which
allows different heads to specialise in different relations, such as syntactic or coreferential links.
The transformer stacks self-attention with feedforward layers, residual connections and layer normalisation, and it
adds positional encodings because attention alone is permutation invariant. The encoder attends to the whole
input; the decoder attends to the output produced so far and masks future positions. The complexity is quadratic
in sequence length, which motivates sparse attention, local windows and linear approximations.
• Self-attention allows every position to depend on every other in one layer.
• Multi-head attention lets different heads capture different relations.
• Positional encodings are required because attention ignores order.
• Masked attention prevents the decoder from seeing future tokens.
• Attention cost grows quadratically with sequence length.
• Residual connections and layer normalisation make deep stacks trainable.
• Recurrent models are sequential and therefore hard to parallelise.
4. Pretraining, fine-tuning and prompting
Pretraining on a large corpus with a self-supervised objective produces a general language representation.
Masked language modelling predicts hidden tokens from their context, which gives a bidirectional encoder suited
to classification and extraction. Causal language modelling predicts the next token, which gives a decoder suited
to generation. The objective determines what the representation is good for, which is why the architecture and the
objective are chosen together.
Fine-tuning adapts a pretrained model to a task with a small labelled dataset. Parameter-efficient methods, such as
adapters and low-rank adaptation, freeze most of the model and train a small number of additional parameters,
which reduces cost and storage. This is now the standard approach where a full fine-tune is impractical, and it
changes the economics of deploying one base model for many tasks.
Prompting treats the task as a text completion. Zero-shot prompting gives instructions only, few-shot prompting
provides examples, and chain-of-thought prompting elicits intermediate reasoning steps which improve
performance on multi-step problems. The limitations are sensitivity to phrasing, the absence of any guarantee of
Natural Language Processing: Embeddings, Transformers and Evaluation Page 2 of 5