Views
No views yet
allenai/longformer and is trained to predict the type of a marked entity span, given its context, using special entity markers [E] ... [/E].impact_location, context_locationpublication_date, session_date, entry_date, expiry_date, legal_date, context_date, validity_period, context_period<entity_type>...</entity_type>.[E] ... [/E] in context.nlpaueb/legal-bert-base-uncased[E] and [/E] as additional special tokens.| Entity Label | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| context_date | 0.9272 | 0.9405 | 0.9338 | 975 |
| context_location | 0.9671 | 0.9751 | 0.9711 | 843 |
| context_period | 0.9744 | 0.8321 | 0.8976 | 137 |
| entry_date | 0.9528 | 0.9587 | 0.9557 | 484 |
| expiry_date | 0.8980 | 0.9496 | 0.9231 | 139 |
| impact_location | 0.9501 | 0.9559 | 0.9530 | 997 |
| legal_date | 1.0000 | 0.9926 | 0.9963 | 943 |
| publication_date | 0.9501 | 0.9870 | 0.9682 | 386 |
| session_date | 0.9597 | 0.9597 | 0.9597 | 347 |
| validity_period | 0.9932 | 0.9379 | 0.9648 | 467 |
| accuracy | 0.9601 | 5718 | ||
| macro avg | 0.9572 | 0.9489 | 0.9523 | 5718 |
| weighted avg | 0.9606 | 0.9601 | 0.9601 | 5718 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("svercoutere/longformer-classifier-refinement-abb")
5model = AutoModelForSequenceClassification.from_pretrained("svercoutere/longformer-classifier-refinement-abb")
6
7def classify_entity(entity_text, context_text):
8 marked_text = context_text.replace(entity_text, f"[E] {entity_text} [/E]", 1)
9 inputs = tokenizer(marked_text, return_tensors="pt", truncation=True, max_length=2048, padding="max_length")
10 with torch.no_grad():
11 outputs = model(**inputs)
12 pred = torch.argmax(outputs.logits, dim=-1).item()
13 return pred # Map to label using label_encoder.classes_[E] ... [/E] in the input.@misc{longformer-classifier-refinement-abb,
author = {S. Vercoutere},
title = {Longformer Entity Refinement},
year = {2026},
howpublished = {\url{https://huggingface.co/svercoutere/longformer-classifier-refinement-abb}}
}