aiola commited on
Commit
c68492a
1 Parent(s): cbe1838

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
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
+ ```