freshcrate
πŸ’¬

Crate #6: Natural Language Processing

How AI learned to read, write, and roast your grammar

πŸ”§ Builder⏱ ~18 min
NLPlanguagetexttransformersLLM

Why Language Is Hard for Computers

Thecatsatonthemat"sat" attends to relevant words in the sentence

Language seems easy because humans do it effortlessly. But language is absurdly complex:

"Time flies like an arrow. Fruit flies like a banana."

Same grammar structure. Completely different meanings. "Flies" is a verb in the first sentence and a noun in the second. "Like" means "similar to" in the first and "enjoy" in the second. Humans parse this instantly. Computers struggle.

Sarcasm: "Oh great, another Monday." Happy or sad? Context-dependent. Ambiguity: "I saw the man with the telescope." Who has the telescope? Idioms: "It's raining cats and dogs." No animals are involved. Slang: "That's fire" means good. "That's trash" means bad. Good luck writing rules for this.

Natural Language Processing (NLP) is the field of making computers understand, generate, and work with human language. It's behind search engines, voice assistants, translation tools, email autocomplete, and the AI chatbots taking over the internet.

From Word Counts to Transformers

Early NLP was embarrassingly simple. Count how many times each word appears in a document. "Positive" words = positive review. "Negative" words = negative review. This actually worked... sometimes.

Then came WORD EMBEDDINGS (2013) β€” representing each word as a list of numbers (a vector) where similar words have similar numbers. The famous result: King - Man + Woman = Queen. The math actually worked! Words weren't just text anymore; they had mathematical meaning.

Then came the big one: THE TRANSFORMER (2017). A team at Google published a paper called "Attention Is All You Need" and changed everything. The key idea was "attention" β€” the model learns to focus on the most relevant parts of the input.

When you read "The cat sat on the mat because IT was tired," you instantly know "it" refers to "the cat." Attention lets the model do the same thing, by learning which words to focus on when processing each word.

Transformers are the foundation of GPT (Generative Pre-trained Transformer), BERT, Claude, and basically every major language AI. The "T" in GPT literally stands for Transformer.

Large Language Models (LLMs)

An LLM is basically a giant neural network (transformer architecture) trained on most of the internet's text to do one thing: predict the next word.

That's it. That's the core trick. You give it "The capital of France is" and it predicts "Paris." You give it "Once upon a time" and it predicts "there." It does this one word at a time, using its previous predictions as input for the next prediction.

The wild part is that this simple objective β€” predicting the next word β€” when done at massive scale (hundreds of billions of parameters, trained on trillions of words), produces something that can: β€’ Write essays, code, and poetry β€’ Solve math problems β€’ Translate between languages β€’ Summarize documents β€’ Answer questions about nearly anything

Nobody explicitly programmed any of these abilities. They EMERGED from next-word prediction at scale. This is one of the most surprising discoveries in AI.

The "Large" in LLM refers to the number of parameters. GPT-3 had 175 billion. Modern models have even more. These parameters are stored as numbers and can take hundreds of gigabytes of storage. Running them requires specialized hardware (GPUs) that costs thousands of dollars.

πŸ€” Think About It

  1. When an AI chatbot says 'I think...' or 'I feel...', does it actually think or feel? Why does it use those words?
  2. If an LLM is trained mostly on English text, what might it get wrong about other languages and cultures?
  3. LLMs sometimes 'hallucinate' β€” they make up facts that sound true but aren't. Why might predicting 'the most likely next word' lead to this?

πŸ”¬ Try This

  1. Try the 'predict the next word' game with a friend. Say a sentence and have them guess the next word. How often are they right? That's what LLMs do billions of times.
  2. Write a paragraph and replace every 5th word with '___'. Can you fill them back in? That's a simplified version of what masked language models (like BERT) do during training.
  3. Ask an AI chatbot the same question 5 times. Do you get exactly the same answer? Why not? (Hint: it has a 'temperature' setting that adds randomness.)

🎯 Fun Fact

The 'Attention Is All You Need' paper that introduced Transformers has been cited over 100,000 times. The title was inspired by a Beatles song. Several of the original eight authors have since left Google to start their own AI companies, collectively worth billions of dollars. One paper, many billionaires.

πŸ“ Quick Quiz

1. What is the core trick behind Large Language Models?

2. What does the 'T' in GPT stand for?

3. What is the key innovation of the Transformer architecture?

Answer all 3 questions to submit