30% off every book in our site-wide sale. Shop the sale

Category: What Is Natural Language Processing?

  • Where to Go Next: Your NLP Future (and From Words to World)

    Where to Go Next: Your NLP Future (and From Words to World)

    TL;DR: You will be able to recap the whole NLP framework in one paragraph, choose your learning path, and start a first project this week with a plan to stay current.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    You started this book knowing that machines could do something with language, but not how. Now you can see the pipeline: raw text goes in, tokens are created, meaning is represented, intent and entities are extracted, context is tracked, and an action or response comes out. You can spot where a system is likely to fail, whether it is messy text, missing context, biased data, or hallucinated facts. You can ask the right questions of any NLP tool. That is a transformation, and it is worth pausing to name it.

    By the end of this Nugget you will be able to recap the whole framework in one paragraph, choose between the technical, business, and curious learner routes, pick one of the three starter projects with its stated time, and set up a staying-current plan with one newsletter, one visual blog, and one community.

    The core idea

    You are not just a user of NLP tools anymore. You are an evaluator. You can look at any tool and ask the right questions. The three routes are not mutually exclusive: many people start curious, then go technical or business, or start business and then learn enough technical detail to ask better vendor questions. The projects are deliberately small: 2-3 hours, 4-6 hours, 2-4 hours. Small is the point, because a small finished project teaches more than a grand plan that never starts. The conclusion’s message is that the transformation is from confusion to evaluation: you started not knowing how machines understand language, and you now have a mental framework, a vocabulary, and a set of questions that let you judge any system you meet. The book closes with ‘Onward – with words.’

    How it works

    Section 1 (Figure 12.1) recaps the definition, why language is hard, the history from rules to statistics to neural networks to Transformers to LLMs, the four-stage pipeline, the vocabulary list, the responsibilities, and the evaluator questions. Section 2 (Figure 12.2) gives the three routes: Technical (Hugging Face Spaces, Python NLTK and spaCy, small project, Hugging Face Transformers with BERT and GPT variants and fine-tuning), Business (audit pain points, sketch pipeline per pain point, vendor questions, one-month pilot, measure time saved, satisfaction, bias, team literacy), Curious Learner (Pinker ‘The Language Instinct’, McCulloch ‘Because Internet’, ELIZA to ChatGPT history, explain to others with kitchen pipeline, meaning map, LEGO analogy, stay current with ‘The Batch’, Jay Alammar, Hugging Face community and LinkedIn).

    The tools

    Tool 1: Recap the framework. The definition: Natural Language Processing is the field that teaches machines how to work with human language, how to read it, make sense of it, and respond to it in a way that is useful to us. Why language is hard: words like ‘bank’ have multiple meanings, ‘I saw her duck’ is ambiguous, context and world knowledge and culture shape meaning. History: rules, then statistics, then neural networks and Transformers, then large language models. The pipeline: Input, Processing, Understanding, Generation. The vocabulary: tokenisation is like LEGO bricks; embeddings are meaning maps; language models are next-word predictors; intent and entities work like a function call, book_table with party_size, time, date, restaurant; context tracking keeps a dialogue state; extractive summarisation highlights, abstractive paraphrases; search, translation, and chatbots are applications; sentiment, ASR, and TTS are applications; bias comes from data, model, and people; privacy, misinformation, and human oversight are responsibilities. The evaluator questions: does the pipeline fit the task? Is the text messy and how is it cleaned? How is meaning represented? Whose language is missing? What are the limitations and failure modes?

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Recap framework in one paragraph: definition, why hard, history, pipeline, vocabulary, responsibilities.
    2. Choose a learning path: technical, business, or curious learner, and name your first step.
    3. Pick one Appendix E project and list its first 3 steps this week.
    4. Staying current plan: choose 1 newsletter, 1 visual blog, 1 community, and a 3-month revisit. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is Jamal’s learning path, given in full in the case study. The project examples are the three Appendix E projects with their stated times: P1 Personal Sentiment Journal 2-3 hours, P2 FAQ Chatbot 4-6 hours, P3 Translation and Bias Audit 2-4 hours. The staying-current example is one newsletter (‘The Batch’ from DeepLearning.AI), one visual blog (Jay Alammar’s visual Transformer explanations), and one community (Hugging Face forums or LinkedIn groups).

    A real example from the book

    Case Study – Chapter 12: Jamal’s Learning Path: From Confused to Evaluator to Builder. No person age is given. Jamal is a retail supervisor in London, a complete beginner in NLP. He starts with a curiosity journal: each day he notes one NLP moment, an autocorrect fail, a surprising search result, a funny translation, a helpful chatbot, and asks which pipeline stage it used and whether there was bias or a limitation. He chooses the technical route first: he tries Hugging Face Spaces sentiment demo, then learns Python with spaCy, then builds Appendix E Project P1 Personal Sentiment Journal, 2-3 hours, analysing 20-30 of his own texts. The tool mislabels sarcasm, which teaches him the limits of sentiment analysis.

    Mistakes to avoid

    • Trying to follow every new model. Correction: anchor in fundamentals, curate a few sources, revisit every 3 months.
    • Choosing a grand project first. Correction: pick a small finished project, 2-3 hours, 4-6 hours, or 2-4 hours, because small finished teaches more than grand unfinished.
    • Treating the three routes as exclusive. Correction: many people start curious, then go technical or business, or start business and then learn enough technical detail to ask better vendor questions.
    • Stopping at user. Correction: the goal is evaluator, someone who can judge any tool with the pipeline, vocabulary, and questions.
    • Forgetting the ethics questions. Correction: ask who benefits, who is harmed, whose language is included, and whether there is human oversight.

    What not to do

    • Do NOT try to follow every new model.
    • Do NOT start with a grand project.
    • Do NOT treat the three routes as exclusive.
    • Do NOT stop at being a user.
    • Do NOT forget the ethics questions.
    • Do NOT skip the first 3 steps this week.

    Low-energy mode

    Write your mental framework in one sentence. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the business route on their own work: audit one pain point, sketch the pipeline for it, and run a one-month pilot on a low-risk, high-value task, measuring time saved and satisfaction.

    How to know it worked

    You recapped the framework in one paragraph. You chose a learning path and named your first step. You picked one Appendix E project and listed its first 3 steps this week. You chose 1 newsletter, 1 visual blog, 1 community, and a 3-month revisit.

    Key takeaways

    • You started this book knowing that machines could do something with language, but not how. Now you can see the pipeline.
    • Onward – with words.
    • You are not just a user of NLP tools anymore. You are an evaluator.

    Try it today

    Do Exercise – Chapter 12: Where to Go Next today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 12: Where to Go Next. No time stated in the book.

    1. Recap framework in one paragraph: definition, why hard, history, pipeline, vocabulary, responsibilities.
    2. Choose a learning path: technical, business, or curious learner, and name your first step.
    3. Pick one Appendix E project and list its first 3 steps this week.
    4. Staying current plan: choose 1 newsletter, 1 visual blog, 1 community, and a 3-month revisit.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to follow every new model fails here, because the chapter’s own point is that fundamentals change slowly while models change fast. The fix the book gives is to anchor in the pipeline and vocabulary, curate a few sources, and revisit every 3 months, rather than chasing everything.

    How do I know it worked?
    You recapped the framework in one paragraph. You chose a learning path and named your first step. You picked one Appendix E project and listed its first 3 steps this week. You chose 1 newsletter, 1 visual blog, 1 community, and a 3-month revisit.

    What if it does not work?
    If you feel overwhelmed by new models, then anchor in fundamentals and curate a few sources. If a project stalls, then check whether it was too grand and pick a smaller one. If you cannot choose a route, then start curious and explain one concept to someone else, then decide.

  • Ethics, Bias, and Limitations: Using NLP Responsibly

    Ethics, Bias, and Limitations: Using NLP Responsibly

    TL;DR: You will be able to trace bias to data, models, and people, apply the responsible deployment framework, and name what NLP still cannot do.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    By now, you have seen what NLP can do: understand language, answer questions, translate, summarise, and more. But what about what it cannot do, or should not do? A system that can translate languages can also amplify stereotypes. A system that can summarise documents can also generate misinformation. A system that can analyse sentiment can also be used to manipulate vulnerable people. Understanding the limitations and ethical implications of NLP is not an optional extra. It is essential if you want to use these tools responsibly, whether as a builder, a buyer, or simply a user.

    By the end of this Nugget you will be able to explain the three sources of bias with the book’s examples, apply the responsible deployment framework including data minimisation, human oversight, transparency, appeal, and drift monitoring, and explain the five limitations: pattern matching versus understanding, hallucination, common sense, novel language, and empathy.

    The core idea

    NLP is powerful, but it is not magic. It is a set of techniques that work well for certain tasks and poorly for others, and that carry real risks if used carelessly. The ethical questions are not abstract: they are practical questions about who is harmed, who benefits, whose language is included, and who gets to challenge a decision. The chapter’s central point is that responsibility is not a single feature you add at the end. It is a set of practices across the whole pipeline: data collection, model training, evaluation, deployment, monitoring, and human oversight. When you evaluate a tool, ask not just what it can do, but what it cannot do, what its failure mode is, who could be harmed if it fails, and whether there is human oversight. That is what it means to be an evaluator, not just a user.

    How it works

    Section 1 (Figure 11.1) covers the three sources of bias: data bias (internet overrepresents American English; resume screening; movie-review sentiment versus older adults; translation doctor he and nurse she), model bias (70 percent he in data becomes 85 percent he in predictions; embeddings programmer closer to man), people bias (confirmation bias, automation bias, labelling bias). Section 2 (Figure 11.2) covers privacy (data minimisation, on-device processing, transparency, user control, GDPR), misinformation (fake reviews, fake news, watermarking and labelling, citations, not overclaiming), and responsible deployment (appropriateness, real-world evaluation, human oversight and appeal path, monitoring for drift, transparency).

    The tools

    Tool 1: Trace bias to data, models, and people. Data bias: NLP systems are trained on data from the internet, which overrepresents certain groups and underrepresents others. Most training data is in English, and within English it overrepresents American English and younger, more online populations. If a sentiment analysis system is trained mostly on movie reviews, it might perform poorly on restaurant reviews or on text from older adults. If a resume screening tool is trained on historical hiring data where most technical hires were men, it may learn to prefer male candidates, even without an explicit gender feature. Model bias: even with balanced data, models can amplify bias. If 70 percent of doctors in the training data are referred to as ‘he’, the model might predict ‘he’ 85 percent of the time, amplifying the imbalance. Word embeddings can encode stereotypes: ‘programmer’ might be closer to ‘man’ than to ‘woman’ in embedding space, because of co-occurrence patterns in training text. People bias: humans bring bias to how they use NLP. Confirmation bias makes us accept AI outputs that agree with us and reject those that do not.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Data bias audit: for a resume screening tool, list three ways training data could be biased and how you would test for it.
    2. Model bias: explain how 70 percent he for doctor in training data becomes 85 percent he in predictions, and what embeddings reveal about programmer and man.
    3. Responsible deployment checklist: for a tool you use, check data minimisation, human oversight, transparency, appeal path, and drift monitoring.
    4. Limitations: give an example where NLP fails on common sense, like sock in fridge, and explain why hallucination happens. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the amplification example: if 70 percent of doctors in the training data are referred to as ‘he’, the model might predict ‘he’ 85 percent of the time, amplifying the imbalance. The common sense example is ‘Put the sock in the fridge’, which is nonsense to a human but might be processed literally by a system. The deployment example is that a model that is 90 percent accurate on test data might be much less accurate on your specific data, so real-world evaluation matters more than test accuracy.

    A real example from the book

    Case Study – Chapter 11: HireFair: Bias, Privacy, and Responsible Deployment in Hiring. No person age is given. HireFair builds an AI resume screening tool. It is trained on historical hiring data where 80 percent of technical hires were men. The model learns to prefer male candidates, even without an explicit gender feature, because it picks up on correlated signals like certain universities, hobbies, or language patterns. The training corpus overrepresents American English and male language, underrepresents Nigerian English and career breaks. Word embeddings link programmer closer to man. Hiring managers show automation bias: they over-trust the AI ranking and interview fewer candidates the AI scored low, even when those candidates had strong qualifications.

    Mistakes to avoid

    • Treating bias as a single bug to fix once. Correction: bias is a property of data, model, and people, and needs ongoing monitoring.
    • Trusting test accuracy alone. Correction: evaluate in the real world, because 90 percent on test data can be much less on your data.
    • Removing an explicit gender feature and assuming bias is gone. Correction: models pick up correlated signals like universities, hobbies, or language patterns.
    • Collecting more data than needed. Correction: data minimisation, only collect what you need.
    • Deploying without an appeal path. Correction: people must be able to challenge automated decisions.
    • Ignoring drift. Correction: language changes over time, so monitor post-deployment.

    What not to do

    • Do NOT treat bias as a one-time fix.
    • Do NOT trust test accuracy alone.
    • Do NOT assume removing a gender feature removes bias.
    • Do NOT collect more data than you need.
    • Do NOT deploy without an appeal path.
    • Do NOT ignore drift.
    • Do NOT assume fluent text means understanding.
    • Do NOT over-trust automated ranking.

    Low-energy mode

    Pick one tool you use and ask: who could be harmed if it fails, and is there human oversight? That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the responsible deployment checklist before recommending a tool to a client: data minimisation, human oversight, transparency, appeal path, and drift monitoring, and can ask the vendor the book’s evaluator questions.

    How to know it worked

    You listed three ways resume training data could be biased and how to test for it. You explained the 70 percent to 85 percent amplification and the programmer embedding. You ran the responsible deployment checklist on a tool you use. You gave a common sense failure example and explained hallucination.

    Key takeaways

    • Understanding the limitations and ethical implications of NLP is not an optional extra. It is essential if you want to use these tools responsibly.
    • Bias is not a bug you fix once; it is a property of the data, the model, and the people using it, and it requires ongoing monitoring.
    • They can generate fluent text about grief without having experienced it.
    • A system that can summarise documents can also generate misinformation.

    Try it today

    Do Exercise – Chapter 11: Ethics, Bias, Limitations today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 11: Ethics, Bias, Limitations. No time stated in the book.

    1. Data bias audit: for a resume screening tool, list three ways training data could be biased and how you would test for it.
    2. Model bias: explain how 70 percent he for doctor in training data becomes 85 percent he in predictions, and what embeddings reveal about programmer and man.
    3. Responsible deployment checklist: for a tool you use, check data minimisation, human oversight, transparency, appeal path, and drift monitoring.
    4. Limitations: give an example where NLP fails on common sense, like sock in fridge, and explain why hallucination happens.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to trust the system fails here, because the chapter’s own point is automation bias: we over-trust automated systems, assuming the computer must be right. The fix the book gives is human oversight, an appeal path, real-world evaluation, and monitoring for drift, not more trust.

    How do I know it worked?
    You listed three ways resume training data could be biased and how to test for it. You explained the 70 percent to 85 percent amplification and the programmer embedding. You ran the responsible deployment checklist on a tool you use. You gave a common sense failure example and explained hallucination.

    What if it does not work?
    If a tool shows bias, then check data, model, and people in that order, and add fairness metrics across groups. If test accuracy is high but real-world accuracy is low, then evaluate on your specific data. If a system invents facts, then check whether generation was grounded in real data.

  • Opinions, Summaries, and Voice: NLP in Action

    Opinions, Summaries, and Voice: NLP in Action

    TL;DR: You will be able to explain sentiment analysis with negation and sarcasm, summarisation in two forms, information extraction, and the full speech loop from audio to voice.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    Every day, millions of people write reviews, post opinions, and share experiences online. That text is a goldmine for businesses that want to know what customers think. But reading thousands of reviews manually is impossible. This is where sentiment analysis comes in. In this Nugget, we will explore sentiment analysis, how NLP reads emotions and opinions in text, and why it is both powerful and tricky.

    By the end of this Nugget you will be able to explain sentiment analysis including aspect-based scoring, negation, sarcasm, and emotion detection, explain extractive versus abstractive summarisation with faithfulness checks, explain information extraction with the Obama example, and explain ASR and TTS with homophones, acoustic and language models, and the privacy and ethics questions.

    The core idea

    Sentiment analysis is not just about counting positive and negative words. It is about understanding opinions, emotions, and attitudes in context. Good sentiment analysis is aspect-based, handles negation, acknowledges sarcasm limits, and is trained on domain-matched data. Summarisation is not just shortening. It is about extracting what matters while staying faithful to the source. Extractive is safe but limited; abstractive is flexible but must be checked against the original. Speech technology is a two-way bridge: ASR turns human speech into machine-readable text, TTS turns machine text into human-hearable speech. Both are powerful and both raise real questions about data, bias, and consent. When you evaluate any of these tools, ask the book’s questions: does it handle negation? Is it aspect-based? Does it acknowledge sarcasm limitations? Was it trained on data from your domain? For summaries, ask whether the summary contains facts not in the original, omits critical caveats, or would be agreed with by a human who read the original.

    How it works

    Section 1 (Figure 10.1) covers sentiment analysis: simple classification, aspect-based analysis, lexicon-based scoring, machine-learning approaches, contextual embeddings, negation, sarcasm, emotion detection, and the five evaluation questions. Section 2 (Figure 10.2) covers summarisation: extractive versus abstractive, meeting transcript example, hallucination and faithfulness checks, and information extraction with named entity recognition and relation extraction. Section 3 (Figure 10.3) covers ASR: acoustic model plus language model, homophones, continuous speech segmentation, accent and noise challenges, low-resource languages; and TTS: concatenative stitching versus neural generation, prosody, uses, voice cloning ethics with watermarking, and privacy as biometric data.

    The tools

    Tool 1: Explain sentiment analysis, including the hard cases. At its simplest, sentiment analysis classifies text as positive, negative, or neutral, like the review ‘The food was amazing, but the service was slow.’ That overall classification hides nuance, so aspect-based sentiment analysis breaks text into aspects: food is positive, service is negative, ambience is neutral. Lexicon-based approaches assign sentiment scores to words: ‘love’ +2, ‘hate’ -2, ‘amazing’ +3, ‘terrible’ -3, then sum them. They are transparent but fail on negation (‘not good’ is not positive) and context (‘This movie was sick’ in slang is positive). Machine-learning approaches train on labelled reviews, learning patterns including word combinations, and use embeddings to understand that ‘amazing’ and ‘fantastic’ are similar. Contextual embeddings understand that ‘good’ in ‘not good’ is different from ‘good’ in ‘very good’. Three hard cases the book names: negation, where ‘not good’ must not be read as positive; sarcasm, where ‘Oh great, another delayed flight.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Sentiment: score four reviews, The food was amazing but the service was slow; I thought the movie would be terrible, but it was fantastic!; Not bad, I guess.; Oh great, another delayed flight. Just what I needed.
    2. Summarisation: summarise a 1000-word article in one sentence and as bullet points, then compare with an AI summary and check faithfulness and hallucination.
    3. Information extraction: extract Person, Date, Place from Barack Obama was born on August 4, 1961, in Honolulu, Hawaii.
    4. ASR and TTS: explain how a system distinguishes to/two/too, why overlapping speech is hard, and what privacy risks voice data poses. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the aspect breakdown: ‘food was amazing but service was slow’ splits into food positive +0.9 and service negative -0.6. The twist example is ‘I thought the movie would be terrible, but it was fantastic!’, which starts negative and ends positive, so an overall score must handle the reversal. The sarcasm example is ‘Oh great, another delayed flight. Just what I needed.’, which looks positive on words but is negative in intent. The information extraction example is ‘Barack Obama was born on August 4, 1961, in Honolulu, Hawaii’, giving Person Barack Obama, Date August 4, 1961, Place Honolulu, Hawaii. The speech example is the homophone test: ‘I bought two apples’ not ‘to apples’, chosen by the language model from context.

    A real example from the book

    Case Study – Chapter 10: TasteAnalytics: Opinions, Summaries, and Voice in a Restaurant Chain. No person age is given. TasteAnalytics serves a restaurant chain with 50 locations. It processes 2,000 reviews daily from Google, TripAdvisor, and Instagram. Aspect-based sentiment analysis breaks reviews into food, service, ambience, price, location. A review Food was amazing but service was slow gives food positive +0.9, service negative -0.6. Negation is handled: not good is not scored as positive. Sarcasm is flagged for human review: Oh great, another delayed flight is not scored as positive. Summaries: extractive summaries highlight the most representative sentences for managers; abstractive summaries generate executive summaries tailored to operations (service speed) versus marketing (food quality). Information extraction pulls structured data from invoices and supplier emails: vendor, amount, date.

    Mistakes to avoid

    • Scoring a whole review as one number. Correction: use aspect-based analysis, food positive and service negative in the same review.
    • Reading ‘not good’ as positive. Correction: handle negation explicitly.
    • Trusting sarcasm detection. Correction: flag sarcasm for human review, because systems still miss it.
    • Accepting an abstractive summary without checking. Correction: run the faithfulness checks, facts not in the original, omitted caveats, would a human agree.
    • Extracting entities without relations. Correction: relation extraction finds the connections, like who was born when and where.
    • Expecting ASR to handle overlapping speech. Correction: use a single-speaker protocol in noisy settings.
    • Using voice cloning without consent. Correction: watermark or label synthetic speech and get consent.

    What not to do

    • Do NOT score a mixed review as one number.
    • Do NOT read ‘not good’ as positive.
    • Do NOT trust sarcasm detection blindly.
    • Do NOT accept an abstractive summary without faithfulness checks.
    • Do NOT expect ASR to handle overlapping speech.
    • Do NOT clone a voice without consent.
    • Do NOT treat voice data as ordinary data.

    Low-energy mode

    Score one review you read today as positive, negative, or mixed, and name the aspect. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use aspect-based sentiment on their own client feedback: split each testimonial into aspects like communication, speed, and quality, so one mixed review does not become a single misleading score.

    How to know it worked

    You scored four reviews including the sarcastic one and the twist one. You summarised a 1000-word article in one sentence and as bullet points and compared with an AI summary on faithfulness and hallucination. You extracted Person, Date, Place from the Obama sentence. You explained the to/two/too distinction, overlapping speech, and voice privacy risks.

    Key takeaways

    • Sentiment analysis is not just about counting positive and negative words. It is about understanding opinions, emotions, and attitudes in context.
    • Good sentiment analysis is aspect-based, handles negation, acknowledges sarcasm limits, and is trained on domain-matched data.
    • Summarisation is not just shortening. It is about extracting what matters while staying faithful to the source.
    • Voice is biometric data.

    Try it today

    Do Exercise – Chapter 10: Opinions, Summaries, Voice today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 10: Opinions, Summaries, Voice. No time stated in the book.

    1. Sentiment: score four reviews, The food was amazing but the service was slow; I thought the movie would be terrible, but it was fantastic!; Not bad, I guess.; Oh great, another delayed flight. Just what I needed.
    2. Summarisation: summarise a 1000-word article in one sentence and as bullet points, then compare with an AI summary and check faithfulness and hallucination.
    3. Information extraction: extract Person, Date, Place from Barack Obama was born on August 4, 1961, in Honolulu, Hawaii.
    4. ASR and TTS: explain how a system distinguishes to/two/too, why overlapping speech is hard, and what privacy risks voice data poses.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to count positive and negative words fails here, because the chapter’s own point is that lexicon counting fails on negation and context: ‘not good’ is not positive, and ‘sick’ in slang is positive. The fix the book gives is aspect-based, contextual, domain-matched sentiment analysis that acknowledges sarcasm limits.

    How do I know it worked?
    You scored four reviews including the sarcastic one and the twist one. You summarised a 1000-word article in one sentence and as bullet points and compared with an AI summary on faithfulness and hallucination. You extracted Person, Date, Place from the Obama sentence. You explained the to/two/too distinction, overlapping speech, and voice privacy risks.

    What if it does not work?
    If a review is mis-scored, then check whether it was scored as one number instead of by aspect. If ‘not good’ is read as positive, then negation handling failed. If sarcasm is missed, then flag it for human review rather than trusting the score. If a summary invents facts, then it is an abstractive hallucination and needs faithfulness checks.

  • Search, Translation, and Chatbots: How NLP Powers the Web

    Search, Translation, and Chatbots: How NLP Powers the Web

    TL;DR: You will be able to explain how search understands a query, how translation moved from word-for-word to meaning-for-meaning, and what makes a support chatbot good or bad.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    Think about the last time you typed something into a search engine. Maybe you typed ‘best Italian restaurant open now near me’ or ‘how to fix a leaky tap’ or ‘what is NLP in simple terms’. You typed a few words, pressed enter, and within half a second got a list of relevant results. That speed and relevance is powered by NLP at several stages, most of which you never see. Let us walk through what happens when you search.

    By the end of this Nugget you will be able to walk a search query through query understanding, indexing, and ranking, explain translation in three generations with the idiom and reordering examples, and judge a support chatbot on understanding, context tracking, transparency, escalation, and empathy.

    The core idea

    Search connects your intent to information. Translation connects your language to other languages. Chatbots connect your needs to actions and support. All three rely on the same foundational pipeline, adapted to different goals. Search is a perfect example of NLP that must work at scale and speed: billions of queries per day, in many languages, with typos and slang, returning relevant results in milliseconds. Translation illustrates a deeper point about NLP: understanding meaning deeply enough to re-express it in another language is a strong test of whether a system truly understands, not just memorises patterns. Chatbots illustrate the business value of NLP: 24/7 support, high volumes, reduced wait times, freeing human agents to handle complex, nuanced cases that require true human judgement and empathy. They are not about replacing humans, but about handling routine inquiries efficiently so humans can focus where they add most value.

    How it works

    Section 1 (Figure 9.1) covers search: query understanding, indexing, ranking, personalisation, direct answers, ambiguity handling. Section 2 (Figure 9.2) covers translation: word-for-word dictionaries, phrase-based statistical translation from parallel corpora, neural encoder-decoder with attention, LLMs for translation with tone, quality by language pair, gender bias in Turkish to English translation, cultural nuance and localisation, gisting versus high-stakes use. Section 3 (Figure 9.3) covers chatbots: rule-based flowcharts, intent-entity ML, LLM-grounded agents, the five traits of good bots (understanding, context tracking, transparency, escalation, empathy), corpus building, privacy, evaluation, and pitfalls (wrong information damaging trust, overpromising, bias against dialects).

    The tools

    Tool 1: Walk a search query through three stages. First, query understanding. Search queries are short, often ungrammatical, full of shorthand. ‘Best Italian restaurant open now near me’ is not a complete sentence, but a human instantly understands it: Italian restaurants, highly rated, currently open, near your location. The pipeline tokenises the query, normalises case, perhaps expands abbreviations, and identifies entities: cuisine = Italian, business type = restaurant, time = now, location = near me (resolved to your actual location). It also identifies intent: you want recommendations, not a definition or a recipe. Modern search engines use embeddings to understand that ‘best’ implies high rating, that ‘open now’ is a time constraint, and that ‘near me’ is a location constraint. They do not just look for documents that contain the exact words. Second, indexing. The web contains billions of pages. Search engines crawl the web and build an index, a massive structure that maps words and meanings to documents, much like the index at the back of a book but far more sophisticated. TF-IDF helps identify which documents have distinctive, relevant terms.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Search: for query best Italian open now near me, list intent, entities, why embeddings help match fantastic and open late to best, and how ranking uses relevance and authority.
    2. Translation: explain why It’s raining cats and dogs fails word-for-word and how phrase-based and neural attention handle idiom and reordering like English SVO vs Japanese SOV.
    3. Bias test: translate O bir doktor and O bir hemşire from Turkish gender-neutral pronoun to English, what gender does the system assume and why?
    4. Chatbot design: for My package hasn’t arrived and I’m leaving town tomorrow, can you redirect? identify two intents and entities, design a response that handles empathy, offers alternatives, and includes escalation with context passing. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the support request: ‘My package hasn’t arrived and I’m leaving town tomorrow, can you redirect it?’ A good chatbot identifies two intents, report delayed delivery and request redirect, with entities: order W12345, new address needed, urgency leaving town tomorrow. It triggers a workflow: check order status, check if redirect is possible, ask for new address, confirm. It offers an empathetic tone, ‘I understand this delay is frustrating’, transparently says it is a bot, and hands off to a human when confidence is low, passing context so the user does not repeat themselves.

    A real example from the book

    Case Study – Chapter 9: GlobalBazaar: Search, Translation, and Chatbots Powering the Web. No person age is given. GlobalBazaar is a marketplace selling to UK and France. Problem: UK user searches best Italian open now near me at 9pm. Search engine must understand intent recommendation, entities cuisine Italian, time now, location near me, and that open now requires real-time hours, not just keyword. They implement embeddings so cheap and affordable match, and direct answer extraction for Where is my order? showing tracking, not just links. Second problem: translation. Product description It’s raining cats and dogs graphic hoodie, literal translation to French would be nonsense. They move from word-for-word to neural translation with attention: encoder builds meaning, decoder generates Il pleut a verse graphic hoodie, correctly translating the idiom as heavy rain.

    Mistakes to avoid

    • Matching keywords only in search. Correction: use embeddings to match meaning, so ‘cheap places to eat’ finds ‘affordable restaurants’.
    • Translating word-for-word. Correction: idioms need phrase-based or neural meaning-for-meaning translation.
    • Ignoring word order differences between languages. Correction: English SVO versus Japanese SOV needs attention-based reordering.
    • Using translation alone for legal or medical text. Correction: human review remains essential for high-stakes use.
    • Building a chatbot that traps users in loops. Correction: good bots escalate smoothly to a human, passing context.
    • Hiding that a bot is a bot. Correction: transparency about what it can and cannot do sets expectations.
    • Training a chatbot on narrow phrasing only. Correction: it must handle informal phrasing and typos like ‘whr is my ordr W12345’.

    What not to do

    • Do NOT match keywords only in search.
    • Do NOT translate idioms word-for-word.
    • Do NOT ignore word order differences between languages.
    • Do NOT use machine translation alone for legal or medical instructions.
    • Do NOT trap users in chatbot loops.
    • Do NOT hide that a bot is a bot.
    • Do NOT train a chatbot only on formal phrasing.

    Low-energy mode

    Take your last search and name its intent and one entity. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the five traits of a good chatbot to brief a client: understanding, context tracking, transparency, escalation, and empathy, and can test a vendor bot with a typo-filled message like ‘whr is my ordr W12345’ before recommending it.

    How to know it worked

    You listed intent and entities for best Italian open now near me and explained the embedding and ranking points. You explained the raining cats and dogs failure and the SVO versus SOV reordering. You ran the Turkish bias test and named the assumed genders and why. You designed a chatbot response for the redirect request with two intents, entities, empathy, alternatives, and escalation with context passing.

    Key takeaways

    • Search connects your intent to information. Translation connects your language to other languages. Chatbots connect your needs to actions and support.
    • Poor bots trap you in loops; good bots know their limits.
    • They are not about replacing humans, but about handling routine inquiries efficiently so humans can focus where they add most value.
    • Understanding meaning deeply enough to re-express it in another language is a strong test of whether a system truly understands.

    Try it today

    Do Exercise – Chapter 9: Search, Translation, Chatbots today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 9: Search, Translation, Chatbots. No time stated in the book.

    1. Search: for query best Italian open now near me, list intent, entities, why embeddings help match fantastic and open late to best, and how ranking uses relevance and authority.
    2. Translation: explain why It’s raining cats and dogs fails word-for-word and how phrase-based and neural attention handle idiom and reordering like English SVO vs Japanese SOV.
    3. Bias test: translate O bir doktor and O bir hemşire from Turkish gender-neutral pronoun to English, what gender does the system assume and why?
    4. Chatbot design: for My package hasn’t arrived and I’m leaving town tomorrow, can you redirect? identify two intents and entities, design a response that handles empathy, offers alternatives, and includes escalation with context passing.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to match keywords fails here, because the chapter’s own point is that modern search does not just look for documents containing the exact words: it uses embeddings to match query meaning to document meaning. The fix is meaning-based matching, plus ranking by intent, authority, and quality, not more keywords.

    How do I know it worked?
    You listed intent and entities for best Italian open now near me and explained the embedding and ranking points. You explained the raining cats and dogs failure and the SVO versus SOV reordering. You ran the Turkish bias test and named the assumed genders and why.

    What if it does not work?
    If search returns irrelevant results, then check whether it matched keywords only instead of meaning. If translation produces nonsense, then check whether it translated word-for-word instead of meaning-for-meaning. If a chatbot traps you in a loop, then check whether it lacks escalation and context passing.

  • The Invisible NLP All Around You: Keyboards, Inboxes, and Voice

    The Invisible NLP All Around You: Keyboards, Inboxes, and Voice

    TL;DR: You will be able to explain how autocorrect, spam filters, email sorting, grammar checkers, and voice assistants work, and ask the privacy questions that matter for each.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    You have probably already used Natural Language Processing today without realising it. You woke up, typed a message, and your phone quietly fixed a typo, suggested the next word, or completed your sentence. That quiet help is NLP, working invisibly. Let us start with autocorrect, one of the oldest and most familiar NLP applications. You type ‘teh’ and it becomes ‘the’. You type ‘restuarant’ and it becomes ‘restaurant’. How does it know?

    By the end of this Nugget you will be able to explain autocorrect with edit distance and language models, predictive text and Smart Compose, spam filtering with embeddings, email classification, grammar checking with syntax parsing, and the full voice assistant loop from wake word to text-to-speech, including on-device versus cloud privacy.

    The core idea

    Autocorrect and predictive text are a perfect example of NLP that is most successful when you do not notice it. When it works, you just type faster with fewer errors. When it fails, the infamous autocorrect that changes ‘meeting’ to something embarrassing, you notice. Spam filters, email sorting, and grammar checkers share a common trait: they work on text you did not ask to process, but that you benefit from having processed. They reduce noise, organise information, and improve clarity. Voice assistants combine everything: speech processing, the full NLP pipeline, dialogue management, and speech generation. They show how NLP does not exist in isolation but as part of a larger system that interacts with the real world. When you think about building or buying NLP tools, these everyday examples are useful benchmarks: does the tool reduce friction like autocorrect does? Does it organise like email sorting? Does it improve quality like grammar checkers?

    How it works

    Section 1 (Figure 8.1) covers autocorrect (dictionaries, edit distance, language models, context), predictive text (next-word prediction, personalisation), and Smart Compose (phrase completion from email patterns and past emails). Section 2 (Figure 8.2) covers spam filters (rule-based evasion like ‘FR EE MO NEY’, machine learning on labelled corpora, embeddings for semantic similarity, personalisation from user labels), email sorting (classification into Primary, Promotions, Social, Updates), and grammar checkers (syntactic parsing, language models, tone detection, the authorship question). Section 3 (Figure 8.3) covers voice assistants: wake word detection on-device, ASR with acoustic and language models, homophones ‘to’, ‘two’, ‘too’, intent and entity extraction, action, TTS, dictation, and the four challenges (no visual feedback, ambiguity, privacy, accent and language diversity).

    The tools

    Tool 1: Explain autocorrect, predictive text, and Smart Compose. Early autocorrect used dictionaries and edit distance, a measure of how many letters you need to change to turn one word into another. ‘Teh’ is one swap away from ‘the’, so it is a likely correction. Modern autocorrect is smarter: it uses context and language models. Predictive text takes this further: as you type ‘How are’, your keyboard might suggest ‘you’, ‘you doing’, ‘you today’. This is a language model predicting the next word based on what you have typed so far and on patterns learned from millions of other sentences. It also personalises: it learns your vocabulary, your common phrases, your names. Smart Compose, like Gmail’s feature that suggests completions for entire phrases, uses even more context: you start typing ‘Thanks for reaching out, I will’, and it suggests ‘get back to you shortly.’ What makes autocorrect feel intelligent is not just dictionary lookup, but context awareness: ‘I need to book a table’ versus ‘I love to read a book’: in the first, ‘book’ is a verb; in the second, a noun.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. For one day, log every autocorrect, predictive text, smart compose suggestion, and note correct vs incorrect and what context it used.
    2. Explain how a spam filter uses embeddings to catch lottery winner and you have won a prize as similar despite no shared words.
    3. Email sorting: how would you classify Your order has shipped with tracking vs 20 percent off with images? What features would the classifier use?
    4. Voice assistant pipeline: trace Hey Siri set timer for ten minutes from wake word detection, ASR, NLP, action, TTS, including privacy design on-device vs cloud and how accent bias arises. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the autocorrect context test: ‘I need to book a table’ versus ‘I love to read a book’. In the first, ‘book’ is a verb; in the second, a noun. A good predictive keyboard knows that after ‘book a table’, the next words might be ‘for two’, while after ‘read a book’, the next words might be ‘about’ or ‘on’. It uses surrounding words to disambiguate. The voice example is the full loop: ‘Hey Siri, set a timer for ten minutes’ goes from wake word to ASR to intent set_timer with duration ten minutes to action to the spoken confirmation ‘Timer set for ten minutes’.

    A real example from the book

    Case Study – Chapter 8: DailyDriver App: Invisible NLP That Saves Time. No person age is given. DailyDriver productivity app integrates three invisible NLP features from Chapter 8. First, smart keyboard: user types teh meeting at L’Artusi tmrw, autocorrect uses edit distance plus language model to fix teh to the, tmrw to tomorrow, and keeps L’Artusi as a single token because the personal dictionary learned it. Predictive text suggests for two at 7pm after Book a table. Second, email triage: incoming messages classified into Primary, Receipts, Support. Spam filter uses embeddings to recognise lottery winner and you have won a prize as similar despite no shared words. It learns from the user marking promotions as not spam, personalising. Third, voice dictation for drivers: Hey DailyDriver, set reminder to call Alex about order W12345.

    Mistakes to avoid

    • Judging autocorrect by dictionary lookup alone. Correction: modern autocorrect uses context and language models, not just edit distance.
    • Thinking spam filters only match keywords. Correction: embedding-based filters catch semantically similar phrases with no shared words.
    • Treating email sorting as magic. Correction: it is classification on tokens, embeddings, sender, subject, body language, and past behaviour.
    • Accepting grammar suggestions without asking why. Correction: good tools explain why, helping you learn, not just correct.
    • Ignoring where voice data goes. Correction: ask whether learning is on-device or in the cloud, and whether recordings can be deleted.
    • Assuming ASR works equally for all accents. Correction: training data has historically overrepresented certain groups, so accent bias is real.

    What not to do

    • Do NOT judge autocorrect by dictionary lookup alone.
    • Do NOT assume a spam filter only matches keywords.
    • Do NOT accept grammar changes without asking why.
    • Do NOT ignore where your voice recordings go.
    • Do NOT assume ASR works equally well for every accent.
    • Do NOT speak ambiguously to a voice assistant and expect it to guess correctly without confirmation.

    Low-energy mode

    Log the next three autocorrect or predictive text suggestions you see, and note one that was right and one that was wrong. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the email triage idea on their own inbox: classify incoming messages by intent and let the classifier learn from marking promotions as not spam, so the important personal emails surface first.

    How to know it worked

    You logged a day of autocorrect, predictive text, and smart compose suggestions with correct vs incorrect and the context used. You explained the lottery winner embedding example. You classified two emails and named the features the classifier would use. You traced Hey Siri set timer for ten minutes from wake word to TTS with privacy design and accent bias.

    Key takeaways

    • Autocorrect and predictive text are a perfect example of NLP that is most successful when you do not notice it.
    • Success measured not by noticing NLP, but by not noticing friction.
    • Your keyboard learns from what you type.
    • When it works, you just type faster with fewer errors.

    Try it today

    Do Exercise – Chapter 8: Invisible NLP today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 8: Invisible NLP. No time stated in the book.

    1. For one day, log every autocorrect, predictive text, smart compose suggestion, note correct vs incorrect and what context it used.
    2. Explain how a spam filter uses embeddings to catch lottery winner and you have won a prize as similar despite no shared words.
    3. Email sorting: how would you classify Your order has shipped with tracking vs 20 percent off with images? What features would the classifier use?
    4. Voice assistant pipeline: trace Hey Siri set timer for ten minutes from wake word detection, ASR, NLP, action, TTS, including privacy design on-device vs cloud and how accent bias arises.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to type perfectly fails here, because the chapter’s own point is that these tools exist to reduce friction, not to demand perfection from you. The fix the book gives is to let the invisible pipeline do its work and to judge it by whether it reduces friction, organises, or improves quality, while asking where your data goes.

    How do I know it worked?
    You logged a day of autocorrect, predictive text, and smart compose suggestions with correct vs incorrect and the context used. You explained the lottery winner embedding example. You classified two emails and named the features the classifier would use. You traced Hey Siri set timer for ten minutes from wake word to TTS with privacy design and accent bias.

    What if it does not work?
    If autocorrect changes a word wrongly, then check whether it used context or only edit distance. If spam slips through, then check whether the filter learned from your marking behaviour. If a voice assistant misunderstands, then check whether it was ASR, intent, entity, or context tracking that failed.

  • Intent, Entities, and Context: How Machines Follow a Conversation

    Intent, Entities, and Context: How Machines Follow a Conversation

    TL;DR: You will be able to extract intent and entities from any utterance, track context across turns, and judge a dialogue system by how it manages flow, correction, and task completion.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    Imagine you walk up to a hotel reception desk and say, ‘Hi, I am here to check in, reservation under Smith for tonight.’ In that one sentence, you have conveyed several things without even thinking about it. The receptionist instantly understands your overall purpose: You want to check in. That is your intent. The receptionist also picks out the specific details needed to act: The name is Smith, the date is tonight. Those details are entities, the pieces of information that fill in the blanks for the intent. Intent and entities are the twin foundations of how machines understand what you actually mean, not just what words you used.

    By the end of this Nugget you will be able to define intent and entities with the book’s examples, track context through a three-turn restaurant dialogue including corrections, and explain dialogue management, response generation, error handling, and task completion tracking in a multi-turn system.

    The core idea

    Intent and entities are the core of understanding single utterances. But real conversations are not single utterances. They are back-and-forth exchanges where meaning builds over time. Context is what turns a series of isolated questions and answers into a true conversation. It is also what makes dialogue systems feel intelligent and helpful, rather than frustrating and forgetful. A conversation is not just a series of independent questions. It is a collaborative process where both participants build shared understanding, track what has been agreed, handle complications, and work towards a goal. Multi-turn dialogue systems try to mimic that collaborative process. When you interact with a good conversational assistant, notice how it handles the flow: does it remember what you said, does it offer helpful alternatives when your request cannot be met, does it confirm before taking important actions, does it handle corrections gracefully, does it know when the conversation is complete? Those are signs of good dialogue management, not just good language generation.

    How it works

    Section 1 (Figure 7.1) defines intent and entities, classification versus sequence labelling, rules versus learning from examples, and the ambiguity challenge (‘Book a table’ versus ‘I love this book about tables’) and novel phrasing (‘Can you squeeze us in for two around seven-ish at L’Artusi?’). Section 2 (Figure 7.2) covers context tracking: dialogue state tracking, anaphora resolution, implicit information, corrections, long-distance dependencies, common ground, explicit state tables versus implicit LLM context windows versus hybrids. Section 3 (Figure 7.3) covers multi-turn dialogue architecture: NLU, Dialogue Manager, Knowledge base, Response Generation, error repair loops, the L’Artusi booking with complications (full at 7pm, dietary restrictions, parking, email confirmation), rule-based versus learned dialogue management, template versus language-model response generation, clarification strategies, and task completion tracking.

    The tools

    Tool 1: Extract intent and entities. An intent is the overall goal or purpose behind an utterance. It answers the question: What does the user want to accomplish? In a restaurant setting, intents might be book_table, cancel_reservation, ask_menu, ask_hours, give_feedback. In a customer support setting, intents might be report_problem, request_refund, check_status, ask_question. The same intent can be expressed in many different ways. All of these share the intent book_table: ‘Book a table for two at 7pm’, ‘Can I get a reservation for two tonight at seven?’, ‘Need a table for 2 at L’Artusi this evening’, ‘I would like to reserve a table for me and my partner for 7’. An entity is a specific piece of information relevant to the intent. If intent is the verb, what you want to do, entities are the nouns and details, who, what, when, where, how many. In ‘Book a table for two at 7pm tonight at L’Artusi’, the entities are: party size two, time 7pm, date tonight (which needs to be resolved to an actual date), restaurant name L’Artusi. Common entity types include person names, locations, organisations, dates, times, numbers, currencies. Why separate them?

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Intent-entity extraction: for My flight BA249 tomorrow is delayed, can I get rebooked? list intent and entities including flight number and date.
    2. Context tracking: dialogue Is there Italian near me? / Yes L’Artusi 0.3 miles / Is it open tonight? / Book table for two at 7, track what it refers to and what implicit info must be filled.
    3. Correction handling: user says Book for two at 7… actually make it 8 and three people, describe how dialogue state should update time and party size.
    4. Failure analysis: bot keeps asking Which restaurant? after you already said L’Artusi, which component failed: intent, entity, context tracking, or dialogue management? No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the three-turn restaurant dialogue plus the complicated booking: ‘Book a table for two at L’Artusi tonight at 7pm’ gets ‘L’Artusi is fully booked at 7pm, but they have availability at 6:30pm or 8:30pm. Which would you prefer?’ The user asks about 8:30 and parking; the system answers that there is a car park 0.2 miles away and street parking after 6pm, and asks whether to book the 8:30 table for two. The user confirms and adds a vegetarian menu and confirmation to [email protected]. The system confirms: ‘Booked! Table for two at L’Artusi tonight at 8:30pm. I have noted vegetarian preference and sent confirmation to [email protected].

    A real example from the book

    Case Study – Chapter 7: Hotel Concord: Intent, Entities, and Context Across Turns. No person age is given. Hotel Concord’s front desk bot handles check-in. Guest says: Hi, I am here to check in, reservation under Smith for tonight. Bot extracts intent check_in, entities name Smith, date tonight resolved to today. Next guest says: Is it open tonight? referring to rooftop bar. Early bot lost context and asked Which restaurant? After Chapter 7, the team implements dialogue state tracking table with slots: Guest_name, reservation_date, discussed_facility rooftop bar, intent history. They add coreference resolution: It resolves to rooftop bar from previous turn, tonight to date. Guest then says: Book a table for two at 7… actually make it 8, and make it three people.

    Mistakes to avoid

    • Treating each utterance as independent. Correction: conversations build meaning over turns, and context must be tracked.
    • Asking for information the user already gave. Correction: that is a dialogue state tracking failure, not a knowledge failure.
    • Adding instead of overwriting on correction. Correction: ‘actually make it 8, and make it three people’ must update time and party size, not add.
    • Taking ‘squeeze us in for two around seven-ish’ literally. Correction: good systems learn to handle informal phrasing and vague times from diverse real-world examples.
    • Generating a natural-sounding response that invents facts. Correction: ground generation in actual data and state, or the system hallucinates availability or parking.

    What not to do

    • Do NOT treat utterances as independent.
    • Do NOT ask for information already given.
    • Do NOT add on correction instead of overwriting.
    • Do NOT generate responses that invent availability or details.
    • Do NOT judge a dialogue system on fluency alone.
    • Do NOT assume an LLM that handles everything implicitly is precise or remembers beyond its context window.

    Low-energy mode

    Take one message you sent today and name its intent and its entities in one line. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use intent and entities to triage client messages: label each message’s intent and extract its entities, so a message that says ‘My flight BA249 tomorrow is delayed, can I get rebooked?’ is answered from its structured purpose plus details, not from a skim of the words.

    How to know it worked

    You listed intent and entities for My flight BA249 tomorrow is delayed, can I get rebooked? including flight number and date. You tracked what ‘it’ refers to and what implicit info must be filled in the L’Artusi dialogue. You described how dialogue state updates time and party size on correction. You named which component failed when the bot kept asking Which restaurant?

    Key takeaways

    • Intent and entities are the twin foundations of how machines understand what you actually mean, not just what words you used.
    • Context is what turns a series of isolated questions and answers into a true conversation.
    • A conversation is not just a series of independent questions. It is a collaborative process where both participants build shared understanding.
    • If it forgets context, it would have to ask ‘Which restaurant? What date?’ again, which feels frustrating and unintelligent.

    Try it today

    Do Exercise – Chapter 7: Intent, Context, Conversation today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 7: Intent, Context, Conversation. No time stated in the book.

    1. Intent-entity extraction: for My flight BA249 tomorrow is delayed, can I get rebooked? list intent and entities including flight number and date.
    2. Context tracking: dialogue Is there Italian near me? / Yes L’Artusi 0.3 miles / Is it open tonight? / Book table for two at 7, track what it refers to and what implicit info must be filled.
    3. Correction handling: user says Book for two at 7… actually make it 8 and three people, describe how dialogue state should update time and party size.
    4. Failure analysis: bot keeps asking Which restaurant? after you already said L’Artusi, which component failed: intent, entity, context tracking, or dialogue management?

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to answer single questions better fails here, because the chapter’s own point is that real conversations are not single utterances. A system that answers one question well but asks ‘Which restaurant?’ after you already said L’Artusi has failed at context tracking, not at knowledge. The fix is dialogue state, not a bigger answer database.

    How do I know it worked?
    You listed intent and entities for My flight BA249 tomorrow is delayed, can I get rebooked? including flight number and date. You tracked what ‘it’ refers to and what implicit info must be filled in the L’Artusi dialogue. You described how dialogue state updates time and party size on correction.

    What if it does not work?
    If the bot asks for information already given, then dialogue state tracking broke, not knowledge. If it misinterprets ‘it’, then reference resolution failed. If it cannot handle ‘actually make it 8’, then its update logic is weak. If it asks ‘Which restaurant?’ after L’Artusi was named, then check context tracking before intent or entity extraction.

  • Giving Words Meaning: From Counting to Meaning Maps to Language Models

    Giving Words Meaning: From Counting to Meaning Maps to Language Models

    TL;DR: You will be able to explain bag-of-words and TF-IDF, embeddings as meaning maps, and language models as next-word predictors, with the book’s own examples.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    So far we have cleaned text and broken it into tokens. We have words like ‘book’, ‘restaurant’, ‘love’, ‘tonight’ neatly sliced and normalised. But to a computer, these are still just labels. How does a machine know that ‘restaurant’ and ‘cafe’ are similar, while ‘restaurant’ and ‘rocket’ are not? How does it know that ‘love’ and ‘adore’ share positivity, while ‘love’ and ‘hate’ are opposites? This is the problem of representation: How do we turn tokens into a form that captures meaning in a way machines can use?

    By the end of this Nugget you will be able to explain bag-of-words and TF-IDF and their three limits, explain embeddings with the meaning map and the king minus man plus woman equals queen example, and explain language models as next-word predictors that learn grammar, facts, and reasoning as a byproduct of prediction.

    The core idea

    The shift from counting to learning representations based on context is the foundation of embeddings. It moved NLP from ‘words are labels to count’ to ‘words are meanings to map’. Embeddings turned words from discrete labels into continuous meanings. That shift from counting to mapping is what allows modern NLP to handle similarity, analogy, and nuance far better than earlier methods. The journey from counting words to embeddings to language models reflects a progression in how we represent meaning. Counting asked ‘What words appear?’ Embeddings asked ‘What company do words keep?’ Language models ask ‘What word comes next given everything so far?’ Each question builds on the previous and captures more context, more nuance, and more of what makes human language so rich.

    How it works

    Section 1 (Figure 6.1) covers bag-of-words and TF-IDF, sparsity, loss of order, and inability to capture synonyms, plus the Firth quote. Section 2 (Figure 6.2) covers word embeddings and meaning maps: dense vectors a few hundred numbers long, Word2Vec 2013, GloVe, static versus contextual embeddings, king minus man plus woman equals queen, Paris minus France plus Italy near Rome, and the practical benefits: solving the synonym problem (a search for ‘cafe’ finds ‘coffee shop’ or ‘bistro’), enabling generalisation (a sentiment system trained on ‘I love this’ understands ‘I adore this’ as positive), and making learning more efficient (knowledge about ‘restaurant’ partly transfers to ‘cafe’).

    The tools

    Tool 1: Start with counting. Bag-of-words represents a document by counting which words appear in it. Imagine you have a bag, you throw all the words of a document into it, shake it up, and count. TF-IDF stands for Term Frequency-Inverse Document Frequency: a word is important to a document if it appears often in that document (term frequency) but rarely in other documents (inverse document frequency). Counting worked surprisingly well for search and topic classification. But counting has three clear limits. First, it treats words as atomic and unrelated: in bag-of-words, ‘car’ and ‘automobile’ are as different as ‘car’ and ‘banana’. Second, it suffers from sparsity: a vocabulary of 50,000 words means each document is a vector with 50,000 numbers, most of them zero. Third, it ignores context and order: ‘Not good’ and ‘good’ look similar if you ignore ‘not’, and ‘I love this’ and ‘I hate this’ differ by only one word, but that word flips the meaning entirely.

    Tool 2: Use the meaning map. Instead of representing a word by counting where it appears, represent it by learning from the company it keeps. The idea comes from linguist J.R.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Bag-of-words vs embeddings: show why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings, using the company they keep idea.
    2. TF-IDF intuition: in a baking article corpus, why does sourdough get high weight and the get low weight?
    3. Explain the embedding analogy king minus man plus woman approximately equals queen without maths, using contextual patterns.
    4. Language model next-word prediction: for The capital of France is ___, I went to the shop to buy some ___, If it rains tomorrow we will ___, list likely words and what knowledge is needed to predict.
    5. Identify hallucination risk: why might a model invent an affordable space rocket that does not exist in inventory? No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the blank test. ‘I went to the shop to buy some ___’ favours milk, bread, and eggs over aeroplane, because you draw on your experience of how people talk about going to shops. A language model learns the same ability from data at a scale no human could match. And the embedding example: ‘king’ minus ‘man’ plus ‘woman’ gives a vector close to ‘queen’, not by magic but because ‘king is to man as queen is to woman’ is a pattern that appears in many contexts.

    A real example from the book

    Case Study – Chapter 6: ThreadzSearch: From Counting to Meaning Maps. No person age is given. Spectrum Threadz online shop search used bag-of-words: query cheap places to eat returned zero results because product descriptions said affordable restaurants. It also treated car and automobile as unrelated. The team applies Chapter 6 concepts. They move from counting to embeddings. They train Word2Vec on 2 million product descriptions and customer reviews, learning that affordable, cheap, budget-friendly appear in similar contexts, so their vectors become neighbours. Search for cafe now finds coffee shop and bistro because embeddings are close. They implement TF-IDF weighting to highlight distinctive terms like sourdough over the. For the language model, they deploy a neural model predicting the next word to power autocomplete: type oversized hood… suggests hoodie, not aeroplane, because the language model learned likely continuations.

    Mistakes to avoid

    • Treating ‘car’ and ‘automobile’ as unrelated. Correction: in embeddings they are neighbours because they keep similar company.
    • Ignoring sparsity. Correction: a 50,000-word vocabulary makes most document vectors mostly zero, which is inefficient.
    • Ignoring word order and ‘not’. Correction: ‘I love this’ and ‘I hate this’ differ by one word that flips meaning.
    • Thinking embeddings are a dictionary with definitions. Correction: they are a map built from usage, not definitions.
    • Thinking a language model looks up answers in a database. Correction: it predicts likely continuations based on patterns in data.
    • Trusting fluent generation without grounding. Correction: ground generation in real data, as ThreadzSearch did with its inventory database, or the model invents products that do not exist.

    What not to do

    • Do NOT treat synonyms as unrelated just because they are different words.
    • Do NOT ignore word order and negation when counting.
    • Do NOT mistake an embedding map for a dictionary of definitions.
    • Do NOT assume a language model looks up answers or understands like a human.
    • Do NOT trust generated text without grounding it in real data.
    • Do NOT use a single static vector when context changes the meaning.

    Low-energy mode

    Name two words that are close in meaning and one that is far away, and say why from the company they keep. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the synonym point on their own shop or site search: if a search for ‘cafe’ misses ‘coffee shop’, the fix is meaning-based matching, not adding more keywords, and generated text must be grounded in real inventory.

    How to know it worked

    You showed why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings. You explained why sourdough gets high TF-IDF weight and the gets low weight in a baking corpus. You explained king minus man plus woman approximately equals queen without maths. You listed likely next words for three prompts and the knowledge needed. You named the hallucination risk with the affordable space rocket.

    Key takeaways

    • You shall know a word by the company it keeps.
    • It is not a dictionary with definitions. It is a map built from usage.
    • Counting asked ‘What words appear?’ Embeddings asked ‘What company do words keep?’ Language models ask ‘What word comes next given everything so far?’
    • They are predicting likely continuations based on patterns in data.

    Try it today

    Do Exercise – Chapter 6: Representations and Language Models today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 6: Representations and Language Models. No time stated in the book.

    1. Bag-of-words vs embeddings: show why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings, using the company they keep idea.
    2. TF-IDF intuition: in a baking article corpus, why does sourdough get high weight and the get low weight?
    3. Explain the embedding analogy king minus man plus woman approximately equals queen without maths, using contextual patterns.
    4. Language model next-word prediction: for The capital of France is ___, I went to the shop to buy some ___, If it rains tomorrow we will ___, list likely words and what knowledge is needed to predict.
    5. Identify hallucination risk: why might a model invent an affordable space rocket that does not exist in inventory?

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to count more words fails here, because the chapter’s own point is that counting treats ‘car’ and ‘automobile’ as unrelated and ignores order, so ‘not good’ and ‘good’ look similar. The fix is not bigger counts, it is a different representation: learn from the company words keep, so similar meanings sit near each other on the map.

    How do I know it worked?
    You showed why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings. You explained why sourdough gets high TF-IDF weight and the gets low weight in a baking corpus. You explained king minus man plus woman approximately equals queen without maths. You listed likely next words for three prompts and the knowledge needed.

    What if it does not work?
    If search returns zero results for a query with synonyms, then check whether the system counts words only instead of using embeddings. If a model invents a product, then ground generation in the actual inventory database. If ‘bank’ is misread, then check whether the system uses contextual embeddings or a single static vector.

  • Making Text Machine-Readable: Cleaning, Tokenisation, and the Corpus

    Making Text Machine-Readable: Cleaning, Tokenisation, and the Corpus

    TL;DR: You will be able to clean messy real-world text, tokenise it three ways, and decide when to remove stop words, stem, lemmatise, or keep the original form.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    If you have ever copied text from a website into a document, you know it rarely comes in clean. There are extra spaces, strange line breaks, maybe some HTML leftovers like ‘&’ instead of ‘&’. There are capital letters used inconsistently, emojis, URLs, hashtags, and the occasional typo. To a computer, that mess is not mildly annoying. It is fundamentally confusing, because a computer starts by treating every distinct character sequence as different unless we tell it otherwise.

    By the end of this Nugget you will be able to audit messy text for case, punctuation, typos, emojis, and noise, tokenise a sentence as words, subwords, and multi-word units, explain when removing stop words hurts, compare stemming and lemmatisation with the book’s examples, and judge whether a corpus is representative.

    The core idea

    Raw text in the wild is messy because human communication is messy. We are creative, informal, multilingual, and we make mistakes. NLP has to embrace that messiness and make it workable. Every impressive demo you see, translation, summarisation, chatbots, rests on careful decisions made at this early stage. Getting the foundation right makes everything downstream easier and more accurate. Tokenisation is not just a mechanical step. It is a design decision that shapes everything downstream. Good tokenisation preserves meaning where it matters and splits where splitting helps. Bad tokenisation destroys meaning or creates unnecessary complexity. When you evaluate an NLP project, one of the best questions you can ask is: how did you handle messy text? What did you do with capitalisation, punctuation, typos, and emojis? The answer tells you a lot about whether the system was built for clean textbook examples or for the real world where you live and work.

    How it works

    Section 1 (Figure 5.1) covers why raw text is messy: case, punctuation, typos, HTML noise, emojis, spacing. Section 2 (Figure 5.2) covers tokenisation: word tokens, subword tokens, multi-word tokens, BPE and SentencePiece, the LEGO analogy, the recipe analogy (breaking ‘2 cups flour, 1 tsp salt, 3 eggs’ into ingredients and amounts). Section 3 (Figure 5.3) covers stop words, stemming versus lemmatisation, and corpora. Stemming chops to ‘runn’ and ‘happi’; lemmatisation returns the proper base ‘run’ and ‘good’ for ‘better’. A corpus must be representative, diverse, and large enough, and corpus choices, what sources to include, how to clean them, how to tokenise them, whether to remove stop words or lemmatise, and how to handle privacy and bias, should reflect the nature of the corpus.

    The tools

    Tool 1: Clean messy text thoughtfully. Capitalisation: to you, ‘Apple’ at the start of a sentence and ‘apple’ in the middle are the same word; to a naive system that has not been taught to normalise case, they are different. Punctuation: ‘Hello, world!’ includes a comma and an exclamation mark; in sentiment analysis, ‘Hello!!!’ conveys stronger positivity than ‘Hello’; in a search query you probably want to ignore punctuation; in ‘L’Artusi’ or ‘Wendy’s’ the apostrophe is part of the name and should be preserved; in ‘don’t’ the apostrophe matters for negation. Typos and variation: ‘color’ and ‘colour’, ‘organize’ and ‘organise’, ‘teh’ for ‘the’, ‘ur’ for ‘your’, ‘cooool’ with extra letters, ‘2moro’ for ‘tomorrow’. Noise that is not language: HTML tags like ‘<div>’ and ‘<p>’, URLs, email addresses, ‘@username’, hashtags like ‘#NLP’; hashtags carry topic information and some noise is valuable. Emojis: ‘I loved the movie’ with a heart-eyes emoji contains sentiment in the emoji; for sentiment analysis, absolutely do not remove it. Spaces: ‘New York’ is one location or two words? ‘Ice cream’? Languages like Chinese or Japanese do not use spaces between words at all. The definition of a word becomes a design decision.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Take messy text: OMG LOVE this!!! with heart-eyes emoji, #NLP, 2moro, cooool, teh, link https://t.co/xyz, and decide case handling, punctuation keep/remove, typo normalisation, emoji handling, and justify for a sentiment task.
    2. Tokenise the sentence I can’t believe it’s 7pm at L’Artusi! three different ways and discuss pros and cons.
    3. Explain when removing stop words hurts: analyse This is not good and to be or not to be.
    4. Compare stemming vs lemmatisation for running, runs, ran, better, happiness, saying which returns real words and when you would use each. Bonus: what bias risk if a corpus overrepresents American English vs Nigerian English? No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the messy social post: ‘OMG LOVE this!!! 😍 #NLP 2moro cooool teh link https://t.co/xyz’. The chapter’s cleaning decisions: lowercasing except brand name, preserving emojis for sentiment, keeping hashtags as topic tokens, handling ‘2moro’ to ‘tomorrow’ via informal mapping, normalising ‘color’ to ‘colour’ for search but keeping the original for display. Tokenisation: subword tokenisation handles ‘cooool’ as ‘cool’ with emphasis, keeps ‘@spectrumthreadz’ as a single mention token, keeps ‘#SpectrumThreadz’ as a topic token. Stop words: they keep ‘not’ for sentiment because ‘not good’ flips meaning. Stemming vs lemmatisation: they choose lemmatisation to map ‘loving’, ‘loved’, ‘love’ to ‘love’ without collapsing to the non-word ‘happi’.

    A real example from the book

    Case Study – Chapter 5: CleanTweets: Making Brand Monitoring Machine-Readable. No person age is given. Spectrum Threadz, a London streetwear brand, monitors Instagram mentions. Raw data is messy: OMG LOVE this drop!!! with two heart-eyes emojis, #SpectrumThreadz, @spectrumthreadz, cooool, 2moro, color vs colour, teh drop, link https://t.co/xyz, <div> spam. Early system treated LOVE, love, and looooove as different words, and the heart-eyes emoji was stripped, losing sentiment. Using Chapter 5 principles, the team redesigns cleaning. Normalisation: lowercasing except brand name, preserving emojis for sentiment, keeping hashtags as topic tokens, handling 2moro to tomorrow via informal mapping, normalising color to colour for search but keeping the original for display. Tokenisation: subword tokenisation handles cooool as cool with emphasis, keeps @spectrumthreadz as a single mention token, keeps #SpectrumThreadz as a topic token, keeps 7pm and L’Artusi style names.

    Mistakes to avoid

    • Treating every distinct character sequence as different. Correction: normalise case and variation thoughtfully.
    • Stripping emojis in sentiment work. Correction: the emoji is gold for sentiment, keep it.
    • Removing ‘not’, ‘no’, ‘never’ as stop words in sentiment analysis. Correction: ‘This is not good’ becomes ‘This is good’, the opposite meaning.
    • Using stemming when you need real words. Correction: stemming gives ‘happi’, lemmatisation gives the proper base form.
    • Tokenising ‘L’Artusi’ into pieces or splitting ‘7pm’. Correction: keep meaningful units together.
    • Building a corpus from one dialect and assuming it represents everyone. Correction: ask whose language is included and whose is missing.
    • Treating tokenisation as purely mechanical. Correction: it is a design decision that shapes everything downstream.

    What not to do

    • Do NOT strip emojis when doing sentiment analysis.
    • Do NOT remove ‘not’, ‘no’, or ‘never’ without checking what it does to meaning.
    • Do NOT use stemming when you need a real word as the base form.
    • Do NOT split proper names or times into pieces.
    • Do NOT build a corpus from one dialect and call it representative.
    • Do NOT treat tokenisation as a mechanical step with one right answer.

    Low-energy mode

    Take one messy sentence you typed today and decide just two things: what to keep and what to normalise. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can run the messy text audit on their own client messages before choosing a tool: if the messages are full of slang, emojis, and typos, a system that strips them will misread sentiment, so the audit becomes part of the client brief.

    How to know it worked

    You decided case handling, punctuation, typo normalisation, and emoji handling for the messy text, with a justification for a sentiment task. You tokenised I can’t believe it’s 7pm at L’Artusi! three ways with pros and cons. You explained why removing stop words hurts for This is not good and to be or not to be. You compared stemming and lemmatisation for running, runs, ran, better, happiness.

    Key takeaways

    • To a computer, that mess is not mildly annoying. It is fundamentally confusing.
    • Cleaning is the first act of respect we show to the data.
    • Tokenisation, then, is not just a mechanical step. It is a design decision that shapes everything downstream.
    • Subword tokenisation is like having a box of LEGO bricks – small, reusable pieces you can combine to build any model, even one you have never built before.

    Try it today

    Do Exercise – Chapter 5: Making Text Machine-Readable today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 5: Making Text Machine-Readable. No time stated in the book.

    1. Take messy text: OMG LOVE this!!! with heart-eyes emoji, #NLP, 2moro, cooool, teh, link https://t.co/xyz, and decide case handling, punctuation keep/remove, typo normalisation, emoji handling, and justify for a sentiment task.
    2. Tokenise the sentence I can’t believe it’s 7pm at L’Artusi! three different ways and discuss pros and cons.
    3. Explain when removing stop words hurts: analyse This is not good and to be or not to be.
    4. Compare stemming vs lemmatisation for running, runs, ran, better, happiness, which returns real words and when would you use each? Bonus: what bias risk if a corpus overrepresents American English vs Nigerian English?

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to clean text by deleting everything unusual fails here, because the chapter’s own logic is that cleaning is a set of thoughtful choices about what to keep, what to normalise, and what to remove. Stripping emojis destroys sentiment; stripping ‘not’ reverses meaning; stripping the apostrophe from L’Artusi destroys a name.

    How do I know it worked?
    You decided case handling, punctuation, typo normalisation, and emoji handling for the messy text, with a justification for a sentiment task. You tokenised I can’t believe it’s 7pm at L’Artusi! three ways with pros and cons. You explained why removing stop words hurts for This is not good and to be or not to be.

    What if it does not work?
    If sentiment scores look backwards, then check whether ‘not’ was removed as a stop word. If brand mentions are missed, then check whether case handling split LOVE, love, and looooove into different words. If new words fail, then check whether the tokeniser is word-level only and needs subword pieces.

  • The End-to-End Pipeline: Your Map for the Rest of the Book

    The End-to-End Pipeline: Your Map for the Rest of the Book

    TL;DR: You will be able to walk any NLP application through the four phases, Input, Processing, Understanding, Generation, and sketch the pipeline for a problem of your own.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    Imagine you receive a handwritten note from a friend. It says: ‘Can’t make dinner tonight, stuck at work, raincheck tomorrow? Let me know!’ You read it, understand the situation, feel a little disappointment, and decide what to do next, maybe text back ‘No worries, tomorrow works!’ That whole process, from seeing ink on paper to taking action, happens in a second, without conscious effort. Now imagine a computer receiving the same note as a digital message. For the computer, it is not a note from a friend. It is a string of characters. To get from that string to a useful action, it needs to go through a journey. That journey is what we call the NLP pipeline.

    By the end of this Nugget you will be able to walk the sentence ‘Book a table for two at 7pm tonight at L’Artusi’ through the whole pipeline, name the four phases and what each does, and explain how sentiment analysis, machine translation, and a voice assistant each adapt the same pipeline differently.

    The core idea

    The pipeline is not a single step, but a sequence of stages, each one transforming the text a little closer to something the machine can act on. Each stage builds on the previous one. In real-world systems, the pipeline is not always strictly linear: modern large language models can do many of these steps implicitly inside one large model. But conceptually, the same work still happens: cleaning, breaking into pieces, representing meaning, understanding intent and entities, maintaining context, and generating a response. Holding this journey overview in your mind is powerful. Whenever you encounter a new NLP application, sentiment analysis, translation, summarisation, you can ask: where does it start with raw text? What cleaning and tokenisation does it need? What understanding does it extract? What action or output does it produce? That simple set of questions turns a mysterious black box into a series of understandable steps. Chapter 4’s pipeline is your map for the rest of the book.

    How it works

    Section 1 (Figure 4.1) gives the journey overview with the restaurant booking example and the kitchen analogy. Section 2 (Figure 4.2) gives the four phases in detail: Input, Processing (normalisation, tokenisation, stemming and lemmatisation), Understanding (representation via embeddings, syntactic and semantic analysis, intent and context, sentiment analysis and classification), Generation (structured meaning to natural language, blurred by LLMs that do both in one system). Section 3 (Figure 4.3) gives the three adaptations: sentiment analysis emphasises understanding, translation emphasises generation, voice assistants add speech steps at both ends.

    The tools

    Tool 1: Walk the whole journey with one example. Raw text in: ‘Book a table for two at 7pm tonight at L’Artusi.’ First, make the text machine-readable: clean and normalise, lowercasing where appropriate, handling punctuation, recognising that ‘L’Artusi’ is a proper name with an apostrophe that should be kept together, not split apart. Next, break it into tokens: [‘book’, ‘a’, ‘table’, ‘for’, ‘two’, ‘at’, ‘7pm’, ‘tonight’, ‘at’, ‘L’Artusi’]. Notice that ‘7pm’ is kept as one meaningful token, not ‘7’ and ‘pm’ separately, because together they represent a time. Then add understanding: ‘Book’ here is not a noun meaning a physical book; it is a verb meaning to reserve. Identify entities: ‘two’ refers to number of people, ‘7pm’ and ‘tonight’ refer to time, ‘L’Artusi’ refers to a restaurant name. Then infer intent: the overall intent is to make a reservation, classified as book_table. Finally, generate a response or action: check availability, make the booking, and produce a confirmation: ‘Done! I have booked a table for two at L’Artusi tonight at 7pm. You will get a confirmation shortly.’ From raw text to action. That is the pipeline in miniature.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Sketch the full pipeline for query Book a table for two at 7pm tonight at L’Artusi, label Input, Processing, Understanding, Generation, and note tokenisation and entity decisions.
    2. Adapt the pipeline for two applications, sentiment analysis dashboard and machine translation, saying which phases are emphasised and which are minimal.
    3. Failure diagnosis: if the system splits L’Artusi into L and Artusi, which phase fails and what is the downstream impact?
    4. Design a pipeline for voice assistant Set an alarm for 6 am tomorrow, including speech-to-text before input and text-to-speech after generation, plus how tomorrow is resolved. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the full pipeline walk for ‘Book a table for two at 7pm tonight at L’Artusi’: cleaning keeps the apostrophe in L’Artusi; tokenisation keeps ‘7pm’ as one time token; understanding reads ‘book’ as a reservation verb, extracts party size two, time 7pm, date tonight, restaurant L’Artusi; intent is classified as book_table; generation checks availability and confirms ‘Done! I have booked a table for two at L’Artusi tonight at 7pm.’ The case study adds the failure diagnosis: bad tokenisation split L’Artusi into L and Artusi, causing an entity miss, and fixing tokenisation improved accuracy 18 percent.

    A real example from the book

    Case Study – Chapter 4: The Pipeline in Action: BookATable Startup. No person age is given. BookATable startup wants to build voice-enabled booking: Book a table for two at 7pm tonight at L’Artusi. The team sketches the Chapter 4 pipeline. Input phase: raw audio from noisy restaurant street plus typed text with typo 7pn. Processing: speech-to-text with error correction, normalisation keeping L’Artusi apostrophe, tokenisation keeping 7pm as one time token, not 7 and pm. Understanding: representation via embeddings recognising book as reservation verb not noun, intent classification as book_table, entity extraction party_size two, time 7pm, date tonight resolved to 2026-10-28, restaurant L’Artusi. Dialogue state tracks Soho location from previous turn. Generation phase: check availability via API, produce confirmation You are all set! Table for two at L’Artusi tonight at 7pm.

    Mistakes to avoid

    • Treating the pipeline as strictly linear in every system. Correction: modern LLMs do many steps implicitly inside one large model, but conceptually the same work still happens.
    • Splitting meaningful tokens apart, like ‘L’Artusi’ into ‘L’ and ‘Artusi’ or ‘7pm’ into ‘7’ and ‘pm’. Correction: keep meaningful units together or entity recognition fails downstream.
    • Grouping word forms when tense matters. Correction: for sentiment analysis grouping ‘loved’ and ‘loving’ helps, but for precise information extraction tense might matter.
    • Expecting generation from every system. Correction: some systems just understand and then take a non-linguistic action, like flagging spam.

    What not to do

    • Do NOT split meaningful tokens like L’Artusi or 7pm apart.
    • Do NOT assume the pipeline is strictly linear in modern LLMs.
    • Do NOT group word forms when tense matters for the task.
    • Do NOT expect every NLP system to generate language.
    • Do NOT evaluate a tool without sketching its pipeline first.
    • Do NOT ignore messy input when estimating difficulty.

    Low-energy mode

    Sketch the four phases for one query you typed today: Input, Processing, Understanding, Generation, one line each. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can sketch the pipeline for a client request before quoting: name the input, the cleaning needed, the understanding to extract, and the action or output, so the quote covers the hard phases instead of only the visible output.

    How to know it worked

    You sketched the full pipeline for Book a table for two at 7pm tonight at L’Artusi with all four phases labelled and tokenisation and entity decisions noted. You adapted it for a sentiment dashboard and for translation, naming which phases are emphasised and which are minimal. You diagnosed the L’Artusi split and its downstream impact. You designed a voice assistant pipeline with speech-to-text before input and text-to-speech after generation.

    Key takeaways

    • Think of the pipeline like a kitchen that turns raw ingredients into a finished meal.
    • From raw text to action. That is the pipeline in miniature.
    • The pipeline does not solve everything, but it gives you a map.
    • Once you see the four phases, you stop seeing NLP as a collection of unrelated magic tricks and start seeing it as a coherent workflow.

    Try it today

    Do Exercise – Chapter 4: End-to-End Pipeline today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 4: End-to-End Pipeline. No time stated in the book.

    1. Sketch the full pipeline for query Book a table for two at 7pm tonight at L’Artusi, label Input, Processing, Understanding, Generation and note tokenisation and entity decisions.
    2. Adapt the pipeline for two applications: sentiment analysis dashboard and machine translation, which phases emphasised, which minimal?
    3. Failure diagnosis: if the system splits L’Artusi into L and Artusi, which phase fails and what downstream impact?
    4. Design the pipeline for voice assistant Set an alarm for 6 am tomorrow, include speech-to-text before input and text-to-speech after generation, plus how tomorrow is resolved.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to understand each NLP application as a separate magic trick fails here, because the chapter’s own point is that most NLP applications are variations on the same theme.

    How do I know it worked?
    You sketched the full pipeline for Book a table for two at 7pm tonight at L’Artusi with all four phases labelled and tokenisation and entity decisions noted. You adapted it for a sentiment dashboard and for translation, naming which phases are emphasised and which are minimal. You diagnosed the L’Artusi split and its downstream impact.

    What if it does not work?
    If entity recognition fails, then check tokenisation first: did it split a meaningful token like L’Artusi or 7pm? If the booking is wrong, then check whether ‘tonight’ was resolved to today’s date. If a sentiment dashboard looks wrong, then check whether processing kept emojis and negations, since ‘not good’ must stay a single sentiment unit.

  • From Rules to Statistics to Neural Networks: How NLP Got Here

    From Rules to Statistics to Neural Networks: How NLP Got Here

    TL;DR: You will be able to tell the story of NLP in three eras, rules, statistics, and neural networks, with dates, systems, and what each era could and could not do.

    This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.

    The story of Natural Language Processing begins not with supercomputers, but with a surprisingly simple idea: If we can write down the rules of language, we can teach a machine to follow them. In the 1950s, in the early days of computing, researchers were optimistic. Language seemed like a code that could be cracked. If a sentence has a subject, verb, and object, you could write that as a rule. If plural nouns end in ‘s’, you could write that as a rule.

    By the end of this Nugget you will be able to place ELIZA 1966, Georgetown-IBM 1954, SHRDLU, the statistical revolution, Word2Vec 2013, and the Transformer 2017 on a timeline, explain why hand-written rules scale poorly, explain n-grams and corpora with the book’s own numbers, and explain attention, BERT 2018, and GPT without maths.

    The core idea

    We moved from hand-written rules that were precise but brittle, to counting patterns in real data that were flexible but shallow, to learning rich representations and attention that are flexible and deep. Each era solved the previous era’s bottleneck and revealed the next one. Rules could not handle exceptions. Statistics could not handle long-distance dependencies or meaning. Neural networks learned representations, but still predict likely continuations rather than understanding the way you do. This history matters because it explains where we are today, and the pipeline in the next chapter reflects decades of learning about what works.

    How it works

    Section 1 (Figure 3.1) covers rule-based systems: formal grammar after Noam Chomsky, ELIZA’s pattern matching, Georgetown-IBM’s 60 sentences and six rules, SHRDLU’s blocks world. Section 2 (Figure 3.2) covers the statistical revolution: corpora, n-grams, probabilities instead of rules, machine learning for part-of-speech tagging trained on human-tagged sentences, speech recognition, spelling correction, information retrieval, and evaluation on held-out test data.

    The tools

    Tool 1: Tell the rules era. In 1954, the Georgetown-IBM experiment demonstrated a small system translating 60 Russian sentences into English using a dictionary and six grammar rules. In 1966 Joseph Weizenbaum at MIT built ELIZA, designed to mimic a psychotherapist in a text conversation. It did not understand you at all. It used clever pattern matching: if you typed ‘I am sad about my mother’, ELIZA would look for the pattern ‘I am X’ and respond with ‘How long have you been X?’ or ‘Tell me more about your family.’ ELIZA taught two lasting lessons: even simple rules can create a powerful illusion of understanding when they mirror human conversational patterns, and illusion is not understanding. ELIZA had no model of the world, no memory of what sadness means, no concept of a mother. It was syntax without semantics. SHRDLU, built in the late 1960s by Terry Winograd, could understand and act on commands about a blocks world, a virtual table with coloured blocks. You could say ‘Pick up the red block’ and it would do it in simulation. Within that tiny, restricted world, it seemed incredibly intelligent.

    Step by step

    The end-of-chapter exercise as a numbered protocol, in order.

    1. Timeline mapping: place ELIZA 1966, Georgetown-IBM 1954, SHRDLU 1960s, statistical revolution 1990s, Word2Vec 2013, Transformer 2017 on a timeline and note one lesson from each.
    2. Compare rule-based vs statistical approach for handling I want to eat, and write how each would predict the next word.
    3. Explain why neural embeddings solved the synonym problem that bag-of-words could not, using example car and automobile.
    4. Debate: why did hand-written rules scale poorly for real-world language? Give two reasons with examples of exceptions. No time is stated in the book for this exercise.

    Worked example

    The book’s worked example is the next-word test. Given ‘I want to eat’, a rule-based system might say any noun could come next. A statistical system looks at a corpus and counts: in a corpus of restaurant reviews, after ‘I want to eat’, the next word is ‘pizza’ 15% of the time, ‘sushi’ 12% of the time, ‘something’ 10% of the time. It can then predict that ‘pizza’ is more likely than ‘aeroplane’, not because of a rule, but because of observed frequency.

    A real example from the book

    Case Study – Chapter 3: From ELIZA to LLM: How Metro Bank Evolved Its Assistant. No person age is given. Metro Bank launched a help assistant in 1970s style, using hand-written rules: if message contains balance, show balance. It worked for 20 phrases but collapsed with What is my balance after fees last Tuesday? Too many exceptions. In the 1990s, they switched to statistical models trained on 50,000 anonymised support chats. The model learned that balance after fees often meant available balance, using n-gram frequencies. Accuracy jumped from 45 percent to 72 percent. In 2018, they adopted embeddings and intent classification, understanding that checking my dough and balance inquiry are similar because dough and balance share contexts in financial slang. In 2022, they deployed a Transformer-based large language model fine-tuned on banking data.

    Mistakes to avoid

    • Thinking ELIZA understood its users. Correction: it was syntax without semantics, and illusion is not understanding.
    • Thinking more rules would eventually cover language. Correction: hand-writing rules scales poorly, for every rule there are dozens of exceptions.
    • Thinking statistical methods understand meaning. Correction: they were flexible but shallow and struggled with long-distance dependencies.
    • Thinking LLMs understand the way you do. Correction: they predict likely continuations based on patterns in data at a scale no human could ever read.
    • Forgetting human oversight for high-risk actions. Correction: Metro Bank kept human oversight, showing history informs responsible deployment.
    • Judging a system by whether it seems intelligent. Correction: measure accuracy on held-out test data, as the statistical era introduced.

    What not to do

    • Do NOT mistake ELIZA’s illusion of understanding for understanding.
    • Do NOT try to cover real-world language with hand-written rules alone.
    • Do NOT assume statistical counting captures meaning.
    • Do NOT claim an LLM understands the way you do.
    • Do NOT deploy without human oversight for high-risk actions.
    • Do NOT judge intelligence by seeming intelligent instead of measuring accuracy.

    Low-energy mode

    Place three dates on a timeline from memory: ELIZA 1966, Word2Vec 2013, Transformer 2017, and say one lesson for each. That counts.

    If you freelance

    This is one way to apply the idea, not a passage from the book. A freelancer can use the three-era story to explain to a client why their old rule-based chatbot collapses on real messages: rules were precise but brittle, and the fix is a system that learns patterns from real examples, with human oversight kept for high-risk actions.

    How to know it worked

    You placed ELIZA 1966, Georgetown-IBM 1954, SHRDLU 1960s, statistical revolution 1990s, Word2Vec 2013, and Transformer 2017 on a timeline with one lesson each. You explained the pizza 15 percent, sushi 12 percent, something 10 percent example. You explained why embeddings solved the synonym problem with car and automobile.

    Key takeaways

    • If we can write down the rules of language, we can teach a machine to follow them.
    • ELIZA taught the field two lasting lessons. First, even simple rules can create a powerful illusion of understanding when they mirror human conversational patterns. Second, illusion is not understanding.
    • It was brilliant in a dollhouse, helpless outside.
    • If the statistical era taught machines to count, the neural era taught them to learn representations – to build internal maps of meaning.

    Try it today

    Do Exercise – Chapter 3: History Evolution today (no time stated in the book, see Exercise).

    End of Chapter Exercise – Chapter 3: History Evolution. No time stated in the book.

    1. Timeline mapping: place ELIZA 1966, Georgetown-IBM 1954, SHRDLU 1960s, statistical revolution 1990s, Word2Vec 2013, Transformer 2017 on a timeline and note one lesson from each.
    2. Compare rule-based vs statistical approach for handling I want to eat, and write how each would predict the next word.
    3. Explain why neural embeddings solved the synonym problem that bag-of-words could not, using example car and automobile.
    4. Debate: why did hand-written rules scale poorly for real-world language? Give two reasons with examples of exceptions.

    Frequently asked questions

    Why does trying harder not work here?
    Trying harder to write more rules fails here by the chapter’s own evidence: hand-writing rules scales poorly because language in the wild is too vast, too varied, too full of idioms, slang, and creative use to be captured by rulebooks alone.

    How do I know it worked?
    You placed ELIZA 1966, Georgetown-IBM 1954, SHRDLU 1960s, statistical revolution 1990s, Word2Vec 2013, and Transformer 2017 on a timeline with one lesson each. You explained the pizza 15 percent, sushi 12 percent, something 10 percent example. You explained why embeddings solved the synonym problem with car and automobile.

    What if it does not work?
    If the eras blur together, then anchor on the three verbs: rules were written, statistics were counted, neural networks learned representations. If you cannot explain attention, then use the book’s own line: when you read a sentence, you do not give equal weight to every previous word; some words matter more.