|
|
|
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased") |
|
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased") |
|
|
|
|
|
nlp_pipeline = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer) |
|
|
|
|
|
texts = [ |
|
"I love using Hugging Face models!", |
|
"This movie was terrible.", |
|
"The weather today is nice.", |
|
"I am feeling neutral about this.", |
|
"The product exceeded my expectations." |
|
"I love my life" |
|
] |
|
|
|
|
|
for text in texts: |
|
print(f"Text: {text}") |
|
result = nlp_pipeline(text) |
|
print(f"Sentiment: {result}\n") |
|
|