narrative-graph 0.3.1

Turn prose into candidate relational facts — entity detection, relation labeling, confidence scoring, entirely local.
Documentation
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# Evaluation

## What is measured today

There is no labeled precision/recall corpus for this project yet. What
exists is behavioral test coverage over the pattern set documented in
[ARCHITECTURE.md](./ARCHITECTURE.md):

| Suite | Count | What it checks |
|---|---|---|
| `src/heuristic/segment.rs` (`cargo test`) | 14 | Sentence segmentation: honorifics, initials, ellipses, decimals, em-dashes, quoted dialogue with attribution, terminator runs, multibyte offsets, empty input, and a 20k-case property test asserting no panic and valid char-boundary offsets |
| `tests/heuristic.rs` (`cargo test`) | 84 | Each relation pattern fires on a canonical example, confidence ordering, span correctness, `min_confidence` filtering, rule attribution, and multi-relation sentences; plus nested mentions (`Jane` inside `Mary Jane`), a surface form recurring inside an earlier word (`Dev` inside `Devon`), an entity whose lowercase form changes byte length (`İ`), a possessive bounded to its noun phrase, passive-voice role orientation, spans covering the token that licensed the relation, a referent mentioned twice yielding both relations, no self-relations, whole-word lexicon matching (`grandmother` is not `mother`), stance nouns scoring below stated kinship, one label shared between a noun rule and a verb rule, and a 20k-case property test over the whole pipeline asserting no panic and valid char-boundary spans. Ten of them came out of the near-miss probing below. Seven assert that nothing is emitted: a possessive without a copula, a reported possessive, a non-head relational noun, a denied or suspended relation, a question, a plural copula, and a capitalized pronoun inside dialogue. Three guard the other direction, so the gates cannot be tightened into silence: a sentence opener dropped without losing the mention after it, a given name that reads as a function word, and each copula the possessive still accepts. Entity boundaries have their own group: a name particle inside a run, a trailing particle that must not be folded in, a leading title dropped from the identity, a title in front of one name word kept because it is doing the distinguishing work, and a style qualifier that is only a title in front of another title. Ten more cover the alias lexicon: a lowercase key becoming a mention, case-insensitive matching alongside an exact uppercase key, an overlapping key that must not replace the run it spans, longest key first, no match inside a longer word, offsets that address the source text past a multi-byte character, a lexicon mention resolving a pronoun, a nearer capitalized run keeping that pronoun instead, a key covering a pronoun replacing it, and a lexicon mention taken outright where no capitalized word precedes the pronoun. Document-level behaviour has its own group: one fact stated three ways yielding one aggregate with three spans, repetition not raising an aggregate's confidence, aggregates ordered by where the story states them while the per-sentence output keeps its own order, a rejection suppressing only the triple it names and keying on the relation the caller saw, a denial recorded as the opposite claim in three phrasings, a conditional denial settling nothing, an assertion and its denial flagged with both spans, two compatible facts about one pair flagged as nothing, the cardinality constraint binding the object rather than the subject, a pronoun taking the previous sentence's referent once the document has said who she is, a chain stopping at a paragraph break, two pronouns in one sentence never sharing a referent, a cross-sentence link agreeing in gender, a personal pronoun refusing a thing and `it` refusing a person, an unestablished capital refused as a referent, a plural pronoun never linking at all, a capitalized pronoun never becoming a graph node, and the typographic apostrophe separating a mention as the straight one does |
| `types.rs` binding-export tests (`cargo test --features bindings`) | 8 | `ts-rs` regenerates `bindings/*.ts` from `Options`, `TripleCandidate`, `SpannedTriple`, `Rejection`, `AggregateTriple`, `Polarity`, `Conflict` and `ConflictKind` without drift |
| `tests/node/api.test.cjs` (`npm test`) | 13 | The N-API surface: extraction, empty input, `minConfidence` filtering, `aliases` (including a titled surface form as the key), `ontology`, the title rule reaching the binding, the out-of-range-confidence error, a suppressed rejection, aggregation with its order and spans, a denial flagged against its assertion, and cross-sentence pronoun linking with its agreement check |
| `tests/node/types.test.mts` (`npm run test:types`) | — | `index.d.ts` accepts valid `NapiOptions`/results and rejects invalid ones (`tsc --strict`) |

