File size: 1,729 Bytes
a0a4a6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
base_model:
- gasmichel/ModernBookNLP
- answerdotai/ModernBERT-large
library_name: coreml
tags:
- coreml
- quotation-attribution
- speaker-attribution
- literature
---

# ModernBookNLP speaker attribution, Core ML

A Core ML conversion of the quotation-attribution model in [ModernBookNLP](https://huggingface.co/gasmichel/ModernBookNLP)
(`ModernBERT_T2000.safetensors`: a ModernBERT-large encoder fine-tuned to find who speaks each quotation in fiction),
for on-device use on iPhone and iPad.

Files:
- `ModernBookNLP_L2560_pal6.mlpackage`: the encoder, a fixed 2,560-token window, weights palettized to 6 bits
  (k-means, grouped by 16 channels), float16, iOS 18+. It runs almost entirely on the Neural Engine. Input `input_ids` and
  `attention_mask` (int32, 1×2560, pad id 50283); output `hidden` (1×2560×1024). Attention masks use -1e4 instead of
  float32's minimum, so float16 padding rows stay finite.
- `speaker-head.bin`: the scoring head, float16, little-endian: W0 (2048×4096, batch norm folded in), b0 (2048),
  W3 (2048), b3 (1). Score(quote, mention) = W3 · GELU(W0 · [h(q_start), h(q_end), h(m_start), h(m_end)] + b0) + b3.
- `tokenizer.json`: ModernBERT's tokenizer, unchanged.

Quality: on four PDNC novels (4,526 quotations), the converted model's speaker picks agree with the PyTorch
original on 98.2% of quotations, with the same accuracy (75.3% vs 75.1% speaker correct, using BookNLP's pipeline).

Credits and licenses: ModernBookNLP by its authors ([gasmichel](https://huggingface.co/gasmichel), MIT); ModernBERT by Answer.AI and LightOn
(Apache-2.0); BookNLP by David Bamman (MIT, see `LICENSE-BookNLP`). Converted by Quack Later; the conversion is
released under the MIT license.