Downloads · 30 days
7
2% of all-time downloads
AventIQ-AI/XLMRoBERTa_Multilingual_Sentiment_Analysis
XLMRoBERTa_Multilingual_Sentiment_Analysis is a machine learning model from AventIQ-AI. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a multilingual sentiment analysis model fine-tuned on the Amazon Reviews Multi dataset using the xlm-roberta-base architecture from Hugging Face Transformers. The model is capable of analyzing…
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
384
Public
Parameters
278M
561 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors556 MB · 99%
From the Hugging Face model README
This repository contains a multilingual sentiment analysis model fine-tuned on the Amazon Reviews Multi dataset using the xlm-roberta-base architecture from Hugging Face Transformers. The model is capable of analyzing product review sentiment in multiple languages and is suitable for real-world multilingual applications.
en subset used for fine-tuning)pip install transformers torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_path = "your-username/xlm-roberta-sentiment-amazon-reviews"
model = AutoModelForSequenceClassification.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
model.eval()
# Prediction function
def predict_sentiment(texts):
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
preds = torch.argmax(probs, dim=1)
label_map = {0: "Negative", 1: "Positive"}
results = []
for text, pred, prob in zip(texts, preds, probs):
results.append({
"text": text,
"prediction": label_map[pred.item()],
"confidence": round(prob[pred].item(), 4)
})
return results
# Example
examples = ["This product is amazing!", "Worst purchase ever."]
print(predict_sentiment(examples))
| Epoch | Training Loss | Validation Loss | Accuracy | F1 Macro |
|---|---|---|---|---|
| 1 | 0.1987 | 0.1842 | 93.22% | 0.9321 |
| 2 | 0.1472 | 0.1987 | 93.46% | 0.9346 |
| 3 | 0.0960 | 0.2491 | 93.42% | 0.9341 |
.
├── model/ # Fine-tuned model and config files
├── tokenizer/ # Tokenizer files
├── inference.py # Inference and testing script
├── README.md # Model documentation
Contributions are welcome! Feel free to open an issue or pull request for improvements or bug fixes.