Fill-Mask
Transformers
PyTorch
English
roberta
NER
named entity recognition
RE
relation extraction
entity mention detection
EMD
coreference resolution
Instructions to use aiola/roberta-large-corener with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aiola/roberta-large-corener with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="aiola/roberta-large-corener")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("aiola/roberta-large-corener") model = AutoModelForMaskedLM.from_pretrained("aiola/roberta-large-corener") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: afl-3.0
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- NER
|
| 6 |
+
- named entity recognition
|
| 7 |
+
- RE
|
| 8 |
+
- relation extraction
|
| 9 |
+
- entity mention detection
|
| 10 |
+
- EMD
|
| 11 |
+
- coreference resolution
|
| 12 |
license: afl-3.0
|
| 13 |
+
datasets:
|
| 14 |
+
- Ontonotes
|
| 15 |
+
- CoNLL04
|
| 16 |
---
|
| 17 |
+
|
| 18 |
+
# CoReNer
|
| 19 |
+
|
| 20 |
+
## Model description
|
| 21 |
+
|
| 22 |
+
A multi-task model for named-entity recognition, relation extraction, entity mention detection, and coreference resolution.
|
| 23 |
+
|
| 24 |
+
We model NER as a span classification task and relation extraction as a multi-label classification of (NER) span tuples.
|
| 25 |
+
Similarly, model EMD as a span classification task and CR as a binary classification of (EMD) span tuples.
|
| 26 |
+
To construct the CR clusters, we keep the top antecedent of each mention, then compute the connected components of the mentions' undirected graph.
|
| 27 |
+
|
| 28 |
+
The model was trained to recognize:
|
| 29 |
+
- Entity types: GPE, ORG, PERSON, DATE, NORP, CARDINAL, MONEY, PERCENT, WORK_OF_ART, ORDINAL, EVENT, LOC, TIME, FAC, QUANTITY, LAW, PRODUCT, LANGUAGE.
|
| 30 |
+
- Relation types: Kill, Live_In, Located_In, OrgBased_In, Work_For.
|
| 31 |
+
|
| 32 |
+
## Usage example
|
| 33 |
+
|
| 34 |
+
See additional details and usage examples at: https://github.com/aiola-lab/corener.
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
import json
|
| 38 |
+
from transformers import AutoTokenizer
|
| 39 |
+
from corener.models import Corener, ModelOutput
|
| 40 |
+
from corener.data import MTLDataset
|
| 41 |
+
from corener.utils.prediction import convert_model_output
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("aiola/roberta-large-corener")
|
| 43 |
+
model = Corener.from_pretrained("aiola/roberta-large-corener")
|
| 44 |
+
model.eval()
|
| 45 |
+
examples = [
|
| 46 |
+
"Apple Park is the corporate headquarters of Apple Inc., located in Cupertino, California, United States. It was opened to employees in April 2017, while construction was still underway, and superseded the original headquarters at 1 Infinite Loop, which opened in 1993."
|
| 47 |
+
]
|
| 48 |
+
dataset = MTLDataset(
|
| 49 |
+
types=model.config.types,
|
| 50 |
+
tokenizer=tokenizer,
|
| 51 |
+
train_mode=False,
|
| 52 |
+
)
|
| 53 |
+
dataset.read_dataset(examples)
|
| 54 |
+
example = dataset.get_example(0) # get first example
|
| 55 |
+
output: ModelOutput = model(
|
| 56 |
+
input_ids=example.encodings,
|
| 57 |
+
context_masks=example.context_masks,
|
| 58 |
+
entity_masks=example.entity_masks,
|
| 59 |
+
entity_sizes=example.entity_sizes,
|
| 60 |
+
entity_spans=example.entity_spans,
|
| 61 |
+
entity_sample_masks=example.entity_sample_masks,
|
| 62 |
+
inference=True,
|
| 63 |
+
)
|
| 64 |
+
print(json.dumps(convert_model_output(output=output, batch=example, dataset=dataset), indent=2))
|
| 65 |
+
```
|