add minimal README
Browse files
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: roberta-base
|
| 3 |
+
language: en
|
| 4 |
+
tags:
|
| 5 |
+
- narrative
|
| 6 |
+
- text-classification
|
| 7 |
+
- pytorch
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# narrative-event-relation-roberta
|
| 11 |
+
|
| 12 |
+
RoBERTa-base fine-tuned for event relation identification: binary temporal (sequential vs non-sequential) and causal classification. Uses entity markers [E1]/[E2] inserted at character offsets. Trained on LLM pseudo-labels with held-out human gold evaluation.
|
| 13 |
+
|
| 14 |
+
> **Note:** Full model card with training details coming soon.
|
| 15 |
+
|
| 16 |
+
## Loading
|
| 17 |
+
|
| 18 |
+
Download `model.pt` and `tokenizer/` from this repo, then:
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
import torch
|
| 22 |
+
from transformers import AutoModel, AutoTokenizer
|
| 23 |
+
from torch import nn
|
| 24 |
+
|
| 25 |
+
ENTITY_MARKERS = ["[E1]", "[/E1]", "[E2]", "[/E2]"]
|
| 26 |
+
|
| 27 |
+
class EventRelationRoBERTa(nn.Module):
|
| 28 |
+
def __init__(self, model_name):
|
| 29 |
+
super().__init__()
|
| 30 |
+
self.backbone = AutoModel.from_pretrained(model_name)
|
| 31 |
+
hidden = self.backbone.config.hidden_size
|
| 32 |
+
self.temporal_head = nn.Linear(hidden, 1)
|
| 33 |
+
self.causal_head = nn.Linear(hidden, 1)
|
| 34 |
+
|
| 35 |
+
def forward(self, input_ids, attention_mask):
|
| 36 |
+
cls = self.backbone(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state[:, 0, :]
|
| 37 |
+
return self.temporal_head(cls), self.causal_head(cls)
|
| 38 |
+
|
| 39 |
+
tokenizer = AutoTokenizer.from_pretrained("tokenizer/")
|
| 40 |
+
model = EventRelationRoBERTa("roberta-base")
|
| 41 |
+
model.load_state_dict(torch.load("model.pt", map_location="cpu", weights_only=True))
|
| 42 |
+
model.eval()
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Config
|
| 46 |
+
|
| 47 |
+
```json
|
| 48 |
+
{
|
| 49 |
+
"model_name": "roberta-base",
|
| 50 |
+
"max_len": 256,
|
| 51 |
+
"dims": [
|
| 52 |
+
"temporal_sequential",
|
| 53 |
+
"causal"
|
| 54 |
+
],
|
| 55 |
+
"data_source": "/projects/tejo9855/Projects/llm-narrative-annotations/event_relation/outputs/google_gemma-4-31B-it/20260518_143249",
|
| 56 |
+
"n_train": 6219,
|
| 57 |
+
"n_val": 690,
|
| 58 |
+
"val_frac": 0.1,
|
| 59 |
+
"best_epoch": 4,
|
| 60 |
+
"seed": 42,
|
| 61 |
+
"test_f1_gold": 0.805
|
| 62 |
+
}
|
| 63 |
+
```
|