Views
No views yet
bert-base-uncased (by Google)bert-base-uncased| Metric | Score |
|---|---|
| Accuracy | 0.99 |
| F1-macro | 0.98 |
| Label ID | Sentiment |
|---|---|
| 0 | Negative |
| 1 | Neutral |
| 2 | Positive |
1from transformers import BertTokenizer, BertForSequenceClassification
2import torch
3import torch.nn.functional as F
4
5model_name = "AventIQ-AI/sentiment_analysis_product_review_sentiment"
6tokenizer = BertTokenizer.from_pretrained(model_name)
7model = BertForSequenceClassification.from_pretrained(model_name)
8model.eval()
9
10def predict(text):
11 inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
12 with torch.no_grad():
13 outputs = model(**inputs)
14 probs = F.softmax(outputs.logits, dim=1)
15 pred = torch.argmax(probs, dim=1).item()
16 label_map = {0: "Negative", 1: "Neutral", 2: "Positive"}
17 return f"Sentiment: {label_map[pred]} (Confidence: {probs[0][pred]:.2f})"
18
19# Test predictions
20print("\nTest Predictions:")
21print(predict("We're thrilled to announce our latest update, packed with new features and performance improvements!")).
├── model/ # Contains the quantized model files
├── tokenizer_config/ # Tokenizer configuration and vocabulary files
├── model.safensors/ # Fine Tuned Model
├── README.md # Model documentation