vishal1364 commited on
Commit
fb273fd
Β·
verified Β·
1 Parent(s): f336ee0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +134 -0
README.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ’¬ Sentiment-Analysis-for-Product-Release-Sentiment
2
+
3
+ A **BERT-based sentiment analysis model** fine-tuned on a product review dataset. It predicts the sentiment of a text as **Positive**, **Neutral**, or **Negative** with a confidence score. This model is ideal for analyzing customer feedback, reviews, or user comments.
4
+
5
+ ---
6
+
7
+ ## ✨ Model Highlights
8
+
9
+ - πŸ“Œ **Architecture**: Based on [`bert-base-uncased`](https://huggingface.co/bert-base-uncased) by Google
10
+ - πŸ”§ **Fine-tuned** on labeled product review data
11
+ - πŸ” **3-way sentiment classification**: `Negative (0)`, `Neutral (1)`, `Positive (2)`
12
+ - πŸ’Ύ **Quantized version available** for faster inference
13
+
14
+ ---
15
+
16
+ ## 🧠 Intended Uses
17
+
18
+ - βœ… Classifying product feedback and user reviews
19
+ - βœ… Sentiment analysis for e-commerce platforms
20
+ - βœ… Social media monitoring and customer opinion mining
21
+
22
+ ---
23
+
24
+ ## 🚫 Limitations
25
+
26
+ - ❌ Designed for English texts only
27
+ - ❌ May not perform well on sarcastic or ironic inputs
28
+ - ❌ May struggle with domains very different from product reviews
29
+ - ❌ Input texts longer than 128 tokens are truncated
30
+
31
+ ---
32
+
33
+ ## πŸ‹οΈβ€β™‚οΈ Training Details
34
+
35
+ - **Base Model**: `bert-base-uncased`
36
+ - **Dataset**: Custom-labeled product review dataset
37
+ - **Epochs**: 5
38
+ - **Batch Size**: 8
39
+ - **Max Length**: 128 tokens
40
+ - **Optimizer**: AdamW
41
+ - **Loss Function**: CrossEntropyLoss (with class balancing)
42
+ - **Hardware**: Trained on NVIDIA GPU (CUDA-enabled)
43
+
44
+ ---
45
+
46
+ ## πŸ“Š Evaluation Metrics
47
+
48
+ | Metric | Score |
49
+ |------------|-------|
50
+ | Accuracy | 0.90 |
51
+ | F1 | 0.90 |
52
+ | Precision | 0.90 |
53
+ | Recall | 0.90 |
54
+
55
+ ---
56
+
57
+ ## πŸ”Ž Label Mapping
58
+
59
+ | Label ID | Sentiment |
60
+ |----------|-----------|
61
+ | 0 | Negative |
62
+ | 1 | Neutral |
63
+ | 2 | Positive |
64
+
65
+ ---
66
+
67
+ ## πŸš€ Usage Example
68
+
69
+ ```python
70
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments
71
+ from transformers import DataCollatorWithPadding
72
+ import torch
73
+ import torch.nn.functional as F
74
+
75
+ # Load model and tokenizer
76
+ model_name = "AventIQ-AI/Sentiment-Analysis-for-Product-Release-Sentiment"
77
+ tokenizer = BertTokenizer.from_pretrained(model_name)
78
+ model = BertForSequenceClassification.from_pretrained(model_name)
79
+ model.eval()
80
+
81
+ # Inference
82
+ def predict_sentiment(text):
83
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
84
+ inputs = {k: v.to(quantized_model.device) for k, v in inputs.items()}
85
+ with torch.no_grad():
86
+ logits = quantized_model(**inputs).logits
87
+ probs = F.softmax(logits, dim=1)
88
+
89
+ predicted_class_id = torch.argmax(probs, dim=1).item()
90
+ confidence = probs[0][predicted_class_id].item()
91
+
92
+ label_map = {0: "Negative", 1: "Positive"}
93
+ label = label_map[predicted_class_id]
94
+ confidence_str = f"confidence : {confidence * 100:.1f}%"
95
+
96
+ return label, confidence_str
97
+
98
+ # Example
99
+ print(predict_sentiment(
100
+ "The service was excellent and the staff was friendly.")
101
+ )
102
+ ```
103
+
104
+ ---
105
+
106
+ ## πŸ§ͺ Quantization
107
+
108
+ - Applied **post-training dynamic quantization** using PyTorch to reduce model size and speed up inference.
109
+ - Quantized model supports CPU-based deployments.
110
+
111
+ ---
112
+
113
+ ## πŸ“ Repository Structure
114
+
115
+ ```
116
+ .
117
+ β”œβ”€β”€ model/ # Quantized model files
118
+ β”œβ”€β”€ tokenizer/ # Tokenizer config and vocabulary
119
+ β”œβ”€β”€ model.safetensors/ # Fine-tuned full-precision model
120
+ β”œβ”€β”€ README.md # Model documentation
121
+ ```
122
+
123
+ ---
124
+
125
+ ## πŸ“Œ Limitations
126
+
127
+ - May not generalize to completely different domains (e.g., medical, legal)
128
+ - Quantized version may show slight drop in accuracy compared to full-precision model
129
+
130
+ ---
131
+
132
+ ## 🀝 Contributing
133
+
134
+ We welcome contributions! Please feel free to raise an issue or submit a pull request if you find a bug or have a suggestion.