Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- attention-analysis
|
| 7 |
+
- long-context
|
| 8 |
+
- modernbert
|
| 9 |
+
base_model: answerdotai/ModernBERT-base
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Long-Context Attention Regressor (Entropy)
|
| 13 |
+
|
| 14 |
+
Predicts the **attention entropy** of a text sample - how spread out vs focused the attention patterns are.
|
| 15 |
+
|
| 16 |
+
## Usage
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 20 |
+
import torch
|
| 21 |
+
|
| 22 |
+
model = AutoModelForSequenceClassification.from_pretrained("KevinDavidHayes/regressor-entropy")
|
| 23 |
+
tokenizer = AutoTokenizer.from_pretrained("KevinDavidHayes/regressor-entropy")
|
| 24 |
+
|
| 25 |
+
text = "Your text here..."
|
| 26 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=8192)
|
| 27 |
+
|
| 28 |
+
with torch.no_grad():
|
| 29 |
+
score = model(**inputs).logits.item()
|
| 30 |
+
|
| 31 |
+
# Higher score = more spread attention (uses more context)
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## Training
|
| 35 |
+
|
| 36 |
+
- **Base model**: ModernBERT-base (8K context)
|
| 37 |
+
- **Target**: Normalized attention entropy
|
| 38 |
+
- **Labels**: Generated using Qwen2.5-7B-Instruct attention analysis at layer 14
|
| 39 |
+
|
| 40 |
+
## Citation
|
| 41 |
+
|
| 42 |
+
Part of research on attention-based data filtering for long-context pretraining.
|