File size: 5,732 Bytes
6a45692
ec948bb
 
 
 
6a45692
ec948bb
6a45692
ec948bb
 
6a45692
ec948bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a45692
 
ec948bb
6a45692
ec948bb
6a45692
ec948bb
6a45692
ec948bb
6a45692
ec948bb
 
 
6a45692
ec948bb
6a45692
ec948bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a45692
 
 
ec948bb
 
 
 
 
 
 
 
6a45692
 
 
 
ec948bb
6a45692
 
ec948bb
6a45692
 
ec948bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a45692
 
ec948bb
 
 
 
 
 
6a45692
ec948bb
 
 
 
 
 
 
6a45692
 
 
ec948bb
 
 
 
 
 
 
 
 
 
 
6a45692
 
 
 
ec948bb
 
 
 
 
 
6a45692
70011a3
ec948bb
 
 
 
 
 
 
41d8eb6
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
---
license: mit
language:
- en
library_name: adaptive-classifier
tags:
- sentiment-analysis
- adaptive-classifier
- few-shot-learning
- continual-learning
- text-classification
- nlp
pipeline_tag: text-classification
widget:
- text: "I love this new technology!"
  example_title: "Positive Example"
- text: "This is terrible and I hate it."
  example_title: "Negative Example"
- text: "Learning is a process of gaining knowledge or skills."
  example_title: "Neutral Example"
- text: "Do you know what Granite Guardian 4 is?"
  example_title: "Neutral Question"
datasets:
- SetFit/tweet_sentiment_extraction
metrics:
- accuracy
model-index:
- name: adaptive-sentiment-classifier
  results:
  - task:
      type: text-classification
      name: Sentiment Analysis
    dataset:
      name: SetFit/tweet_sentiment_extraction
      type: tweet_sentiment_extraction
    metrics:
    - type: accuracy
      value: 0.800
      name: Test Accuracy
---

# Adaptive Sentiment Classifier

An improved sentiment analysis model using the adaptive-classifier library, designed for accurate classification of positive, negative, and neutral sentiments with special focus on technical and informational content.

## Model Description

This model is based on the [adaptive-classifier](https://github.com/MemChainAI/adaptive-classifier) library and uses DistilBERT as the underlying transformer. It has been specifically trained to properly classify:

- **Positive sentiment**: Expressions of satisfaction, enthusiasm, approval
- **Negative sentiment**: Expressions of dissatisfaction, frustration, criticism  
- **Neutral sentiment**: Factual information, questions, technical descriptions

## Key Improvements

- βœ… **Technical Content**: Properly classifies technical descriptions as neutral
- βœ… **Questions**: Correctly identifies questions as neutral rather than negative
- βœ… **Educational Content**: Handles informational text appropriately
- βœ… **Balanced Training**: Uses detailed class descriptions for better embeddings

## Training Data

- **Primary Dataset**: SetFit/tweet_sentiment_extraction (114 examples)
- **Training Method**: Adaptive classifier with continual learning
- **Class Distribution**: Balanced training with quality filtering
- **Additional Features**: Detailed class descriptions for stronger initial embeddings

## Performance

- **Test Accuracy**: 80.0%
- **Problematic Cases Resolved**: 8/10 challenging examples correctly classified
- **Improvement**: 100% increase from baseline accuracy

### Benchmark Examples

| Text | Expected | Predicted | βœ“ |
|------|----------|-----------|---|
| "Granite Guardian 4 is a type of AI model..." | neutral | neutral | βœ… |
| "Do you know what Granite Guardian 4 is?" | neutral | neutral | βœ… |
| "Learning is a process of gaining knowledge..." | neutral | neutral | βœ… |
| "I love this new technology!" | positive | positive | βœ… |
| "This is terrible and I hate it." | negative | negative | βœ… |

## Usage

### Installation

```bash
pip install adaptive-classifier
```

### Basic Usage

```python
from adaptive_classifier import AdaptiveClassifier

# Load the model
classifier = AdaptiveClassifier.from_pretrained("MemChainAI/adaptive-sentiment-classifier")

# Make predictions
text = "This is a great product!"
predictions = classifier.predict(text)

# Get top prediction
label, confidence = predictions[0]
print(f"Sentiment: {label} ({confidence:.3f})")
```

### API Integration

This model is designed to work with the MemChain Models API:

```python
import requests

response = requests.post(
    "http://localhost:8033/model/sentiment/predict",
    json={"text": "Your text here", "k": 3}
)
result = response.json()
```

### Batch Processing

```python
texts = [
    "I love this!",
    "This is terrible.",
    "The system processes data automatically."
]

# Batch prediction
batch_results = classifier.predict_batch(texts)
for i, predictions in enumerate(batch_results):
    label, confidence = predictions[0]
    print(f"Text {i+1}: {label} ({confidence:.3f})")
```

## Training Methodology

1. **Class Descriptions**: Started with detailed descriptions of each sentiment class
2. **Quality Examples**: Used filtered, high-quality examples from the dataset
3. **Iterative Training**: Added examples gradually with evaluation at each step
4. **Continual Learning**: Leveraged adaptive classifier's continual learning capabilities

## Intended Use

- **Content Moderation**: Analyze user-generated content sentiment
- **Customer Feedback**: Classify customer reviews and feedback
- **Social Media**: Monitor social media sentiment
- **Technical Documentation**: Properly classify technical content as neutral
- **Educational Content**: Handle informational and educational text appropriately

## Limitations

- Optimized for English text
- Best performance on text similar to training data (tweets, reviews, questions)
- May require additional examples for domain-specific terminology
- Performance may vary on very long texts (>200 characters)

## Ethical Considerations

- The model should not be used as the sole basis for important decisions
- Bias may exist reflecting the training data
- Regular evaluation and retraining recommended for production use
- Consider cultural and contextual factors when interpreting results

## Citation

```bibtex
@misc{adaptive-sentiment-classifier-2025,
  title={Adaptive Sentiment Classifier},
  author={MemChain AI},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/MemChainAI/adaptive-sentiment-classifier}
}
```

## License

MIT License - see LICENSE file for details.

## Contact

For questions, issues, or contributions, please visit the [MemChain AI](https://www.memchain.ai/contact/).