AmanSengar commited on
Commit
7b34234
Β·
verified Β·
1 Parent(s): 33a52fc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +106 -14
README.md CHANGED
@@ -1,26 +1,118 @@
1
- ### Load the Model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  ```python
4
- import torch
5
- from torch.utils.data import Dataset, DataLoader
6
- from torch.optim import AdamW
7
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
8
  import torch.nn.functional as F
9
 
10
- MODEL = "AventIQ-AI/sentiment-analysis-for-user-reviews-sentiment"
11
- tokenizer = AutoTokenizer.from_pretrained(MODEL)
12
- model = AutoModelForSequenceClassification.from_pretrained(MODEL,num_labels=2,ignore_mismatched_sizes=True)
13
-
14
 
15
  def predict(text):
16
  inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
17
  with torch.no_grad():
18
- outputs = quantize_model(**inputs)
19
  probs = F.softmax(outputs.logits, dim=1)
20
  pred = torch.argmax(probs, dim=1).item()
21
- label_map = {0: "Negative", 1: "Neutral", 2: "Positive"}
22
- return f"Sentiment: {label_map[pred]} (Confidence: {probs[0][pred]:.2f})"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- # Test predictions
25
- print("\nTest Predictions:")
26
- print(predict("the product quality is just so good"))
 
1
+ # 🧠 SentimentClassifier-RoBERTa-UserReviews
2
+
3
+ A RoBERTa-based sentiment analysis model fine-tuned on user review data. This model classifies reviews as **Positive** or **Negative**, making it ideal for analyzing product feedback, customer reviews, and other short user-generated content.
4
+
5
+ ---
6
+
7
+ ## ✨ Model Highlights
8
+
9
+ πŸ“Œ Based on `cardiffnlp/twitter-roberta-base-sentiment` (from Cardiff NLP)
10
+ πŸ” Fine-tuned on binary-labeled user reviews (positive vs. negative)
11
+ ⚑ Supports prediction of 2 classes: Positive, Negative
12
+ 🧠 Built using Hugging Face πŸ€— Transformers and PyTorch
13
+
14
+ ---
15
+
16
+ ## 🧠 Intended Uses
17
+
18
+ - βœ… Customer review sentiment classification
19
+ - βœ… E-commerce product feedback analysis
20
+ - βœ… App review categorization
21
+
22
+ ---
23
+
24
+ ## 🚫 Limitations
25
+
26
+ - ❌ Not optimized for multi-class sentiment (Neutral, Sarcasm, etc.)
27
+ - 🌍 Trained primarily on English-language reviews
28
+ - πŸ“ Performance may degrade for texts >128 tokens (due to max length truncation)
29
+ - πŸ€” Not designed for domain-specific jargon (e.g., legal or medical texts)
30
+
31
+ ---
32
+
33
+ ## πŸ‹οΈβ€β™‚οΈ Training Details
34
+
35
+ | Attribute | Value |
36
+ |-------------------|----------------------------------------|
37
+ | Base Model | cardiffnlp/twitter-roberta-base-sentiment |
38
+ | Dataset | Filtered user reviews (binary labeled) |
39
+ | Labels | Positive (1), Negative (0) |
40
+ | Max Token Length | 128 |
41
+ | Epochs | 3 |
42
+ | Batch Size | 8 |
43
+ | Optimizer | AdamW |
44
+ | Loss Function | CrossEntropyLoss |
45
+ | Framework | PyTorch + Hugging Face Transformers |
46
+ | Hardware | CUDA-enabled GPU |
47
+
48
+ ---
49
+
50
+ ## πŸ“Š Evaluation Metrics
51
+
52
+ | Metric | Score |
53
+ |------------|--------|
54
+ | Accuracy | 0.94 |
55
+ | Precision | 0.93 |
56
+ | Recall | 0.95 |
57
+ | F1 Score | 0.94 |
58
+
59
+ > πŸ“Œ Replace with your final values after complete training if these were updated.
60
+
61
+ ---
62
+
63
+ ## πŸ”Ž Label Mapping
64
+
65
+ | Label ID | Sentiment |
66
+ |----------|-----------|
67
+ | 0 | Negative |
68
+ | 1 | Positive |
69
+
70
+ ---
71
+
72
+ ## πŸš€ Usage
73
 
74
  ```python
 
 
 
75
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
76
+ import torch
77
  import torch.nn.functional as F
78
 
79
+ model_name = "your-username/sentiment-roberta-user-reviews"
80
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
81
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
82
+ model.eval()
83
 
84
  def predict(text):
85
  inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
86
  with torch.no_grad():
87
+ outputs = model(**inputs)
88
  probs = F.softmax(outputs.logits, dim=1)
89
  pred = torch.argmax(probs, dim=1).item()
90
+ label_map = {0: "Negative", 1: "Positive"}
91
+ return f"Sentiment: {label_map[pred]} (Confidence: {probs[0][pred]:.2f})"
92
+
93
+ # Example
94
+ print(predict("I really love this product, works great!"))
95
+
96
+
97
+
98
+ πŸ“ Repository Structure
99
+ python
100
+ Copy
101
+ Edit
102
+ .
103
+ β”œβ”€β”€ model/ # Contains fine-tuned model files
104
+ β”œβ”€β”€ tokenizer/ # Tokenizer config and vocab
105
+ β”œβ”€β”€ config.json # Model configuration
106
+ β”œβ”€β”€ pytorch_model.bin # Fine-tuned model weights
107
+ β”œβ”€β”€ README.md # Model card
108
+
109
+
110
+
111
+ 🀝 Contributing
112
+ Contributions are welcome! Feel free to open an issue or submit a pull request if you have ideas to improve this model or documentation.
113
+
114
+
115
+
116
+
117
+
118