By Sagi Shaier · 6 November 2026 · 14 min read
NLP tasks explained, and how to frame your problem as one
The six common families of NLP tasks, seven questions that turn a product request into a build plan, and five worked requests from support tickets to report summaries.
An NLP task is a named kind of job a system does with text, defined by what goes in and what comes back out. Sorting reviews into negative and not negative is one task, and pulling every person's name out of a contract is another. Naming the task tells you what data to collect, what the model has to output and how to measure whether it works, so it is the first step in turning a vague request into something you can build.
Language models work with tokens, which are whole words or pieces of words. This post says "word" in a few places to keep the examples simple.
Start from what the user needs back
Requests rarely arrive as task names. They sound like "find the best policy page", "answer these questions using this contract", "find similar tickets" or "pull every date from this paragraph". The first step is to ask what the system should return:
- "find the best policy page" returns pages sorted by relevance, which is retrieval
- "answer from this contract" returns an answer taken from a passage, which is question answering
- "find similar tickets" returns lists of numbers that can be compared, which is feature extraction
- "pull every date" returns marked stretches of the text, which is token classification
The returned object points to the task family. Task names last longer than any one model design, because models and tools change quickly while the shape of what a user needs back changes less often.

The six task families
Six families cover many common NLP requests. Each is defined by what it returns, not by one required model architecture.
- Text classification returns one or more labels for a whole text, such as "negative" for a review or "billing" for a support ticket.
- Token classification returns a label for each token, or marked stretches of the text called spans, such as every person's name in a document.
- Question answering returns an answer to a question, either copied from a passage or written from the context.
- Feature extraction returns a vector for a text, a list of numbers, so that another system can compare texts. Texts with similar meaning get vectors that point in similar directions.
- Retrieval and ranking returns the texts that best match a query, sorted with the best first.
- Text generation returns new text, such as a summary, a translation or a reply.

Seven questions that turn a task into a build plan
Naming the family is a start, and it still leaves a lot open. "Text classification" does not say what the input looks like, which labels exist, how a prediction is made or how success is measured. Seven questions pin those down:
- Input: what text goes in? It can be one sentence, a question plus a passage or a whole document.
- Target: what correct answer are predictions compared against? A label from a fixed set, a tag per token or a start and end position in a passage. For retrieval and generation it is a ranking or a piece of text.
- Prediction: what raw output does the model compute? One score per class, one score per tag per token or scores over positions in a passage. Retrieval computes similarity scores, and generation computes a probability for each possible next token.
- Data: what examples do training and evaluation need? Text paired with a label, a question and passage paired with an answer span, or a source text paired with a target text.
- Training: if the model's weights are updated, what loss moves predictions toward targets? If a large language model is used without training it for this task, this step becomes the instructions and examples in the prompt.
- Inference: what rule turns the raw output into the answer the user gets? Take the highest-scoring class, choose the best span, return the top documents or generate tokens.
- Evaluation: what metric scores the predictions? The wrong metric can make a weak system look fine.
The questions fall into three stages. Task setup covers input and target. Model and training covers prediction, data and training, and the last stage is inference and evaluation.

A worked example: find the negative reviews
A product manager asks: "As new reviews come into our website, find the negative ones so we can see what customers want fixed." That request does not say whether to use a small classifier, a large language model, hand-written rules or a mix. Usually there is more than one reasonable approach. You try a few and keep the one that fits the data, cost, speed and quality the product needs.
What comes back. The manager wants reviews that count as negative, not a summary or a ranked list. Each review gets one label, so this is text classification. A simple version has two labels, negative and not negative. A richer version uses negative, neutral and positive, which is more useful if the team also wants trend reports.
Input and target. The input is one review, such as "the app crashes every time I open the cart". The target is the correct label for that review.
Prediction. One option is a trained classifier that reads the review and outputs one score per label, such as negative: 2.8 and not negative: -0.4. Another is a large language model asked to reply with one of the allowed labels. Both can feed the same product behavior, which is to keep the reviews predicted as negative. They differ in cost and speed, in how much labeled data they need and in how easy they are to evaluate.

