AI
Natural Language Processing (NLP): A Plain Guide
Natural language processing (NLP) lets computers understand and generate human language. How it works, key tasks, examples, NLP vs LLMs, and how to start.
Natural language processing (NLP) is the field of artificial intelligence that lets computers work with human language: reading text, understanding speech, extracting meaning, translating, summarizing and generating new text. It sits where computer science, linguistics and machine learning meet. You use it every day in search engines, spam filters, voice assistants, autocorrect, translation apps and chatbots. Today's large language models are the most powerful NLP systems ever built, but NLP is broader than LLMs: it also includes smaller, faster, specialized models for tasks such as classifying text or pulling names out of documents.
This guide explains what natural language processing is, how it evolved, how NLP works step by step, the main tasks, natural language processing examples by industry, NLP vs NLU vs NLG, NLP vs LLM, the tools to use, and how to get started with natural language processing with Python.
What Is Natural Language Processing?
Human language is hard for computers. Words have several meanings ("bank" of a river or a bank account), sentences can be read different ways, meaning depends on context and tone, and people constantly misspell, abbreviate and invent new words. Natural language processing is the set of methods that turn this messy language into something a computer can analyze, and turn computer output back into fluent language.
NLP covers both written text and speech. Speech is usually converted to text first (speech recognition), processed, and sometimes turned back into speech (text-to-speech).
A Short History of NLP
| Era | Approach | Milestones |
|---|---|---|
| 1950s–1980s | Rules written by experts | Early machine translation experiments; ELIZA, a conversation program developed at MIT by Joseph Weizenbaum between 1964 and 1967 |
| Late 1980s–2000s | Statistical methods learned from data | Probabilistic models for tagging, parsing and translation; spam filters |
| 2010s | Neural networks and word embeddings | Word embeddings such as word2vec (2013) represent words as vectors; recurrent networks for translation |
| 2017 onward | Transformers and pre-trained models | The transformer architecture (2017), BERT (2018) and the GPT series show that one pre-trained model can be adapted to many tasks |
| 2020s | Large language models | Chat assistants and LLMs that handle many NLP tasks from instructions alone |
ELIZA is a famous lesson from the early days: it imitated a therapist by matching patterns and reflecting users' words back, and many users believed it understood them, despite Weizenbaum's insistence that it didn't. The gap between seeming to understand and actually understanding still matters with today's chatbots.
How Natural Language Processing Works
Modern NLP systems usually follow some version of these steps:
- Text input and cleaning: collect the text, fix encoding issues, and sometimes remove noise such as HTML.
- Tokenization: split text into units called tokens, which may be words, parts of words or characters. Large language models use subword tokens, so a rare word may become several tokens.
- Representation: turn tokens into numbers. Older systems counted words; modern ones use embeddings, vectors that place words and sentences with similar meanings close together.
- Modeling: a model, today usually a neural network, processes those vectors to produce an output: a label, a set of extracted items, a translation or new text.
- Output and post-processing: turn the model's output into something useful, like a category, a highlighted name in a document or a reply.
Classic NLP pipelines also include steps such as lemmatization (reducing words to their base form, like "running" to "run"), part-of-speech tagging (noun, verb, adjective) and dependency parsing (which word relates to which). Large language models learn much of this implicitly, but these steps remain useful in fast, specialized systems.
The key change of the last decade is the transformer model, whose attention mechanism lets every word in a sentence take every other word into account. That made it possible to pre-train one model on huge amounts of text and then adapt it to many tasks.
Main NLP Tasks
| Task | What it does | Everyday example |
|---|---|---|
| Text classification | Assigns a label to a piece of text | Spam detection, routing support tickets |
| Sentiment analysis | Detects positive, negative or neutral opinion | Analyzing product reviews |
| Named entity recognition (NER) | Finds names of people, companies, places, dates, amounts | Extracting parties and amounts from contracts |
| Part-of-speech tagging and parsing | Labels word types and sentence structure | Grammar checkers |
| Machine translation | Converts text between languages | Translation apps |
| Summarization | Shortens text while keeping key points | Meeting and article summaries |
| Question answering | Answers questions from a text or knowledge base | Help-center search, chat assistants |
| Information retrieval and search | Finds relevant documents for a query | Web and site search |
| Text generation | Produces new text | Writing assistants, chatbots |
| Speech recognition and synthesis | Converts speech to text and back | Voice assistants, dictation |
| Topic modeling and clustering | Groups documents by theme | Organizing large document collections |
| Coreference resolution | Works out which words refer to the same thing | Knowing that "she" in one sentence means "Maya" in the previous one |
NLP vs NLU vs NLG
NLP vs NLU vs NLG is a common source of confusion. The three terms describe different scopes:
| Term | Stands for | Focus | Example |
|---|---|---|---|
| NLP | Natural language processing | The whole field of computers working with language | Any of the tasks above |
| NLU | Natural language understanding | Extracting meaning and intent from language | Working out that "book me a table for two at 7" is a restaurant booking request with a party size and time |
| NLG | Natural language generation | Producing language from data or meaning | Writing "Your table for two is booked for 7 pm" from the booking data |
NLU and NLG are parts of NLP. A chatbot needs both: NLU to understand the user and NLG to reply. Large language models do both in one model, which is one reason the distinction matters less than it used to.
NLP vs LLM
People often ask about NLP vs LLM as if they were alternatives. They aren't: a large language model is one kind of NLP system, the most general one so far. The practical question is whether to use an LLM or a smaller, specialized NLP model for a given task:
| Large language model | Specialized NLP model | |
|---|---|---|
| Examples | GPT, Claude, Gemini, Llama and other open models | spaCy pipelines, fine-tuned BERT-style classifiers, dedicated NER models |
| Setup | Write a prompt; no training needed for many tasks | Needs training data or a pre-trained model for the task |
| Flexibility | Very high: one model handles many tasks | One task per model |
| Cost per request | Higher, especially at large volume | Very low, often runs on a CPU |
| Speed | Slower | Fast, suitable for millions of documents |
| Consistency | Can vary between runs; needs validation | Predictable outputs |
| Best for | Complex, varied or low-volume tasks; prototypes; text generation | High-volume, well-defined tasks like classification and extraction |
A common pattern is to prototype with an LLM, then move stable, high-volume tasks to a small specialized model once you know exactly what you need. Our explainer on what an LLM is covers how these models work.
Natural Language Processing Examples
Natural language processing examples by industry:
- Customer service: chatbots and virtual agents, automatic ticket routing, sentiment tracking across support conversations.
- Healthcare: extracting diagnoses and medications from clinical notes, transcribing doctor-patient conversations, searching medical literature.
- Finance: analyzing news and earnings calls, flagging risky language in communications, processing loan and insurance documents.
- Legal: contract review, finding relevant clauses, searching case law.
- E-commerce: product search, review analysis, generating product descriptions.
- Human resources: screening job applications (carefully, given bias risks), analyzing employee feedback.
- Marketing: social listening, brand sentiment, content generation.
- Software: code search and AI coding assistants, which apply language modeling to programming languages.
- Accessibility: captions, screen readers with natural-sounding voices, real-time translation.
Natural Language Processing With Python
Python is the main language for NLP, thanks to mature libraries:
| Library | Best for |
|---|---|
| spaCy | Fast, production-ready pipelines: tokenization, tagging, parsing, named entity recognition |
| Hugging Face Transformers | Thousands of pre-trained transformer models for classification, NER, translation, summarization and more |
| NLTK | Teaching and classic NLP techniques, with datasets and tutorials |
| scikit-learn | Classic machine learning on text features (for example TF-IDF with a linear classifier) |
| Gensim | Topic modeling and word embeddings |
| LLM SDKs | Calling large language models through an API |
Here's named entity recognition with spaCy, using the example from spaCy's own documentation. It loads a small English pipeline and prints each entity with its position and type:
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)According to spaCy's documentation, the model labels "Apple" as an organization (ORG), "U.K." as a geopolitical entity (GPE) and "$1 billion" as money (MONEY). It also warns that such models are statistical and depend on what they were trained on, so they won't always be right and may need tuning for your text.
How Large Language Models Changed NLP
Before large language models, most NLP projects followed the same recipe: collect labeled data for one task, choose features or a model architecture, train it, and repeat for every new task. Pre-trained transformers changed that. A model first learns general language from huge amounts of text, then adapts to a task in one of three ways:
| Approach | How it works | When it fits |
|---|---|---|
| Fine-tuning | Continue training the pre-trained model on labeled examples for your task | Stable, high-volume tasks where you have training data |
| Prompting (zero-shot) | Describe the task in plain language and let the model do it | Quick prototypes and tasks that change often |
| Few-shot prompting | Add a handful of examples to the prompt | When instructions alone give inconsistent results |
Large language models also blurred the old boundaries between tasks. One model can classify, extract, summarize, translate and answer questions, often in the same request. That made NLP far more accessible to developers without machine learning backgrounds, but it also shifted the hard work toward evaluation, cost control and handling mistakes, because a fluent answer isn't always a correct one.
How NLP Systems Are Evaluated
Every NLP system needs a way to measure quality, and the right metric depends on the task:
| Task | Common metrics | What they capture |
|---|---|---|
| Classification and sentiment | Accuracy, precision, recall, F1 score | How often labels are right, and how errors split between false alarms and misses |
| Named entity recognition | Precision, recall and F1 per entity type | Whether the right spans get the right labels |
| Translation | BLEU, chrF, plus human ratings | Overlap with reference translations; humans judge fluency and meaning |
| Summarization | ROUGE, plus human or model-graded review | Overlap with reference summaries; whether key facts are kept |
| Question answering | Exact match, F1 over answer words | Whether the answer matches the expected one |
| Open-ended generation | Human review, rubric-based grading by a strong model | Helpfulness, accuracy, tone |
Automatic metrics are cheap and repeatable but miss nuance; human review is accurate but slow. Most teams combine a fixed test set with automatic scores, spot checks by people, and tracking of real user feedback after launch.
NLP Beyond English
Most NLP research and training data is in English, and quality drops for many other languages. Several issues are specific to them:
- Tokenization: languages that join many meanings into one word, such as Turkish or Finnish, or that use non-Latin scripts, such as Arabic, are often split into more tokens, which can make models slower, more expensive and less accurate.
- Right-to-left text and mixed scripts: Arabic and Hebrew need correct handling of text direction, especially when mixed with numbers or English terms.
- Dialects and informal writing: social media text, regional dialects and transliteration (writing a language in another script) confuse models trained on formal text.
- Less labeled data: fewer datasets exist for training and evaluating specialized models.
Multilingual models, trained on many languages at once, have narrowed the gap, and large language models handle major languages well. For specialized tasks in less common languages, testing on real local data before deploying remains essential.
NLP and Search: From Keywords to Meaning
Search is one of NLP's oldest and most important applications. Classic search matched keywords, ranking documents by how often and where query words appeared. Modern semantic search uses embeddings to match meaning, so a query for "how to cancel my plan" can find a page titled "Ending your subscription". Many systems combine both, because keyword matching is still best for exact names, codes and rare terms.
This is also the foundation of retrieval-augmented generation (RAG), where a search step finds relevant documents and a language model answers using them. For most companies, the most valuable NLP project isn't a chatbot from scratch; it's making their own documents searchable and answerable.
Challenges and Limits of NLP
- Ambiguity: the same words can mean different things in different contexts.
- Sarcasm, irony and humor: hard to detect even for people.
- Languages with fewer resources: most training data is in English and a few other languages, so quality drops for many others.
- Domain language: medical, legal and technical text needs specialized data or models.
- Bias: models learn biases present in their training data, which can lead to unfair outcomes.
- Hallucinations: generative models can produce fluent but false text, so outputs need checks.
- Privacy: text often contains personal or confidential information.
How to Get Started With NLP
- Learn Python basics and how to work with text strings and files.
- Try classic methods first: bag-of-words and TF-IDF features with a simple classifier in scikit-learn teach the fundamentals.
- Use spaCy for tokenization, part-of-speech tagging and named entity recognition on real text.
- Move to transformers: use pre-trained models from Hugging Face for classification and NER, and fine-tune one on a small labeled dataset.
- Work with LLMs: learn prompting, structured outputs and evaluation.
- Build a project: classify support tickets, analyze reviews, or build a small search engine over your own documents.
- Read a textbook: Jurafsky and Martin's "Speech and Language Processing" is a widely used reference, with a draft edition available online from Stanford.
FAQ
What is natural language processing in simple terms?
Natural language processing is the part of AI that lets computers understand, analyze and produce human language, written or spoken. It powers search engines, translation apps, spam filters, voice assistants and chatbots.
What are examples of natural language processing?
Common examples include spam filters, autocorrect, voice assistants, machine translation, chatbots, sentiment analysis of reviews, automatic summaries, search engines and tools that extract names and amounts from documents.
What is the difference between NLP and LLM?
NLP is the whole field of computers working with language. A large language model is one type of NLP system: a very large neural network trained on huge amounts of text that can perform many language tasks from instructions. Smaller NLP models are often faster and cheaper for specific tasks.
What is the difference between NLP, NLU and NLG?
NLP is the overall field. NLU (natural language understanding) focuses on extracting meaning and intent from language, and NLG (natural language generation) focuses on producing language. Both are parts of NLP, and chatbots use both.
Is NLP part of machine learning?
Modern NLP relies heavily on machine learning, especially deep learning, but NLP is a broader field that also draws on linguistics and rule-based methods. Early NLP systems used hand-written rules; today most use models learned from data.