ModernBERT-base-literary-NER-novelties
ModernBERT-base-literary-NER-novelties is NER model based on ModernBERT-base and trained on the Novelties literary dataset for usage in the Renard library.
Performance
| Book | Precision | Recall | F1 |
|---|---|---|---|
| Ulysses | 89.23 | 85.50 | 87.33 |
| The Way we Live Now | 78.66 | 82.17 | 80.37 |
| Tinker Tailor Soldier Spy | 82.19 | 83.54 | 82.86 |
| The Wheel of Time | 88.63 | 84.68 | 86.61 |
| Vanity Fair | 88.57 | 92.38 | 90.44 |
| Class | F1 |
|---|---|
| CHR | 92.53 |
| GRP | 68.47 |
| LOC | 81.97 |
| MSC | 37.76 |
| ORG | 37.14 |
Usage in Renard
from renard.pipeline import Pipeline
from renard.pipeline.tokenization import NLTKTokenizer
from renard.pipeline.ner import BertNamedEntityRecognizer
from renard.pipeline.character_unification import GraphRulesCharacterUnifier
from renard.pipeline.graph_extraction import CoOccurrencesGraphExtractor
pipeline = Pipeline(
[
NLTKTokenizer(),
BertNamedEntityRecognizer(
model="compnet-renard/ModernBERT-base-literary-NER-novelties"
),
GraphRulesCharacterUnifier(),
CoOccurrencesGraphExtractor(co_occurrences_dist=10),
],
# by default, a Renard pipeline uses "PER" as the tag to recognize characters,
# but this model is trained to ouput "CHR" tags instead.
character_ner_tag="CHR"
)
out = pipeline("Princess Liana felt sad, because Zarth Arn was gone. The princess went to sleep.")
print((out.character_network.nodes, out.character_network.edges))
This outputs:
(NodeView((<Princess Liana, Gender.UNKNOWN, 1 mentions>, <Zarth Arn, Gender.UNKNOWN, 1 mentions>)), EdgeView([(<Princess Liana, Gender.UNKNOWN, 1 mentions>, <Zarth Arn, Gender.UNKNOWN, 1 mentions>)]))