<jupyter_start><jupyter_text><jupyter_code>!pip install transformers  --quiet
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import pandas as pd
tokenizer =AutoTokenizer.from_pretrained('nlptown/bert-base-multilingual-uncased-sentiment')

model = AutoModelForSequenceClassification.from_pretrained('nlptown/bert-base-multilingual-uncased-sentiment')
Foodpanda_reviews = pd.read_csv('Foodpanda_reviews.csv',error_bad_lines=False)
Foodpanda_reviews.head()
def sentiment_score(review):
    tokens = tokenizer.encode(review, return_tensors='pt')
    result = model(tokens)
    return int(torch.argmax(result.logits))+1
Foodpanda_reviews['sentiment'] = Foodpanda_reviews['review'].apply(lambda x: sentiment_score(x[:512]))
Foodpanda_reviews.head(50)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup