Upload 7 files
Browse files- README.md +158 -14
- adapter_config.json +45 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- vocab.txt +0 -0
README.md
CHANGED
|
@@ -1,24 +1,168 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
-
-
|
| 4 |
- lora
|
| 5 |
-
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
base_model: ''
|
| 12 |
-
instance_prompt: null
|
| 13 |
-
license: apache-2.0
|
| 14 |
---
|
| 15 |
-
# Paladim
|
| 16 |
|
| 17 |
-
|
| 18 |
|
|
|
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: prajjwal1/bert-tiny
|
| 3 |
+
library_name: peft
|
| 4 |
tags:
|
| 5 |
+
- base_model:adapter:prajjwal1/bert-tiny
|
| 6 |
- lora
|
| 7 |
+
- transformers
|
| 8 |
+
- sentiment-analysis
|
| 9 |
+
- text-classification
|
| 10 |
+
- paladim
|
| 11 |
+
- continual-learning
|
| 12 |
+
license: mit
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
|
|
|
| 14 |
|
| 15 |
+
# PALADIM Sentiment Analysis (Improved)
|
| 16 |
|
| 17 |
+
**A balanced, production-ready sentiment analysis model using PALADIM architecture**
|
| 18 |
|
| 19 |
+
## 🎯 Model Performance
|
| 20 |
|
| 21 |
+
- **Overall Accuracy**: 78.68%
|
| 22 |
+
- **Positive Sentiment**: 74.61% accuracy
|
| 23 |
+
- **Negative Sentiment**: 82.87% accuracy
|
| 24 |
+
- **Training Data**: 22,500 balanced samples from IMDb
|
| 25 |
+
- **Balanced Training**: Equal positive/negative samples (no bias!)
|
| 26 |
|
| 27 |
+
## 📊 Test Results
|
| 28 |
|
| 29 |
+
All predictions correct with high confidence:
|
| 30 |
+
|
| 31 |
+
| Text | Prediction | Confidence |
|
| 32 |
+
|------|------------|------------|
|
| 33 |
+
| "This movie was absolutely fantastic!" | ✅ POSITIVE | 93.5% |
|
| 34 |
+
| "Terrible experience. Waste of time and money." | ❌ NEGATIVE | 92.1% |
|
| 35 |
+
| "Pretty good, I enjoyed it overall." | ✅ POSITIVE | 88.5% |
|
| 36 |
+
| "Not great, kind of boring and disappointing." | ❌ NEGATIVE | 86.4% |
|
| 37 |
+
| "Amazing! Best thing I've ever seen!" | ✅ POSITIVE | 94.0% |
|
| 38 |
+
| "Awful. Would not recommend to anyone." | ❌ NEGATIVE | 95.7% |
|
| 39 |
+
|
| 40 |
+
## 🚀 Quick Start
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from peft import PeftModel
|
| 44 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 45 |
+
import torch
|
| 46 |
+
|
| 47 |
+
# Load model
|
| 48 |
+
base_model = AutoModelForSequenceClassification.from_pretrained(
|
| 49 |
+
"prajjwal1/bert-tiny",
|
| 50 |
+
num_labels=2
|
| 51 |
+
)
|
| 52 |
+
model = PeftModel.from_pretrained(base_model, "nickagge/paladim-sentiment-improved")
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained("nickagge/paladim-sentiment-improved")
|
| 54 |
+
|
| 55 |
+
# Predict
|
| 56 |
+
text = "This movie was fantastic!"
|
| 57 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 58 |
+
outputs = model(**inputs)
|
| 59 |
+
prediction = torch.argmax(outputs.logits, dim=-1).item()
|
| 60 |
+
|
| 61 |
+
sentiment = "POSITIVE" if prediction == 1 else "NEGATIVE"
|
| 62 |
+
confidence = torch.softmax(outputs.logits, dim=-1).max().item()
|
| 63 |
+
|
| 64 |
+
print(f"{sentiment} ({confidence*100:.1f}%)")
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Model Details
|
| 68 |
+
|
| 69 |
+
**PALADIM** (Pre Adaptive Learning Architecture of Dual-Process Hebbian-MoE Schema) is a continual learning system that combines:
|
| 70 |
+
|
| 71 |
+
- **Stable Core**: Pre-trained BERT-tiny (4.4M parameters) - frozen
|
| 72 |
+
- **Plastic Memory**: LoRA adapters (12,546 trainable = 0.29%)
|
| 73 |
+
- **MoE Layer**: Mixture of Experts routing
|
| 74 |
+
- **Consolidation**: EWC + Knowledge Distillation
|
| 75 |
+
- **Meta-Controller**: Adaptive learning triggers
|
| 76 |
+
- **Replay Buffer**: Anti-forgetting mechanism
|
| 77 |
+
|
| 78 |
+
### Model Description
|
| 79 |
+
|
| 80 |
+
This model is fine-tuned for binary sentiment classification (positive/negative) with balanced training to avoid prediction bias. It achieves 78.68% accuracy with high confidence predictions on both sentiment classes.
|
| 81 |
+
|
| 82 |
+
- **Developed by:** nickagge
|
| 83 |
+
- **Model type:** BERT-tiny with LoRA adapters
|
| 84 |
+
- **Language(s):** English
|
| 85 |
+
- **License:** MIT
|
| 86 |
+
- **Finetuned from model:** prajjwal1/bert-tiny
|
| 87 |
+
|
| 88 |
+
## Training Details
|
| 89 |
+
|
| 90 |
+
### Training Data
|
| 91 |
+
|
| 92 |
+
- **Dataset**: IMDb movie reviews
|
| 93 |
+
- **Training samples**: 22,500 (11,250 positive + 11,250 negative)
|
| 94 |
+
- **Validation samples**: 2,500 (balanced)
|
| 95 |
+
- **Max sequence length**: 128 tokens
|
| 96 |
+
|
| 97 |
+
### Training Procedure
|
| 98 |
+
|
| 99 |
+
#### Training Hyperparameters
|
| 100 |
+
|
| 101 |
+
- **Training regime**: fp32 (CPU training)
|
| 102 |
+
- **Epochs**: 3
|
| 103 |
+
- **Batch size**: 16
|
| 104 |
+
- **Learning rate**: 5e-4
|
| 105 |
+
- **Optimizer**: AdamW
|
| 106 |
+
- **LoRA rank (r)**: 8
|
| 107 |
+
- **LoRA alpha**: 16
|
| 108 |
+
- **LoRA dropout**: 0.1
|
| 109 |
+
- **Target modules**: ["query", "value", "key"]
|
| 110 |
+
|
| 111 |
+
#### Training Progress
|
| 112 |
+
|
| 113 |
+
| Epoch | Train Loss | Train Acc | Eval Acc | Pos Acc | Neg Acc |
|
| 114 |
+
|-------|------------|-----------|----------|---------|---------|
|
| 115 |
+
| 1 | 0.5514 | 71.31% | 77.48% | 77.44% | 77.52% |
|
| 116 |
+
| 2 | 0.4933 | 76.00% | 77.68% | 86.59% | 68.51% |
|
| 117 |
+
| 3 | 0.4805 | 76.94% | **78.68%** | 74.61% | 82.87% |
|
| 118 |
+
|
| 119 |
+
## Evaluation
|
| 120 |
+
|
| 121 |
+
### Testing Data & Metrics
|
| 122 |
+
|
| 123 |
+
- **Test set**: 2,500 balanced samples from IMDb
|
| 124 |
+
- **Metrics**: Accuracy (overall and per-class)
|
| 125 |
+
- **Positive class accuracy**: 74.61%
|
| 126 |
+
- **Negative class accuracy**: 82.87%
|
| 127 |
+
|
| 128 |
+
### Results
|
| 129 |
+
|
| 130 |
+
✅ **Balanced predictions** - No systematic bias
|
| 131 |
+
✅ **High confidence** - 86-96% on test sentences
|
| 132 |
+
✅ **Consistent performance** - Both classes above 74%
|
| 133 |
+
|
| 134 |
+
## Uses
|
| 135 |
+
|
| 136 |
+
### Direct Use
|
| 137 |
+
|
| 138 |
+
- Sentiment analysis for movie reviews, product reviews, customer feedback
|
| 139 |
+
- Social media sentiment monitoring
|
| 140 |
+
- Content moderation and filtering
|
| 141 |
+
- Market research and opinion mining
|
| 142 |
+
|
| 143 |
+
### Limitations
|
| 144 |
+
|
| 145 |
+
- Trained specifically on movie reviews (may need domain adaptation for other contexts)
|
| 146 |
+
- Binary classification only (positive/negative, no neutral class)
|
| 147 |
+
- English language only
|
| 148 |
+
- Max sequence length: 128 tokens
|
| 149 |
+
|
| 150 |
+
## Citation
|
| 151 |
+
|
| 152 |
+
```bibtex
|
| 153 |
+
@misc{paladim-sentiment-improved,
|
| 154 |
+
title={PALADIM Sentiment Analysis Model},
|
| 155 |
+
author={nickagge},
|
| 156 |
+
year={2025},
|
| 157 |
+
publisher={HuggingFace},
|
| 158 |
+
howpublished={\url{https://huggingface.co/nickagge/paladim-sentiment-improved}}
|
| 159 |
+
}
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
## Related Models
|
| 163 |
+
|
| 164 |
+
- [Original PALADIM Model](https://huggingface.co/nickagge/paladim-sentiment)
|
| 165 |
+
- [BERT-tiny Base](https://huggingface.co/prajjwal1/bert-tiny)
|
| 166 |
+
### Framework versions
|
| 167 |
+
|
| 168 |
+
- PEFT 0.18.0
|
adapter_config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "prajjwal1/bert-tiny",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 16,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.1,
|
| 22 |
+
"megatron_config": null,
|
| 23 |
+
"megatron_core": "megatron.core",
|
| 24 |
+
"modules_to_save": [
|
| 25 |
+
"classifier",
|
| 26 |
+
"score"
|
| 27 |
+
],
|
| 28 |
+
"peft_type": "LORA",
|
| 29 |
+
"peft_version": "0.18.0",
|
| 30 |
+
"qalora_group_size": 16,
|
| 31 |
+
"r": 8,
|
| 32 |
+
"rank_pattern": {},
|
| 33 |
+
"revision": null,
|
| 34 |
+
"target_modules": [
|
| 35 |
+
"query",
|
| 36 |
+
"key",
|
| 37 |
+
"value"
|
| 38 |
+
],
|
| 39 |
+
"target_parameters": null,
|
| 40 |
+
"task_type": "SEQ_CLS",
|
| 41 |
+
"trainable_token_indices": null,
|
| 42 |
+
"use_dora": false,
|
| 43 |
+
"use_qalora": false,
|
| 44 |
+
"use_rslora": false
|
| 45 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": true,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_basic_tokenize": true,
|
| 47 |
+
"do_lower_case": true,
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 51 |
+
"never_split": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"strip_accents": null,
|
| 55 |
+
"tokenize_chinese_chars": true,
|
| 56 |
+
"tokenizer_class": "BertTokenizer",
|
| 57 |
+
"unk_token": "[UNK]"
|
| 58 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|