All pass as of this writing (98 under default features; the 8 binding-export
tests require `--features bindings`, which CI covers via `--all-features`).
Reproduce with:

```bash
cargo test                      # 98: segmentation + pipeline
cargo test --all-features       # 106: adds the binding-export tests
npm install && npm test
npm run test:types
```

CI additionally enforces `cargo fmt --check`, `cargo clippy --all-targets
--all-features -D warnings`, and a gate asserting the default build has zero
dependencies.

## Measured example output

Confidence and span values quoted in the README and `docs/INTEGRATION.md`
are captured directly from a run, not invented:

```bash
$ echo "Elena is Marco's sister. Marco mentors Dev, who works at the Archive." \
  | cargo run --features cli -- extract - --format json
```

```json
[
  { "subject": "dev", "relation": "works_at", "object": "archive",
    "confidence": 0.7488, "span": [39, 68], "rule": "verb-works-at-pattern" },
  { "subject": "elena", "relation": "sister_of", "object": "marco",
    "confidence": 0.85, "span": [0, 23], "rule": "possessive-sister-pattern" },
  { "subject": "marco", "relation": "mentors", "object": "dev",
    "confidence": 0.78, "span": [25, 42], "rule": "verb-mentor-pattern" }
]
```

Confidence is `score_confidence(base, gap)` (`src/heuristic/cooccurrence.rs`):
a base score carried by the pattern that matched — stated kinship and role
highest, then direct verb patterns, then social stance and relative-clause
patterns — reduced by up to 15% as the character gap between subject and
object approaches the 30-character cutoff enforced in
`find_relation_pattern`. It is not derived from a trained model or a
corpus-wide statistic — it is a fixed formula over a per-pattern constant and
a distance measurement, so identical inputs always produce identical scores.

## Precision on near-miss phrasing

The open question this replaces was per-noun precision for the possessive
lexicon: whether "sister" is a safer trigger than "friend". Probing it found
the variance is not per-noun at all. Three batches of sentences built around
the documented shapes — the same nouns and verbs, varied only in what joined
the two mentions or opened the sentence — produced 13 false positives out of
15 possessive probes, 8 out of 13 verb probes, and 6 out of 9 sentence-opener
probes. Every one fired at the pattern's full confidence, and the noun was
never the reason:

| Probe | Emitted before | Why it was wrong |
|---|---|---|
| "Elena visited Marco's sister." | `sister_of(elena, marco)` @ 0.85 | Names a third person |
| "Elena is not Marco's sister." | `sister_of(elena, marco)` @ 0.85 | Denies the relation |
| "Elena could be Marco's sister." | `sister_of(elena, marco)` @ 0.85 | Hedges it |
| "Dev believed Elena was Marco's sister." | `sister_of(dev, marco)` @ 0.81 | Claims it of the reporter |
| "Elena is Marco's friend's sister." | `sister_of(elena, marco)` @ 0.85 | Sister of the friend |
| "Elena is Marco's master key." | `master_of(elena, marco)` @ 0.85 | Names a thing |
| "Elena did not mentor Marco." | `mentors(elena, marco)` @ 0.77 | Denies the relation |
| "Elena refused to mentor Marco." | `mentors(elena, marco)` @ 0.75 | Suspends the event |
| "But Elena mentors Marco." | `mentors(but_elena, marco)` @ 0.78 | Splits the character |

One root cause covered most of it: each rule matched a substring of the text
between the mentions and never checked the rest of it. Every probe in the
table is now an assertion in `tests/heuristic.rs`, as are the true positives
of each batch, which pin the gates open; the gating is documented in
[ARCHITECTURE.md](./ARCHITECTURE.md).

This is adversarial probing by the pattern author, which is weaker evidence
than an independent judgment on real prose. It bounds nothing about behavior
on phrasing nobody thought to probe.

## Recall on real prose

Measured, and the result is bad enough to state plainly: **on 1.96 MB of
public-domain narrative prose the pipeline emitted one candidate, and that
candidate is wrong.**

