COMP5046 — Natural Language Processing

Lecture 1: Introduction & Representing Text

Lexicons → discrete & count features → TF–IDF/BM25 → distributional & learned vectors → evaluation.

📚Lexicons & BoW
📈TF–IDF / BM25
🧠Distributional & neural
Evaluation & bias

How to use this guide: skim bullets first (chunking). Cover the bullets and answer each Recall prompt from memory (retrieval practice). Use Quiz Hub + flashcards for spaced repetition — research shows re-reading alone is weak for retention.

Unit & tasks

What this unit is about

RecallWithout looking up: what four verbs describe what you should be able to do with NLP tech? Name two task families from the list.

Symbolic resources

Lexicons: definitions and relations

RecallWhat two symbolic resources are contrasted? What does WordNet use instead of definitions alone?

Sparse vectors

One-hot words and bag-of-words documents

RecallWhy are hall and room orthogonal in one-hot space? OR vs sum of one-hots — which loses counts?

Corpus weighting

TF–IDF & BM25

\[ \mathrm{tf}_{t,d} = \begin{cases} 1 + \log_{10} \mathrm{count}(t,d) & \text{if } \mathrm{count}(t,d) > 0 \\ 0 & \text{otherwise} \end{cases} \] \[ \mathrm{idf}_t = \log_{10} \frac{N}{\mathrm{df}(t)}, \qquad \mathrm{tf\text{-}idf}_{t,d} = \mathrm{tf}_{t,d} \times \mathrm{idf}_t \]

RecallWrite the IDF formula. If \(\mathrm{df}(t)=N\), what is \(\mathrm{idf}_t\)? What does BM25 add beyond TF–IDF (two words)?

Context statistics

Distributional similarity

Firth: company it keeps · Wittgenstein: meaning in use · Harris: distributional structure.

RecallState the distributional hypothesis in one sentence. What does SVD do to context count vectors?

CBOW / word2vec

Neural word vectors (preview)

RecallList the six training steps (context → loss). CBOW vs skip-gram: who predicts whom? Narrow vs wide window?

Intrinsic tests

Evaluating vectors

RecallWhen is cosine preferred to dot product? Write the analogy arithmetic check. Name two caveats (bias / instability / frequency).

End-to-end

Typical pipeline

  1. Collect / normalise text (encoding, strip HTML).
  2. Tokenise (words/subwords); optional sentence split / lemmatise.
  3. Represent tokens (counts, TF–IDF, ids, embeddings).
  4. Task model (classifier, tagger, LM, parser, generator).
  5. Decode to labels, trees, or strings.

Pretrained transformers often merge steps; stages still help debug and baselines.

RecallRecite the five pipeline stages in order.

Lab

Workshop preview

Quick practice

Why do two one-hot word vectors for synonyms often have zero dot product?
They use the same index
One-hots are orthogonal — different indices, zero overlap
The vectors cancel each other
Cosine is always zero for word vectors
If a token appears in every document, what happens to its IDF weight?
IDF = log(N/N) = 0 — no discriminative power
IDF = 1
IDF = log(N)
IDF is undefined
What is one effect of using a smaller vs larger context window in word2vec-style training?
Smaller → more semantic, larger → more syntactic
Window size has no effect on embeddings
Smaller → more syntactic, larger → more semantic
Larger → slower training only

Chapter quizzes

Retrieval practice (more effective than re-reading). Use flashcards + quiz hub for spaced repetition.

Open Quiz Hub Chapter flashcards