Views
No views yet
["person", "band", "chemical compound"]
-- and it returns the character spans of the entities of those types. There is no fixed
label set and no fine-tuning step: the types are part of the input.google/rembertgoogle-bert/bert-base-multilingual-uncased1from transformers import AutoModel
2
3model = AutoModel.from_pretrained("whoisjones/otter-bi-rembert", trust_remote_code=True)
4model.eval()
5
6entities = model.predict(
7 "Angela Merkel besuchte gestern das Brandenburger Tor in Berlin.",
8 labels=['person', 'organization', 'location'],
9)
10
11for entity in entities:
12 print(f"{entity['text']!r:25} {entity['label']:15} {entity['score']:.2f}")'Angela Merkel' person 0.76
'Brandenburger Tor' location 0.35
'Berlin' location 0.60text, label, start, end (character offsets into the
input string) and score. Pass a list of strings to run on a batch; you then get one
list of entities per input, in the same order:1model = model.to("cuda")
2
3texts = ["Angela Merkel besuchte das Brandenburger Tor.", "Sony was founded in Tokyo."]
4results = model.predict(texts, labels=["person", "organization", "location"], batch_size=16)predict keeps spans scoring above threshold, which defaults to
config.prediction_threshold (0.2 for this checkpoint, chosen by calibrating
macro-F1 across the evaluation suite). Lower it for higher recall, raise it for higher
precision:entities = model.predict(text, labels=labels, threshold=0.1)"politician" and
"person" select different spans, and a phrase like "chemical compound" works as well
as a single word. Prefer the wording you would use to describe the type to a person.type_inputs = model.encode_labels(labels) # do this oncepredict does this per call; drop down to forward if you are running over a large
corpus with a fixed label set.collate_fn.py in this repository holds the training and evaluation collators. See the
GitHub repository for the full training pipeline,
the evaluation suite, and the data preparation scripts.| Model | Architecture | Encoder |
|---|---|---|
whoisjones/otter-bi-mmbert | bi-encoder | mmBERT-base |
whoisjones/otter-cross-mmbert | cross-encoder | mmBERT-base |
whoisjones/otter-bi-rembert | bi-encoder | RemBERT |
whoisjones/otter-cross-rembert | cross-encoder | RemBERT |