Method. Three novels from Project Gutenberg — *The Age of Innocence* (541),
*Pride and Prejudice* (1342), *Howards End* (2891) — with the licence header
and footer stripped, split on blank lines and rewrapped, keeping every block of
at least 80 bytes. The only filter is the length floor, so the sample is not
shaped by a guess about which prose the extractor handles well.
`examples/precision_sample.rs` does this and is the reproduction:

```
cargo run --release --features json --example precision_sample -- \
    --out DIR --sample 100000 --seed 1 541.txt 1342.txt 2891.txt
```

That corpus is 5,014 paragraphs, which is what the command reports back.

At the commit where this was first measured, the pipeline emitted **one**
candidate over all of it, and that candidate was wrong. The same harness
against `ad9aa4e`, the commit before the precision work described above,
emits 24, of which **17 name a subject that is not an entity at all** — a
sentence-opening function word (`but`, `if`, `this`), a pronoun (`it`, `they`,
`his`, `he`), or a place standing in for a person (`new_york`). So the
precision work removed a large body of nonsense, and what the measurement then
showed is that almost nothing correct was there to keep.

### Cross-sentence pronoun linking, measured against the same corpus

Resolving a pronoun past its own sentence was first built ungated, and this
corpus rejected it: it added exactly one triple over the 5,014 paragraphs, and
that triple was wrong — "He had wanted work keenly at Oniton" resolved "He" to
the woman named in the sentence before, where the man it refers to was named
three sentences earlier.

What fixed it was not a wider window. No one-sentence lookback could have
reached the right antecedent, and a wider one would only have had more wrong
candidates to choose between. What fixed it was requiring evidence: the
register described in [ARCHITECTURE.md](./ARCHITECTURE.md) reads gender,
personhood and thinghood off the document itself, and a link is made only where
that evidence positively agrees with the pronoun.

Measured after that change, on the same corpus and with linking on
unconditionally: **the output is byte-identical to the run before the feature
existed** — the same six triples, no additions and no losses. The false
positive is gone and nothing correct was traded for it. `precision_sample`
reproduces this; the four files it writes diff clean.

That is the bar the feature had to clear to be on by default, and it is a
modest one: it says the mechanism does no harm here, not that it does good
here. It cannot do visible good on this corpus, because the relation rules fire
six times in 5,014 paragraphs and a resolved pronoun only matters in a sentence
where a rule also fires. Its accuracy is now bounded by entity precision rather
than by pronoun agreement — the links it still gets wrong are links to things
that were never names, which is the limitation the next section is about.

### Why: the rules matched a form prose does not use

Counting surface forms across the same three novels, against the same
relational-noun lexicon:

| Form | Occurrences |
| --- | ---: |
| `X is Y's <noun>` — the only form the possessive rule matched | **0** |
| `X's <noun> was Y` | 0 |
| `X, Y's <noun>` | 1 |
| `the <noun> of Y` | 13 |
| `X, the <noun> of Y` | 6 |

The rule set was built entirely around the Saxon possessive and a copula. That
exact construction does not occur once in 1.96 MB of narrative prose. English
prefers the "of" genitive, which was not recognized at all.

Three rules now cover the forms that do occur: the appositive
(`X, Y's <noun>`), the reversed possessive (`Y's <noun> was X`), and the "of"
genitive (`X, the <noun> of Y`, with or without a copula in place of the
comma). Each admits only a closed class of pre-nominal modifiers between the
mentions, so a relative clause or a conjunction is not read as an apposition.

### Precision, independently adjudicated

With those rules the same 5,014 paragraphs yield 6 candidates. Each was put to
two judges who had not seen the patterns, the rule names, or the confidence
scores — only the paragraph and the claim in plain English. Both returned the
same verdict on all six:

| | |
| --- | ---: |
| Candidates | 6 |
| Judged correct | 5 |
| Judged wrong | 1 |
| Inter-judge agreement | 6/6 |

**Precision 5/6.** The sample is far too small for that ratio to mean much —
the 95% interval on 6 trials runs from roughly 44% to 97% — and it is reported
as a count for that reason. The single wrong candidate is
`mentors(shapely, mentor)`, which reads a role noun as a person; it is the one
surviving candidate from before this work and neither new rule produced it.

