Transformers

Transformers

Sentiment Analysis with pipeline

from transformers import pipeline

classifier = pipeline(task="sentiment-analysis")

result = classifier("I love using transformers!")
print(result) # [{'label': 'POSITIVE', 'score': 0.9998760223388672}]

or Specific model

classifier = pipeline(task="sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

result = classifier("I love using transformers!")
print(result) # [{'label': 'POSITIVE', 'score': 0.9998760223388672}]

Other tasks

  • Text Generation
  • Question Answering
  • Summarization
  • Translation
  • Zero-Shot Classification
  • Token Classification
  • Conversational
  • Feature Extraction
  • Fill-Mask
  • Image Classification
  • Image Segmentation
  • Object Detection
  • Table Question Answering
  • Text2Text Generation
最后更新于