Hugging face
- Open Google Colab and create a new notebook.
- Select the Runtime to T4-GPU (optional)
- In the first cell, Enter
%pip install transformers - Navigate to Refer Here and run the following
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
# response = classifier("I like Large Language models very much")
# print(response)
response = classifier("I got irritate standing in line at airport")
print(response)
-
NLP/Transformer Tasks
- classification
- summarization
- NER
- Feature Extraction
- Sentiment analysis
- Text Generation
-
High level usage:
pipeline. Refer Here for the google colab notebook
I want to classify text into a category
- Input:
India won World cup in Cricket - I want you to find a classifier which classifies the input and possible options are
['Sports', 'Politics', 'Technology']
classifier = pipeline('zero-shot-classification', model='facebook/bart-large-mnli')
# classifier code
sequence_to_classify = "India won World cup in Cricket"
candidate_labels = ["sports", "politics", "health", "business"]
classifier(sequence_to_classify, candidate_labels)
