What pipeline() actually does
pipeline() is a factory function that wires three things behind one call: a tokenizer, a model, and a task-specific pre/post-processing function. You pass in a task name ("text-generation", "sentiment-analysis", "automatic-speech-recognition", ...) and a model id; it returns a callable that takes raw input (text, audio bytes, image PIL) and returns task-shaped output.
The task name is the contract. pipeline("text-generation") always returns [{"generated_text": str}]. pipeline("text-classification") always returns [{"label": str, "score": float}]. This consistency is why the same pipeline call works across thousands of models — the model card's pipeline_tag field is the routing key.
Where pipeline() ends
pipeline() is the right tool for: prototyping, single-input inference, demos, and Colab notebooks. It is the wrong tool for: batch inference at throughput, custom decoding (beam search variants, JSON-mode, structured output), or anything that needs the raw logits. The moment you need control, drop down to AutoTokenizer + AutoModelForXxx — that's the next lesson.
One feature you do get out of pipeline(): device placement and batching. Pass device=0 for GPU 0, device="mps" on Apple Silicon, or device_map="auto" for multi-GPU sharding via accelerate.