Data and training. A trained classifier needs rows of (review_text, label). The loss compares the classifier's scores with the correct label, and training updates the weights over many rows. A large language model can instead get a prompt with a few labeled examples and instructions for edge cases, which shape its answers without changing its weights. Either way, the examples should look like the reviews the site actually gets. Movie-review data may have nothing about app crashes, late deliveries or refunds.
Inference. For a classifier, take the highest-scoring label and send the review to the complaint queue if that label is negative. If flagging a review by mistake is costly, add a threshold so that only confident predictions get flagged.
Evaluation. Accuracy, the share of reviews labeled correctly, can hide problems when most reviews are not negative. Three other numbers help. Precision is the share of flagged reviews that really were negative. Recall is the share of negative reviews the system found. F1 combines the two into one number that is high only when both are.
The code below uses a made-up test set of 20 reviews with 3 negative ones. The model flags 2 reviews, and only one of them is really negative:
1# 1 = negative review, 0 = not negative
2true = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
3pred = [1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
4
5tp = sum(t == 1 and p == 1 for t, p in zip(true, pred))
6fp = sum(t == 0 and p == 1 for t, p in zip(true, pred))
7fn = sum(t == 1 and p == 0 for t, p in zip(true, pred))
8
9accuracy = sum(t == p for t, p in zip(true, pred)) / len(true)
10precision = tp / (tp + fp)
11recall = tp / (tp + fn)
12f1 = 2 * precision * recall / (precision + recall)
13print(f"accuracy {accuracy:.2f} precision {precision:.2f} recall {recall:.2f} F1 {f1:.2f}")
14
15always_not_negative = [0] * len(true)
16acc_lazy = sum(t == p for t, p in zip(true, always_not_negative)) / len(true)
17print(f"flag nothing: accuracy {acc_lazy:.2f}, recall 0.00")1accuracy 0.85 precision 0.50 recall 0.33 F1 0.40
2flag nothing: accuracy 0.85, recall 0.00tp counts true positives (negative reviews that were flagged), fp false positives (flagged reviews that were fine) and fn false negatives (negative reviews that were missed). The model's accuracy is 0.85, and a model that flags nothing at all also gets 0.85. Its recall of 0.33 shows that it found only one of the three negative reviews, which accuracy hides.
With every question answered, the vague request has become a plan:

Once the questions are answered, you also know what to search for. A model hub such as Hugging Face may already have sentiment classifiers or review datasets close to the task. Compare them with the checklist: do their inputs look like your reviews, do their labels match your target, and what did they train and evaluate on?
The same questions for a support chatbot
A support lead asks for "a chatbot on our website so customers can ask about shipping, refunds and account settings". The customer asks a question and expects an answer, so this is question answering. The family alone still leaves three different builds:
- Extractive QA scores every token in a policy page as a possible start or end of the answer, then copies the best span.
- Retrieval first scores help articles against the question, then returns the best article or passes it to another model.
- Grounded generation finds relevant help articles, writes an answer token by token from them, then checks that the answer is supported by those articles.
These serve the same request with different raw outputs, different data and different ways to fail. Extractive QA needs rows of (question, passage, answer_span), retrieval needs (question, relevant_article), and a grounded generator needs (question, source_docs, supported_answer). The evaluation has to score the answer the customer sees. Did it address the question, was it supported by the source, and did the system decline when the source had no answer?

Framing a task as text generation
A large language model can handle many of these tasks by writing the answer as text. It still predicts one token at a time. The prompt tells it what those tokens should be: a label, a JSON object, an answer or a rewritten message.
- Classification: ask for one label word, such as
positiveornegative. - Extraction: ask for structured output, such as JSON with lists of
personsandorganizations. - Generative QA: give a question and a passage, and ask for a one-sentence answer.
- Rewriting: ask the model to change the text while keeping its meaning, such as making a message more formal.
![Generated outputs still have shapes: the prompt Reply with one label: positive or negative gives positive, Return JSON with persons and organizations gives {persons: [Alice], organizations: [Acme]}, Answer using the passage, one sentence gives The refund window is 30 days, and Rewrite this message more formally gives I would appreciate a response.](images/generation_framing_examples.png)
The task name still decides how the output gets checked. A generated label should be scored like a label, generated JSON should be validated as JSON, and a generated answer should be checked against the source text.
The output is also free text. A classifier's highest score always points to a valid class. A language model asked for positive or negative might write Positive., positive sentiment or a full sentence. So the code around the model has to parse the string and reject anything that is not one of the allowed labels:
1ALLOWED = {"positive", "negative"}
2
3def parse_label(generated):
4 """Return the allowed label in a generated string, or None if there isn't exactly one."""
5 words = generated.lower().replace(".", " ").replace(",", " ").split()
6 found = {w for w in words if w in ALLOWED}
7 return found.pop() if len(found) == 1 else None
8
9outputs = ["negative", "Positive.", "positive sentiment", "I think it's negative.",
10 "It is not positive, it is negative", "mixed"]
11for text in outputs:
12 print(f"{text!r:40} -> {parse_label(text)}")1'negative' -> negative
2'Positive.' -> positive
3'positive sentiment' -> positive
4"I think it's negative." -> negative
5'It is not positive, it is negative' -> None
6'mixed' -> NoneThe parser accepts the outputs that contain exactly one allowed label and returns None for the rest, so the calling code can retry the request or log it instead of passing an invalid label downstream. A tighter prompt, such as "answer with exactly one word: positive or negative", makes parsing easier. It does not remove the need to check the result.

For high-volume systems, a task-specific model is still worth considering. A classifier is often smaller, faster and cheaper than a large language model, and its outputs are easier to score automatically.
Data format follows the task
Each family needs its own shape of training data, and getting it wrong early is expensive to fix later.
- Text classification needs a text paired with a label.
- Token classification needs a label for every token. One example is part-of-speech tagging, where each word gets its grammatical role, such as noun or verb.
- Extractive question answering needs a question, a passage and the exact span in the passage that answers it.
- Sentence similarity needs pairs of texts with a similarity score or a same-meaning label.
- Summarization and other generation tasks need a source text paired with the exact target text.
A team that collected only one label per document cannot train a token classifier without labeling every token in every document again. A team that collected single sentences cannot train a similarity model without pairing them and scoring each pair first.

Five requests, five tasks
Route a support ticket to the right team
The task is intent classification, a kind of text classification. Each ticket gets one label from a fixed list of queues, such as billing, password reset or cancellation. The training data is tickets paired with the correct queue. The model outputs one score per queue, and softmax turns those scores into probabilities that add up to 1. Inference picks the queue with the highest probability, or marks the ticket as out of scope when even the top probability is below a threshold.
Some queues get far more tickets than others, so the metric to watch is macro-averaged F1. It computes F1 for each queue separately and then averages them with equal weight, so a busy queue with good results cannot hide poor results on a rare one.

Find every person and organization in a contract
A redaction tool needs to black out names, so the task is named entity recognition (NER), a kind of token classification. Every token gets its own label in the BIO format: B-PER marks the first token of a person's name and I-PER each token after it inside the name, B-ORG and I-ORG do the same for organizations, and O marks everything else.
Inference turns each B tag and the I tags right after it into one entity span, the exact stretch of text to black out. The metric is span-level F1, where a predicted name counts as correct only if both its start and its end match. A redaction that catches "Alice" and misses "Johnson" leaves part of the name visible.

Answer a question by quoting the policy page
The request is to answer customers by quoting the exact sentence from the return policy, not a paraphrase. That is extractive question answering. The training data is a question, the policy passage and the exact span that answers it. The model outputs a start score and an end score for every token in the passage, and inference picks the start and end pair with the highest combined score and returns the text between them.
The metric is exact match, which is 1 when the returned span is identical to the correct one and 0 otherwise. It is often reported with token F1, which gives partial credit for the words the two answers share.

Show the FAQ entry that best matches what the user typed
This is retrieval built on feature extraction. Every FAQ entry is turned into a vector ahead of time, and the user's query is turned into a vector the same way when it arrives. Cosine similarity scores how closely two vectors point in the same direction, from -1 to 1. Inference scores the query against every FAQ vector, sorts the entries by score and returns the top one or the top few.
There is no label per query to train on here, so evaluation needs people to mark which FAQ entries answer a sample of real queries. With one correct entry per query, mean reciprocal rank (MRR) is a natural score. A query whose correct entry is ranked first scores 1 and one ranked third scores 1/3, and MRR averages those scores over all queries. With several acceptable entries, precision at k is common, the share of the top k results that are relevant.

Turn a long report into a short summary
The output is new text, so the task is text generation, specifically summarization. The training data is reports paired with target summaries. The model generates one token at a time, each based on the report and the tokens it has written so far, until it produces an end token.
A quick automated metric is ROUGE, which counts how many words and phrases the generated summary shares with a reference summary. ROUGE only measures overlap, so a team also reads summaries against the report to catch statements the report never made.

Common mistakes
- Picking a model before naming the returned answer. "Use an LLM" or "train a classifier" is a decision about the prediction step. Decide what the user gets back first, then compare approaches on the same evaluation set.
- Collecting data in the wrong shape. Document-level labels cannot train a token classifier, and single sentences cannot train a similarity model. Decide the task before the labeling starts.
- Reporting accuracy on imbalanced classes. When most reviews or tickets belong to one class, a model that always predicts it can score high accuracy. Report precision, recall and F1, or macro F1 across classes.
- Trusting a generated string as a label. Parse it, check it against the allowed values and decide what happens when it fails the check.
- Evaluating on data unlike the real inputs. A sentiment model tested on movie reviews says little about how it handles complaints about app crashes or refunds.
Related concepts
Feature extraction and retrieval build on word embeddings, which turn text into vectors that can be compared. Generation tasks such as summarization depend on decoding strategies, the rules for picking each next token. Many generation tasks are built with encoder-decoder models, which read a source text and write a target text.
QuiddityML opens the NLP tasks unit of its NLP track with these four concepts. Its questions ask learners to match requests such as the ticket router, the contract redaction tool and the FAQ search to a task, an output and a metric (QuiddityML).