FinBERT-PT-BR is a Portuguese sentiment-classification model trained on financial news. It can help filter positive customer reviews when better-matched Portuguese models are unavailable, but its financial training domain makes the result provisional. section 6.2.5
Treat the model as a screening aid rather than an unquestioned decision-maker:
- Check predictions against sampled raw reviews, especially sarcasm, cultural expressions, and regional Portuguese. section 6.2.5
- Use human review and error monitoring to identify shortcomings before relying on filtered results. section 6.2.5
- Consider computational requirements, model bias, and privacy when processing customer reviews. section 6.2.5
Listing 6.2 Extracting positive reviews with the help of a suboptimal model
import pandas as pd
from transformers import pipeline
# Assuming df is your DataFrame and it has a column named
'review_comment_message'
# Load the sentiment analysis pipeline with the FinBERT-PT-BR model
classifier = pipeline("sentiment-analysis",
model="lucas-leme/FinBERT-PT-BR")
def get_sentiment(review):
try:
result = classifier(review)[0]
return result['label'], result['score']
except Exception as e:
print(f"Error processing review: {e}")
return None, None
# Apply the sentiment analysis to each review
df['sentiment'], df['score'] =
zip(*df['review_comment_message'].map(get_sentiment))
# Filter the DataFrame to only include positive reviews
positive_reviews_df = df[df['sentiment'] == 'LABEL_1']
# Assuming 'LABEL_1' is positive; adjust label as necessary based on model
output
# Now positive_reviews_df contains only the positive reviews
A pandas and Transformers workflow applies the classifier to review_comment_message, stores labels and scores, and filters an assumed positive LABEL_1. section 6.2.5
