Downloads · 30 days
9
21% of all-time downloads
TahianaAndriambahoaka/sentiment-analysis-food-reviews
sentiment-analysis-food-reviews is a machine learning model from TahianaAndriambahoaka. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model is a fine-tuned version of cardiffnlp/twitter-roberta-base-sentiment-latest specifically adapted for analyzing sentiments in food recipe reviews.
Downloads · 30 days
9
21% of all-time downloads
All-time downloads
42
Public
Parameters
125M
997 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors499 MB · 99%
From the Hugging Face model README
---
language: en
license: mit
base_model: cardiffnlp/twitter-roberta-base-sentiment-latest
tags:
- sentiment-analysis
- food-reviews
- roberta
- text-classification
- fine-tuned
datasets:
- food-com-recipes-and-user-interactions
pipeline_tag: text-classification
widget:
- text: "This recipe was absolutely delicious! Will make again."
example_title: "Positive review"
- text: "Too salty and instructions were confusing."
example_title: "Negative review"
- text: "It was okay, nothing special."
example_title: "Neutral review"
---
This model is a fine-tuned version of cardiffnlp/twitter-roberta-base-sentiment-latest specifically adapted for analyzing sentiments in food recipe reviews.
The base model (RoBERTa) was originally trained on a large corpus of Twitter data and has been fine-tuned on the Food.com recipes dataset to better understand the specific language and expressions used in culinary reviews.
This model is designed to classify food recipe reviews into three sentiment categories:
from transformers import pipeline
# Load the model
analyzer = pipeline(
"sentiment-analysis",
model="TahianaAndriambahoaka/sentiment-analysis-food-reviews"
)
# Analyze a review
result = analyzer("This recipe is amazing!")
print(result)
# Output: [{'label': 'positive', 'score': 0.9876}]
### Batch processing multiple reviews
```python
reviews = [
"Amazing! Will make again.",
"Too salty, not recommended.",
"It was okay, nothing special."
]
results = analyzer(reviews)
for review, result in zip(reviews, results):
print(f"{review}: {result['label']} ({result['score']:.2%})")
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "TahianaAndriambahoaka/sentiment-analysis-food-reviews"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "This recipe is amazing!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=256)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1).item()
label_map = {0: "negative", 1: "neutral", 2: "positive"}
print(f"Sentiment: {label_map[predicted_class]}")
The model outputs one of three labels:
The model was fine-tuned on the Food.com Recipes and User Interactions dataset, which contains:
The model achieves strong performance on food review sentiment classification. Evaluation metrics on the test set:
If you use this model, please cite the original dataset:
@article{food-com-dataset,
title={Food.com Recipes and User Interactions},
author={Shuyang Li},
year={2019},
url={https://www.kaggle.com/shuyangli94/food-com-recipes-and-user-interactions}
}
TahianaAndriambahoaka
For questions or feedback, please open an issue on the model repository.