Steps in Natural Language Processing (NLP): A Practical Pipeline
Natural Language Processing (NLP) typically follows an end-to-end pipeline: convert raw text into a structured representation, learn patterns, then produce task outputs. A common high-level sequence includes Text preprocessing, Tokenization, Linguistic annotation, Feature representation, Modeling, and Evaluation.
Below is a concise, widely used set of steps—shown at the right level to cover both “classic” NLP workflows and modern transformer-based systems.
Key idea: Different tasks (sentiment, NER, translation, QA) reuse most of these steps but vary in the details of annotation, representation, decoding, and metrics.2
Footnotes
-
Stanford CS224N (Natural Language Processing with Deep Learning) - Course Notes/Topics: tokenization, parsing/NER, and overall NLP process. https://web.stanford.edu/class/cs224n/ ↩
-
Jurafsky & Martin / NLP overview concepts (preprocessing, modeling, evaluation; TF-IDF/embeddings and metrics). https://web.stanford.edu/~jurafsky/slp3/ ↩
NLP Pipeline Overview (preprocessing → features → models)
Core steps in an NLP workflow
- 1Step 1
Specify the NLP goal (e.g., classification, NER, translation, summarization), the input type (text vs. speech), and the output format (label set vs. generated text).
- 2Step 2
Clean/normalize text: remove noise, standardize casing, handle punctuation, normalize unicode, and optionally filter stop words. Also manage document structure (sentences, paragraphs).
- 3Step 3
Split text into tokens (words or subwords) and map them consistently to the model vocabulary; many modern systems use subword tokenization.
- 4Step 4
Add intermediate structure such as part-of-speech (POS) tags, dependency parses (Dependency parsing), and named entities (Named entity recognition).
- 5Step 5
Convert tokens/structures into numeric vectors (e.g., TF-IDF for classic ML, or embeddings such as transformer hidden states).
- 6Step 6
Train a model to map representations to outputs; then run inference to produce predictions (class scores, entity spans, or generated sequences).
- 7Step 7
Transform raw model outputs into the final format (e.g., choose labels, extract spans, convert token IDs back to text, apply constraints).
- 8Step 8
Measure performance with task-specific metrics (e.g., accuracy/F1 for classification/NER, BLEU/ROUGE for generation). Iterate on preprocessing, representation, labeling, and model design based on error analysis.
Brief explanation of each step
- Task definition: Determines the pipeline branches (what annotations you need, what decoding you use, which metrics matter).
- Preprocessing: Reduces variability and noise so downstream steps and models focus on meaning-bearing signals.
- Tokenization: Provides the atomic units a model can process consistently; modern NLP often tokenizes into subword units to handle rare words and morphology.
- Linguistic annotation (optional, but common): Adds interpretable structure (POS tags, dependencies, named entities) that can improve performance or enable structured prediction.2
- Feature representation: Converts text (and annotations) into numeric inputs. Classic approaches use sparse features (e.g., bag-of-words, TF-IDF), while modern systems use contextual embeddings.
- Modeling: Learns patterns from labeled data (or performs inference in pre-trained models).
- Decoding/post-processing: Converts model outputs into task-appropriate predictions or text, often handling formatting and constraints.
- Evaluation & iteration: Uses metrics that align with the task objective and guides improvements.
Common “task switch”: If your output is a label, you typically emphasize classification training and metrics like accuracy/F1. If your output is generated text, decoding quality and generation metrics become central.
Footnotes
-
Stanford CS224N (Natural Language Processing with Deep Learning) - Course Notes/Topics: tokenization, parsing/NER, and overall NLP process. https://web.stanford.edu/class/cs224n/ ↩ ↩2 ↩3 ↩4
-
Jurafsky & Martin / NLP overview concepts (preprocessing, modeling, evaluation; TF-IDF/embeddings and metrics). https://web.stanford.edu/~jurafsky/slp3/ ↩ ↩2 ↩3 ↩4 ↩5
-
spaCy documentation (pipeline components like tagging/NER as structured steps). https://spacy.io/usage/processing-pipelines ↩
Practical mental model
Think of NLP as: normalize → represent → predict → evaluate. Annotation and linguistic parsing are “representation upgrades,” not mandatory steps for every modern approach.
Be careful mixing evaluation regimes
Generation tasks use metrics like BLEU/ROUGE, while extraction/classification tasks often use F1/accuracy. Using the wrong metric can lead to misleading conclusions about quality.
Footnotes
-
Jurafsky & Martin / NLP overview concepts (preprocessing, modeling, evaluation; TF-IDF/embeddings and metrics). https://web.stanford.edu/~jurafsky/slp3/ ↩
Typical NLP development lifecycle
Define task & data requirements
1) Problem setupCollect examples and define target output and evaluation metric."
Preprocess + represent
2) Pipeline designDecide tokenization, normalization, and feature/embedding strategy."
Train/infer
3) LearningFit a model and run inference for predictions."
Evaluate + iterate
4) Quality assuranceCompute metrics, inspect errors, refine preprocessing/labels/model."
Where each step matters most (by common NLP task types)
Relative emphasis—higher means that step is more critical for that task style.
Common variations you’ll encounter
NLP pipeline quick checks
Knowledge Check
Which sequence best describes a typical end-to-end NLP pipeline?