One judge flagged a defect the rule changes did not address, in
`widow_of(bourgh, sir_lewis)` extracted from "Lady Catherine de Bourgh, widow
of Sir Lewis de Bourgh": the lowercase "de" broke the capitalized run, so both
slots normalized to a fragment of the surname the two people share, and the
claim was only distinguishable by taking the reading that makes them different
people. A closed list of name particles now continues a run already open, and
that candidate reads
`widow_of(catherine_de_bourgh, lewis_de_bourgh)`. The other five candidates
carry the same relation, direction and referents, so the counts above still
stand. The changed candidate was not re-adjudicated: both judges ruled on the
relation and its direction, which the fix does not touch, and the entity
boundary they objected to is what it repairs.

The honorific the subject then carried — the same class of boundary error one
level out, a capitalized run taking in every title before the name — was
tracked as issue #8 and is fixed too. Re-running the sample is how both were
found and how both were confirmed; the run is unchanged at 6 candidates and
three of them changed a mention:

| Before | After |
| --- | --- |
| `widow_of(right_honourable_lady_catherine_de_bourgh, sir_lewis_de_bourgh)` | `widow_of(catherine_de_bourgh, lewis_de_bourgh)` |
| `uncle_of(mr_percy_cahill, mrs_charles)` | `uncle_of(percy_cahill, mrs_charles)` |
| `father_of(bob_spicer, mrs_manson_mingott)` | `father_of(bob_spicer, manson_mingott)` |

`mrs_charles` keeps its title on purpose: a title in front of a single name
word is the only thing distinguishing the people who share that word. The same
rule is why `daughter_of(miss_darcy, mr_darcy)` is untouched — stripping
unconditionally would make both slots `darcy`, which `extract_relations` then
drops as a self-relation, costing a candidate the judges ruled correct.

### What the number is worth

Recall went from 1 candidate to 6. That is a real improvement and it is still
6 facts from three novels. The ceiling table above is the honest bound: with
this lexicon, roughly forty relational statements exist to be found in 1.96 MB
of prose, and the pipeline currently reaches a sixth of them. Nothing here
contradicts the test suite — every test still passes, because every test uses
the phrasing its rule was written for. That is exactly the limit of what a
suite written by the pattern author can tell you, and it is why this section
exists.

## Synthetic fiction set

`tests/synthetic_eval.rs` scores extraction against paragraphs written for the
file, none quoted from a manuscript. A case lists the claims its paragraph
states; a claim counts only if (subject, relation, object, polarity) matches, so
a wrong label is both a miss and a false positive. Negatives (no gold) are
dialogue fragments crossing an attribution, a third party's possessive, common
nouns, pronouns alone, modal and conditional phrasing, desire, questions, and
verbs with other content between the mentions.

Three sets run: *development* (written beside the rules and used to tune them),
*held-out* (longer, dialogue-heavy paragraphs written afterwards; the first run
exposed misses that were then fixed, so it is no longer untouched), and
*narrator-context* (a shared `Context` with a named first-person narrator).
`cargo test --test synthetic_eval -- --nocapture` prints every miss and false
positive.

| Set | Paragraphs | Gold | Before (precision / recall) | After (precision / recall) |
|---|---|---|---|---|
| development | 84 | 58 | 0.750 / 0.103 | 1.000 / 1.000 |
| held-out | 30 | 21 | 1.000 / 0.048 | 1.000 / 0.905 |
| narrator-context | 13 | 10 | n/a / 0.000 | 1.000 / 1.000 |
| all | 127 | 89 | 0.778 / 0.079 | 1.000 / 0.978 |

