# A Tour of Pipeline Tasks — Hugging Face Transformers

Source: https://www.skillbyai.com/en/hugging-face/hf-pipeline-tasks

> Choose the right pipeline task for classification, entities, zero-shot labelling, QA, summarisation and generation.

## Common tasks and what they return

Each task name maps to a pipeline class with its own input and output shape. **text-classification** (alias `sentiment-analysis`) returns a label and score. **token-classification** (alias `ner`) tags each token; with `aggregation_strategy="simple"` it merges word pieces back into whole entities such as a person or a city. **zero-shot-classification** lets you supply your *own* candidate labels at run time; it uses a model trained on natural-language inference to score how well each label fits, so you need no training data. **question-answering** extracts an answer span from a context paragraph. **summarization** and **translation** use encoder-decoder models to write new text, and **text-generation** continues a prompt or a chat. Vision and audio tasks such as **image-classification** and **automatic-speech-recognition** follow the same pattern. The model you choose must have been trained for the task; loading a plain base model into a classification pipeline gives random predictions.

## Zero-shot labels and named entities

Zero-shot scores your own labels; NER with aggregation returns whole entities with character offsets.

```python
from transformers import pipeline

zero_shot = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
out = zero_shot("The RBI kept the repo rate unchanged this quarter.",
                candidate_labels=["economy", "sports", "politics"])
print(out["labels"][0])  # highest-scoring label first, likely "economy"

ner = pipeline("ner", model="dslim/bert-base-NER", aggregation_strategy="simple")
for ent in ner("Sundar Pichai visited Bengaluru."):
    print(ent["entity_group"], ent["word"], ent["start"], ent["end"])
```

## Read the task tag on the model card

Every Hub model page shows a task tag such as *Text Classification* or *Token Classification*. Pick models from that filtered list. A classic bug is loading a summarisation checkpoint into a classification pipeline and getting nonsense with no error.

**Quiz:** You must sort support tickets into labels that change every month and you have no labelled data. Which pipeline fits best?

- [ ] text-generation
- [ ] token-classification
- [ ] summarization
- [x] zero-shot-classification

*Answer:* zero-shot-classification. Zero-shot classification accepts candidate labels at call time and needs no task-specific training data.
