liveBook · Manning

Pipeline

As explained in Natural Language Processing in Action, Second Edition

An NLU pipeline is a sequence of natural-language-understanding stages that transform text into an interpretation or decision.

An NLP pipeline passes natural-language text through processing stages until it produces data, a decision, or a reply. The stages matter because words do not always have one clear meaning: “The chicken is ready to eat” might describe a hungry bird or dinner. A pipeline must turn that ambiguity into something an application can use. section 1.1

For a chatbot, five cooperating subsystems provide a practical design:

  • Parse text into structured features. section 1.8
  • Analyze features for properties such as sentiment, grammar, and meaning. section 1.8
  • Generate candidate replies with templates, search, or language models. section 1.8
  • Decide which reply best advances the user’s conversational goal. section 1.8
  • Store conversation history and relevant knowledge in a database for later decisions. section 1.8

Not every application needs every subsystem or a deep model. A small intent recognizer can split a message into words, check for a greeting, and choose between two replies. More elaborate pipelines add layers such as part-of-speech tagging and entity relationships; deeper layers can help populate a knowledge base for inference. A useful question is how much processing the task needs, not how many stages can be added. section 1.5.1 section 1.9

Inspect an intermediate result

Run `nlp = spacy.load('en_core_web_sm')`, then `doc = nlp(text)` and `[tok.text for tok in doc]`. The resulting tokens let you inspect an early transformation before using later labels or decisions. Splitting a contraction into separate tokens can help treat “isn’t bad” like “is not bad” in search or sentiment analysis; whether that change is desirable depends on the application. section 2.1.4

Pipelines can also combine different kinds of processing. A question-answering system can join text search, semantic search, and an LLM: fast retrieval narrows the documents, while semantic matching helps find relevant ones. In a generative chatbot, a prompt and conversation memory help shape replies, but fluent output still needs checking: a math-tutor example praises an incorrect answer while giving the correct next number. Design the stages around the task, and inspect both intermediate outputs and final behavior. section 10.3 section 12.5.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines a five-subsystem chatbot design and explores processing layers, while allowing simpler applications to use only a few algorithms.
Examples
Uses a two-intent greeting recognizer, spaCy token inspection, and a chatbot with conversation memory and a faulty math reply.
What it assumes
Assumes enough Python familiarity to follow short examples while defining pipeline stages and their roles.
What you can do after
Build it from scratch by combining suitable parsing, analysis, generation, decision, and memory components for a chatbot.
How it connects
Connects feature extraction, sentiment analysis, knowledge bases, response generation, information retrieval, semantic search, and large language models.

Also explained in

Compare how 48 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.