"Before" is the engine at `73a1969` over the same cases. The remaining misses
are a subject elided across a coordinated verb ("divorced Bram ... and moved
back to Tulsa") and a subject separated from its verb by a relative clause
("Elena, who works for Marco, has never met Dev"). A set this size, written by
the author of the rules, bounds nothing about real prose; its use is to catch
regressions and to document which phrasings are read and which are not. The
precision floor asserted in CI is 0.95 and the recall floor 0.85.

## What is not measured

- **Precision at a sample size worth quoting.** Six adjudicated candidates is
  a count, not a rate. Getting to a number with a usable interval needs the
  recall work to continue until the corpus yields candidates in the hundreds,
  which is a lexicon and pattern problem rather than a measurement one.
  No labeled corpus is checked in. The measurement above is reproduced from
  the seed and the command, not from a fixture, so the repository carries no
  copy of the prose and nothing here goes stale against one.

  No such corpus appears to be published. A survey of the citation cluster in
  [Artificial Relationships in Fiction](https://aclanthology.org/2025.latechclfl-1.13.pdf)
  (LaTeCH-CLfL 2025), the most recent work to need one, turns up only speaker
  identification, character detection, spatial annotation, and unsupervised
  work with no gold release. [LitBank](https://github.com/dbamman/litbank) is
  the right domain under a usable license but annotates entities, events,
  coreference and quotations, with no relation layer.
  [Massey et al. 2015](https://arxiv.org/abs/1512.00728) has the right
  relation inventory but annotates third-party plot summaries rather than the
  prose, and ships no license. ARF itself is GPT-4o output that its authors
  state is unvalidated. Precision is the cheaper half to establish and needs
  no corpus: sample real prose, extract, and have someone who did not write
  the patterns judge each emitted triple against its sentence. The probe
  above is not that — it is the author testing his own guesses about where
  the patterns break.
- **Coverage of relation phrasing outside the documented patterns.**
  Every current test exercises the exact phrasing each pattern was built
  for; none establish a recall floor on the broader space of ways the same
  relations get expressed in real writing.
- **Cross-sentence behavior.** Every test operates within a single sentence
  or a small fixed passage; there is no evaluation of pronoun or entity
  resolution across a full chapter or document.

A precision/recall benchmark against a genuinely independent labeled corpus
remains future work; see "What is not measured" above for why no
redistributable corpus has been adopted.

## Hand-labelled real text

`tests/real_text_eval.rs` scores whole-book extraction against hand labels on
sentences sampled by fixed seed (`tests/corpus/tools/sample_public.py`): 150
from the six public-domain novels in `tests/corpus/`, and a private set
(`NG_PRIVATE_EVAL`, never committed) of 173 from contemporary novels and the
author's manuscript excerpts. Labels are tiered: stated, `implied`, and
described (a bracketed side such as `[her mother = Mrs. Bennet]`).
`tests/corpus.rs` snapshots every whole-book aggregate, so a rule change shows
as the claims it adds and loses.

Baseline (2026-11-22): public, 44 stated labels, none found; private, 31
stated labels, one found and one false positive. 438 of 548 labels need a
person the sentence only describes, mostly narrators and unnamed speakers,
and `speaks_to` is the most frequent relation.

### Plan and settled decisions

- Inference stays local and the default build dependency-free. No remote
  model at run time or in tests.
- Odd-numbered items are the held-out half: tune on even items, read the odd
  half only at milestones.
- Order: the apostrophe fix (`O’Leary` is cut to `leary`); dialogue speaker
  attribution emitting `speaks_to`; narrator identity; nodes for described
  people; then a learned pair classifier.
- The classifier: a teacher (a local model through ollama) is first scored on
  the even half with the same matcher; only if it does well is it used to
  label training text, with every evaluated window excluded. The student is a
  small fine-tuned encoder run locally through Tract behind the opt-in `model`
  feature. It scores candidate pairs and resolves described mentions.
  A linear model cannot reach
  the target: most labels need coreference or a speaker carried across turns.
  The rule pipeline stays the dependency-free default and supplies features. Training text for shipped weights is public domain plus the
  author's own writing, not the commercial novels.
- Target: recall of at least 0.7 over all tiers on the held-out half, with
  precision of at least 0.8 once extractions are numerous enough to measure.
  1.0 is not a meaningful goal: annotators disagree on fiction relations, and
  half the items changed under the gpt-6.2-astra review.
- Labels were reviewed by gpt-6.2-astra (public: 78 of 150 items changed;
  private: 115 of 173). Removals mostly enforce the rule that only the target
  sentence is labelled. After the review and the apostrophe fix: public 0/58
  stated, private 2/32 stated with no false positives.

### Ceiling and teacher (2026-11-22)

`NG_HALF=even|odd` scores one half. `NG_PREDICTIONS` (public) and
`NG_PRIVATE_PREDICTIONS` (private) score a file of `item | A | relation | B`
lines with the same matcher instead of the library;
`tests/corpus/tools/teacher.py` writes one from a local ollama model. Builds
use `CARGO_TARGET_DIR=/Volumes/C/rust-target-narrative-graph`, because other
sessions hold the lock on the shared target directory for hours.

The report gives each tier a ceiling: the share of labels that are
matchable, with both sides named and a relation from the guide (its lists,
the relations its rules name in backticks such as `speaks_to`, and every
relation the library has a rule for). The matcher needs the relation string
exactly, and the labels invent relations freely (`limits_criticism_of`,
`wants_to_visit`), most of them used once.

| set, half | labels | ceiling all tiers | stated | implied | described | invented names, used once |
|---|---|---|---|---|---|---|
| public even | 150 | 0.593 | 0.421 | 0.700 | 0.612 | 38, 29 |
| public odd | 170 | 0.576 | 0.538 | 0.682 | 0.569 | 52, 45 |
| private even | 121 | 0.331 | 0.438 | 0.692 | 0.261 | 45, 38 |
| private odd | 126 | 0.341 | 0.500 | 0.875 | 0.275 | 49, 41 |

So recall of 0.7 over all tiers is out of reach for any extractor, not only a
vocabulary-bound one, while the labels stand: a model cannot learn names used
once. Private described labels are mostly nameless (`[the man]`).

- Library, recall over all tiers: public even 0.020, odd 0.000; private even
  0.000, odd 0.016 (stated 2/16, no false positives).
- Teacher, qwen3:14b without thinking, 3000 characters of preceding text, a
  cast of frequent names and the label guide as the prompt, public even:
  recall 0.093 over all tiers and 0.135 over the matchable labels, precision
  0.136 over 103 extractions. Most false positives are invented relations or
  common nouns as sides. Superseded: this run sliced the book at the wrong
  offset; see the v3 table under "Labels revised onto the vocabulary".

### Labels revised onto the vocabulary (2026-11-22)

Chosen over scoring only matchable labels, a synonym table in the matcher, or
a lower target. `tests/corpus/tools/revise_relations.py` rewrites an invented
relation to the guide relation that says the same (`scolds` and `warns` to
`speaks_to`, `has_home_in` to `lives_in`, `distrusts` to a denied `trusts`,
`visits` a person to `meets`) and comments out the rest as `# outside the
vocabulary:`, since an invented name used once can neither be learned nor
ruled for. A denied label is never rewritten: denying a specific act is not
denying the broader relation. Public: 9 rewritten, 98 outside the
vocabulary (9 of them `visits` to a place), 5 duplicates of an existing
label; private: 12, 94 and 1 (backups `labels.before-relations.txt`,
`labels.before-names.txt`). Eight private nameless sides got the name the
book gives them, checked against the text; the other 51 are never named
(most of them in *Outline*). The guide now says to leave a relation out when
none fits.

`visits` joined the guide's verbs afterwards, so the 7 public and 3 private
`visits` labels to a place are scored again.

| set, half | labels | ceiling | library recall |
|---|---|---|---|
| public even | 106 | 0.925 | 0.028 |
| public odd | 118 | 0.915 | 0.000 |
| private even | 78 | 0.667 | 0.000 |
| private odd | 77 | 0.675 | 0.026 |

The private ceiling stays under 0.7 because of the never-named sides, so the
target (recall 0.7, precision 0.8) applies to the public odd half only; the
private set is reported, never gated.

Teacher, qwen3:14b without thinking, public even, on these labels before
`visits` was restored (102 labels). Runs
before v3 sliced the book by characters at a byte offset, so their context
came from later in the book; v3 decodes from the byte offset and adds the `~`
line.

| prompt | recall all tiers | over matchable | precision |
|---|---|---|---|
| v1, guide only, wrong context | 0.137 | 0.149 | 0.136 |
| v2, vocabulary and named sides required, wrong context | 0.108 | 0.117 | 0.147 |
| v3, as v2 with the right context | 0.206 | 0.223 | 0.163 |

v3 finds 6/9 stated, 1/8 implied and 14/85 described labels with 108 false
positives: speaker and listener reversed, and background kinship the
sentence does not state ("Mrs. Bennet | mother_of" every daughter). With
thinking on it takes about eight minutes an item. Too weak to label training
text, so the next work is the rule path for `speaks_to`, about 45% of public
labels: conversation turns, pronoun speakers, and the narrator's identity.

### Conversation turns (2026-11-23)

`src/heuristic/dialogue.rs` solves each conversation whole once two
paragraphs pass without speech. A turn is anchored by its own tag or by the
turn before addressing someone; the conversation is cut wherever an anchor
breaks alternation (a third name, one person on both sides, two tags on one
turn); a stretch whose two sides each have a tag gives every turn to its
side, said to the other person unless it addresses someone, and a pronoun
tag that fits only the other side cancels the stretch. Speech left open at a
paragraph's end joins the next paragraph when that one reopens the
quotation, and a turn addressing three people or more is a recounted
conversation whose addresses are ignored. Each `speaks_to` carries a span on
every sentence of the turn. A first-person book gets a narrator: the name the
turns beside "I said" turns address, at least three times and twice the
runner-up (Jane Eyre: `jane`; no other public book qualifies), and the
document is read again with it. Hard-wrapped speech no longer closes at every
line break, only at a paragraph break.

| run | public even recall, all tiers | precision on labelled sentences |
|---|---|---|
| before | 0.028 | 1.000 (3 of 3) |
| forward tracker | 0.057 | 0.750 (6 of 8) |
| conversation resolver | 0.075 | 0.727 (8 of 11) |

Public odd, scored once at this milestone: recall 0.034 over all tiers,
precision 0.571 (4 of 7).

Private: even 0.000, odd 0.039 at precision 0.750. That is far below the
target, so the rule path alone will not reach it: most remaining `speaks_to`
misses are turns no tag in their stretch reaches, narrators the vote does not
find (Wuthering Heights has two, Moby-Dick's Ishmael is rarely addressed),
and aliases (Nelly and Ellen, Cathy and Catherine, Lizzy and Elizabeth).

### Document character profiles and confidence

The first fit on the existing public evaluation used 11 predictions from
three rules. On seven held-out predictions its Brier loss was 0.2438,
compared with 0.2271 for the heuristic. The small sample motivated a
separate book-level calibration review.

`tests/litbank.rs` aligns the LitBank tokens to the original prose and
scores all 100 annotated excerpts. A linked pronoun or description matches
when its span is exact and the predicted ID has an unambiguous named anchor
in the reference chain. Explicit apposition and copula links can also
supply the named anchor for a description. This measures links to named
people. For events it checks whether the extractor's trigger overlaps an
annotated realis trigger. [LitBank dataset](https://github.com/dbamman/litbank), [Coreference annotation paper](https://aclanthology.org/2020.lrec-1.6/)

| LitBank check | Correct | Predictions | Gold with a named anchor |
|---|---:|---:|---:|
| Pronoun links | 1,404 | 2,348 | 9,924 |
| Description links | 8 | 14 | 1,549 |

The event trigger labels overlap both detected deaths and one of two
detected journeys. The existing six-book public relation evaluation finds
13 of 224 labels with 5 extra predictions on labeled sentences. That gives
0.058 recall over all tiers and 0.722 precision.

The relation review is stored in `tests/corpus/litbank-calibration.tsv`.
The fixture retains 94 predictions reviewed against their surrounding
prose in complete LitBank books. One verdict was unclear. It records the
book, byte span, candidate, polarity and rule so the test can verify the
same predictions are being scored. The six existing evaluation novels
and their alternate editions were excluded.

Source IDs divisible by three were excluded from sampling. Books with
source IDs congruent to 0 or 1 modulo 5 went into the check split.
The review took at most one candidate per book and rule family. Candidates
were ranked by a SHA-256 hash prefixed by the sample seed `20261123`.
Exact phrases and inferred turns received additional fit examples from
the same ranking. Predictions removed by subsequent rule fixes were
discarded from the fixture.

Each estimate is `(correct + 4 × heuristic) / (observations + 4)`.
Families need at least five fit verdicts.

| Family | Correct | Fit verdicts |
|---|---|---|
| Inferred dialogue turn | 9 | 23 |
| Explicit address | 10 | 10 |
| Nominal relation | 7 | 10 |
| Exact phrase | 15 | 22 |

On the 23 supported predictions in the check split, Brier loss rose from
0.2202 with heuristic scores to 0.2253 with the estimates. On the seven
supported predictions from the original public odd split, it moved from
0.2271 to 0.2227. These checks provide limited evidence for choosing a
probability threshold.

LitBank is by David Bamman and collaborators, licensed CC BY 4.0. These
checks use commit `3e50db0ffc033d7ccbb94f4d88f6b99210328ed8`.
[Source and attribution](https://github.com/dbamman/litbank/tree/3e50db0ffc033d7ccbb94f4d88f6b99210328ed8)

```sh
NG_LITBANK_ROOT=/path/to/litbank cargo test --release --test litbank -- --ignored --nocapture
NG_HALF=even cargo test --release --test real_text_eval -- --include-ignored --nocapture
NG_HALF=odd cargo test --release --test real_text_eval -- --include-ignored --nocapture
```

### Paid teacher (2026-11-23)

Authorised by the user as an exception to the paid-API rule: score a frontier
model as teacher on public even items first; if it reaches about 0.6 recall
at 0.7 precision, it labels public-domain training windows only. Private
text is never sent (`teacher.py --provider openai` refuses any other corpus).
Requests go through the OpenAI Batch API (`--batch submit`, then `--batch
collect`) at half price, with the guide first so its prefix is cached.
gpt-6.2-astra also reviewed the labels, so its agreement with them may read
high. Batch `batch_6b040fc3ffe081908bd1cd8b71d7af54`, state in
`/Volumes/C/ng-teacher/public-even-astra.txt.batch.json`.

Result, public even (106 labels): recall 0.585 over all tiers (0.633 over the
matchable), precision 0.705 over 88 extractions; stated 9/10, implied 1/9,
described 52/87. Several of the 26 false positives are spellings the matcher
does not join (`Adela` for Adèle, `Lizzy` for Elizabeth). That is at the bar
set for a usable teacher (about 0.6 and 0.7), against 0.206 and 0.163 for
qwen3:14b. Answers: `/Volumes/C/ng-teacher/public-even-astra.raw.txt`.

### Local student (2026-11-23)

The teacher labeled 2,004 public-domain training windows and returned 2,361
claims. The batch state, sample, and answers are in
`/Volumes/C/ng-teacher/student`. The DeBERTa-v3-small run used 1,405 training
windows and 396 validation windows. It selected epoch one and a threshold of
0.16 on teacher validation, where precision was 0.260 and recall was 0.198.
A trial that scored name tokens at their locations in the passage reached
0.187 validation F1. The selected checkpoint reached 0.225.

| Extractor | Even recall | Even precision | Odd recall | Odd precision |
|---|---:|---:|---:|---:|
| Conversation resolver | 0.075 | 0.727 | 0.034 | 0.571 |
| Conversation resolver and student | 0.113 | 0.353 | 0.102 | 0.375 |
| Paid teacher | 0.585 | 0.705 | — | — |

Recall covers all tiers. The student scored the sampled sentence spans with
book context. The rules and the matcher used the same revision as the
conversation resolver comparison (`081c2ad`). On public even, the student had
both candidate names for 77 of 98 usable claims. The combined run found 12
of 106 claims with 22 false positives. It found 12 of 118 on the held-out
half with 20 false positives.

The `model` feature serves the ONNX export with Tract and SentencePiece.
The trained checkpoint is at `/Volumes/C/ng-teacher/student/deberta-v3-small-ranked`.
See the [training and evaluation commands](../tests/corpus/README.md#local-student).