File size: 4,697 Bytes
219c763 8fd1c33 219c763 8fd1c33 219c763 28ea356 219c763 28ea356 219c763 28ea356 219c763 28ea356 8fd1c33 219c763 8fd1c33 219c763 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | ---
license: apache-2.0
language:
- en
library_name: onnx
base_model: FacebookAI/roberta-base
tags:
- onnx
- coreference-resolution
- quotation-attribution
- named-entity-recognition
- literary
- narrative-lens
datasets:
- dbamman/litbank
- Priya22/project-dialogism-novel-corpus
---
# narrative-multitask (v2)
One encoder, four heads, for English prose fiction. The export is consumed by the
[narrative-lens](https://github.com/writerslogic/narrative-lens) crate (`ModelKind::NarrativeMultitask`,
profile `narrative_multitask_v1`), which runs it on the native ONNX Runtime and, through tract, in WebAssembly.
| Head | Output | What it does |
| --- | --- | --- |
| `entity_logits` | `[1, L, 9]` BIO over the CoNLL label set | proper person spans (only PER carries training signal) |
| `nominal_logits` | `[1, L, 3]` O / B-NOM / I-NOM | nominal person mentions ("her mother", "the old man") |
| `coref_scores` | `[m, m]` | antecedent score of mention *j* for mention *i* (*j* < *i*); 0 is the no-antecedent score |
| `attribution_scores` | `[q, m + 1]` | speaker score per quotation over the window's mentions; column 0 is "speaker not in window" |
Inputs: `input_ids`, `attention_mask` (`[1, L]`, L <= 512), `mention_starts`, `mention_ends`, `quote_starts`, `quote_ends`
(int64 token positions, `[CLS]` at 0). Windows are 510 content tokens (`windowTokens` in `manifest.json`); the batch
axis is fixed at 1. Weights are dynamically quantized to int8 (126 MB). `tokenizer.adapted.json` is the RoBERTa
tokenizer with padding and truncation removed, as the crate requires; `manifest.json` carries the sha256 of both.
## Training
Student: RoBERTa-base (`FacebookAI/roberta-base`), 3 epochs, lr 3e-5, 510-token windows on two shifted grids,
learned token-distance features in both pair heads. Teacher: DeBERTa-v3-large trained first on the same documents
(2 epochs, lr 2e-5); the student learns from gold labels plus the teacher's distributions, aligned through character
offsets. Data: the LitBank development split (proper, nominal, and pronoun mentions, coreference clusters, quotations
with speakers; CC BY 4.0), 24 novels of the Project Dialogism Novel Corpus (quotation speakers and alias
mentions; CC BY 4.0) plus shuffled alias lists from its character tables, and 100 unlabelled public-domain
novels from Project Gutenberg (29,214 windows) structured and soft-labelled by the teacher. The four PDNC
novels whose LitBank excerpt is in the LitBank holdout split were excluded, as were all LitBank source novels
from the Gutenberg selection.
Script: `scripts/multitask_train.py` in the narrative-lens repository; provenance in `training.json`.
## Measurements
Unseen authors (pooled over an author-disjoint 5-fold split over LitBank, PDNC, and the PDNC alias-list
documents; each fold's teacher also structures ~29,200 windows from the 100 unlabelled Gutenberg novels):
| | student (pooled) | teacher (range across folds) |
| --- | ---: | ---: |
| Proper person spans, exact F1 | 0.822 | 0.633-0.906 |
| Nominal mentions, exact F1 | 0.708 | 0.604-0.686 |
| Antecedent accuracy, proper mentions (within window) | 0.937 | - |
| Antecedent accuracy, nominal mentions (within window) | 0.859 | - |
| Antecedent accuracy, pronouns (within window) | 0.935 | 0.925-0.954 |
| Quotation speaker accuracy | 0.854 | 0.849-0.898 |
The student is close to or ahead of its own teacher on every head except speaker accuracy, where the
teacher stays a few points ahead. The teacher's token-head scores vary more across folds because
LitBank's entity and nominal labels are its only supervision, trained on one window grid for two
epochs against the student's two grids with LitBank repeated four times. LitBank development split through the
narrative-lens pipeline (the model trained on these works, so this shows the integration, not generalization):
supplied-cast pronoun resolution F1 0.848 (precision 0.861), explicit-mode speaker F1 0.699 (precision 0.787),
against 0.786 and 0.657 for v1.
## Use with narrative-lens
```sh
hf download Writerslogic/narrative-multitask --revision v2 --local-dir narrative-multitask-v2
cargo run --release --features onnx --example evaluate_literary -- inputs.json --narrative-model narrative-multitask-v2
```
In code: `onnx::set_model_bytes_verified(ModelKind::NarrativeMultitask, &model, &tokenizer_adapted, &manifest)`;
`continuity::coreference` and `craft::dialogue` then use the model and keep their heuristics as the fallback.
## Attribution
LitBank: David Bamman et al., CC BY 4.0. Project Dialogism Novel Corpus: Krishnapriya Vishnubhotla et al., CC BY 4.0.
Base model RoBERTa (MIT); teacher DeBERTa-v3 (MIT). The weights are released under Apache-2.0.
|