Why Language Is So Hard
A bookshop with a problem.
Welcome to Bright Books, a small online bookshop with a big problem. Every morning, there are two thousand new customer messages. Complaints, questions, praise, and refunds. Two tired people read every one by hand. The owner looks at you and says, could a computer read these for us? Your job for this course starts right now. You're going to build Scribe, an assistant that reads.

- Bright Books: 2,000 messages a day
- Two tired people read them all
- You will build Scribe
Reading in ten lines
Let's not wait. This small program reads three real style messages, and decides how each one feels. We download a pretrained model, with one line. Then we pass in the messages. Run it. The first is positive, and the second negative. And look at the third. Oh great, another broken zip. Just perfect. Those are all positive words. Did it spot the sarcasm? By the end of this course, you'll know exactly why models get things like this right or wrong, and what to do about it.
from transformers import pipeline
classify = pipeline("sentiment-analysis", device="cpu",
model="distilbert-base-uncased-finetuned-sst-2-english")
tickets = ["My order arrived on time, and the book is lovely.",
"This is the third time my delivery has gone missing.",
"Oh great, another broken zip. Just perfect."]
for text in tickets:
r = classify(text)[0]
print(f"{r['label']:<9} {r['score']:.2f} {text}")POSITIVE 1.00 My order arrived on time, and the book is lovely. NEGATIVE 1.00 This is the third time my delivery has gone missing. POSITIVE 1.00 Oh great, another broken zip. Just perfect.
Why language is hard
Why has this taken computers so long? Language is ambiguous. The word bank can be a river or a building. It depends on context. Meaning depends on what came before, and on things that were never said. Everyday writing is full of errors and slang. And there are thousands of languages. A sentence like, I saw her duck, has at least two meanings, and you only know which from the situation.
One word, two meanings
Here's a taste of how a computer can begin to deal with this. We use a library called spaCy to analyse two sentences that both use the word bank. It works out the grammar of each one. Run it. In the first, bank is the subject doing something. In the second, it's the object of a preposition. The structure around a word gives the machine a clue about its meaning. That's the very beginning of understanding.
import spacy
nlp = spacy.load("en_core_web_sm")
for text in ["The bank raised its rates.", "We sat on the river bank."]:
doc = nlp(text)
bank = [t for t in doc if t.text == "bank"][0]
print(f"{text:<30} bank -> {bank.dep_}, head: {bank.head.text}")The bank raised its rates. bank -> nsubj, head: raised We sat on the river bank. bank -> pobj, head: on
Summary
You've run a real language model, and you've seen why language is so hard for machines. That's the mission. Teach machines to handle something that we do without thinking. Next, how did we get here? The story of machines and words.
Key takeaways- Bright Books needs a reader
- Language is ambiguous and messy
- Models can already do a lot