Views
No views yet
1from transformers import AutoTokenizer, pipeline
2
3# Load the base model tokenizer
4tokenizer = AutoTokenizer.from_pretrained('tabularisai/multilingual-sentiment-analysis')
5
6# Load the classification pipeline with the specified model
7pipe = pipeline("text-classification", model="Neleac/yelp-review-classifier", tokenizer=tokenizer)
8
9# Classify a new Yelp review
10review = "This is by far my favorite Panera location in the Pittsburgh area. \
11 Friendly, plenty of room to sit, and good quality food & coffee. \
12 Panera is a great place to hang out and read the news - they even have free WiFi! \
13 Try their toasted sandwiches, especially the chicken bacon dijon."
14
15result = pipe(review)
16
17# Print the result
18print(result) # [{'label': 'Very Positive', 'score': 0.7158929109573364}]