← All courses

Course 8 · Natural Language Processing · about 10 min

Why language is hard for computers

By the end of this course you can explain how computers turn text into numbers, why word order matters, and how modern models understand context.

Language is full of ambiguity. "I went to the bank" could mean money or a river. "Great, another Monday" is probably not praise. People resolve this effortlessly with context; computers need help.

Natural language processing (NLP) covers tasks such as sentiment analysis, translation, summarisation and finding names of people, places and companies in text (called named entity recognition).

Try itWhich NLP task is it?

CheckWhy is "I went to the bank" hard for a computer?

Step 2

Tokens: chopping text into pieces

Models can't read letters. First, text is split into tokens, and each token gets an ID number. Common words are usually one token. Rare or long words are split into subwords, so "unbelievably" might become "un", "believ", "ably". That way a fixed vocabulary can still represent any word, even new ones.

Try itTokenise a sentence

Type anything. This is a simplified tokenizer; real ones learn their splits from data.

CheckWhy do tokenizers split rare words into subwords?

Step 3

Counting words, and where it breaks

Early NLP used a bag of words: ignore the order, just count which words appear. A simple sentiment model adds a point for each positive word and subtracts one for each negative word. It's fast and often works, until word order matters.

Try itBreak a bag-of-words sentiment model

Try the examples, then write your own review.

CheckWhy does "not good" fool a bag-of-words model?

Step 4

Embeddings: meaning as numbers

Modern NLP turns each word into an embedding: a list of hundreds of numbers, learned so that words used in similar contexts end up close together. "Cat" lands near "kitten", far from "carburettor".

Directions in this space can even capture relationships. In the word2vec model (2013), the arithmetic king − man + woman landed closest to queen. Embeddings also carry the biases of the text they were trained on, which researchers have documented.

Try itClose together or far apart in embedding space?

CheckWhat does an embedding represent?

Step 5

Context changes everything

A plain word embedding gives "bank" one meaning everywhere. Transformers fix this with attention: each word looks at the words around it, so "bank" next to "river" gets a different representation than "bank" next to "loan".

BERT (2018) reads a sentence in both directions at once and is great for understanding tasks. GPT-style models read left to right and generate text. Both are transformers.

Predict"The trophy didn't fit in the suitcase because it was too big." What does "it" refer to?

CheckWhat does attention let a language model do?

Step 6 · Recap

What you learned

Quick reviewThree questions from memory. No scrolling back.

Course 9 teaches machines to learn from rewards: reinforcement learning. Mark this course complete below when you're ready.