Transformers is an open-source Python library for using pretrained transformer-based models across natural-language processing, computer vision, audio, and reinforcement-learning tasks. It provides accessible APIs so developers can apply capable models without building or training them from scratch. section 1.1 section 3.3
Classify sentiment with a pipeline
from transformers import pipeline classifier = pipeline( 'text-classification', model='distilbert-base-uncased-finetuned-sst-2-english', revision='af0f99b' ) result = classifier('This film was witty, enjoyable, and beautifully acted.') The pipeline loads the specified pretrained model and returns a formatted classification result. Pipelines provide a high-level interface for common workflows such as classification, named entity recognition, translation, summarization, and generation. section 1.1 section 3.0
Use Transformers to perform tasks including:
- Text classification, including sentiment analysis and zero-shot classification. section 1.1 section 3.3
- Text generation, summarization, translation, and question answering. section 3.3
- Computer-vision work such as object detection with models hosted on the Hugging Face Hub. section 1.2
- Named entity recognition and other workflows through pretrained models and pipelines. section 2.2 section 3.0
Install the package with pip in a notebook, terminal, or Anaconda Prompt. Pretrained models include BERT, GPT, RoBERTa, DistilBERT, and T5; each supplies a different starting point for NLP applications. section 2.2 section 3.2.1
from transformers import pipeline
classifier = pipeline('text-classification',
model = 'distilbert-base-uncased-finetuned-sst-2-english',
revision = 'af0f99b')
Runnable pipeline example showing model selection and revision pinning. section 1.1





