File size: 3,536 Bytes
e46f2b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # π§ SentimentClassifier-BERT-RegulatoryCompliance
A **BERT-based** sentiment analysis model fine-tuned on regulatory feedback and compliance-related text. This model classifies input text into **Positive**, **Neutral**, or **Negative**, making it well-suited for analyzing complaints, formal feedback, and regulatory communication.
---
## β¨ Model Highlights
- π Based on [`bert-base-uncased`](https://huggingface.co/bert-base-uncased)
- π Fine-tuned on a custom dataset of labeled regulatory feedback
- β‘ Supports prediction of **3 classes**: Positive, Neutral, Negative
- π§ Built using **Hugging Face Transformers** and **PyTorch**
---
## π§ Intended Uses
- β
Regulatory and compliance feedback classification
- β
Complaint monitoring and triaging
- β
Customer sentiment analysis for compliance departments
---
## π« Limitations
- β Not optimized for multi-language input (English only)
- π Input longer than 128 tokens will be truncated
- π€ Model may misinterpret informal or slang language
- β οΈ Not intended to replace expert human judgment in legal matters
---
## ποΈββοΈ Training Details
| Attribute | Value |
|-------------------|------------------------------------|
| Base Model | `bert-base-uncased` |
| Dataset | Custom `.txt` file with feedbacks |
| Labels | Negative (0), Neutral (1), Positive (2) |
| Max Token Length | 128 |
| Epochs | 3 |
| Batch Size | 16 |
| Optimizer | AdamW |
| Loss Function | CrossEntropyLoss |
| Framework | PyTorch + Transformers |
| Hardware | CUDA-enabled GPU |
---
## π Evaluation Metrics
| Metric | Score |
|-----------|-------|
| Accuracy | 0.84 |
| Precision | 0.85 |
| Recall | 0.84 |
| F1 Score | 0.85 |
---
## π Label Mapping
| Label ID | Sentiment |
|----------|-----------|
| 0 | Negative |
| 1 | Neutral |
| 2 | Positive |
---
## π Usage
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
model_name = "your-username/sentiment-bert-regulatory-compliance"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
def predict(text):
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = F.softmax(outputs.logits, dim=1)
pred = torch.argmax(probs, dim=1).item()
label_map = {0: "Negative", 1: "Neutral", 2: "Positive"}
return f"Sentiment: {label_map[pred]} (Confidence: {probs[0][pred]:.2f})"
# Example
print(predict("The issue was resolved promptly and professionally."))
```
## π Repository Structure
```
bash
Copy
Edit
.
βββ model/ # Fine-tuned model files (pytorch_model.bin, config.json)
βββ tokenizer/ # Tokenizer config and vocab
βββ training_script.py # Training code
βββ feedbacks.txt # Source dataset
βββ README.md # Model card
```
## π€ Contributing
Contributions are welcome! Feel free to open an issue or pull request to improve the model or its documentation.
|