ModernBookNLP speaker attribution for Core ML: 2,560-token 6-bit encoder, head, tokenizer
Browse files
LICENSE-BookNLP
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2021 David Bamman
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
ModernBookNLP_L2560_pal6.mlpackage/Data/com.apple.CoreML/model.mlmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af507797eaf842ba5b1c125496bdb139c2a6f6352d91f1b588d221dcb8c2e71a
|
| 3 |
+
size 382350
|
ModernBookNLP_L2560_pal6.mlpackage/Data/com.apple.CoreML/weights/weight.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b84e0730d65ff4bb6044fec41b33c77634f1528d86f42cede702084c43eca6f9
|
| 3 |
+
size 313339904
|
ModernBookNLP_L2560_pal6.mlpackage/Manifest.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fileFormatVersion": "1.0.0",
|
| 3 |
+
"itemInfoEntries": {
|
| 4 |
+
"904CF4C3-AE16-48A6-9077-E05065FDA207": {
|
| 5 |
+
"author": "com.apple.CoreML",
|
| 6 |
+
"description": "CoreML Model Weights",
|
| 7 |
+
"name": "weights",
|
| 8 |
+
"path": "com.apple.CoreML/weights"
|
| 9 |
+
},
|
| 10 |
+
"CD42E891-F1E6-4CE5-8B83-2CF754F9A515": {
|
| 11 |
+
"author": "com.apple.CoreML",
|
| 12 |
+
"description": "CoreML Model Specification",
|
| 13 |
+
"name": "model.mlmodel",
|
| 14 |
+
"path": "com.apple.CoreML/model.mlmodel"
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"rootModelIdentifier": "CD42E891-F1E6-4CE5-8B83-2CF754F9A515"
|
| 18 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model:
|
| 4 |
+
- gasmichel/ModernBookNLP
|
| 5 |
+
- answerdotai/ModernBERT-large
|
| 6 |
+
library_name: coreml
|
| 7 |
+
tags:
|
| 8 |
+
- coreml
|
| 9 |
+
- quotation-attribution
|
| 10 |
+
- speaker-attribution
|
| 11 |
+
- literature
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# ModernBookNLP speaker attribution, Core ML
|
| 15 |
+
|
| 16 |
+
A Core ML conversion of the quotation-attribution model in [ModernBookNLP](https://huggingface.co/gasmichel/ModernBookNLP)
|
| 17 |
+
(`ModernBERT_T2000.safetensors`: a ModernBERT-large encoder fine-tuned to find who speaks each quotation in fiction),
|
| 18 |
+
for on-device use on iPhone and iPad.
|
| 19 |
+
|
| 20 |
+
Files:
|
| 21 |
+
- `ModernBookNLP_L2560_pal6.mlpackage`: the encoder, a fixed 2,560-token window, weights palettized to 6 bits
|
| 22 |
+
(k-means, grouped by 16 channels), float16, iOS 18+. It runs almost entirely on the Neural Engine. Input `input_ids` and
|
| 23 |
+
`attention_mask` (int32, 1×2560, pad id 50283); output `hidden` (1×2560×1024). Attention masks use -1e4 instead of
|
| 24 |
+
float32's minimum, so float16 padding rows stay finite.
|
| 25 |
+
- `speaker-head.bin`: the scoring head, float16, little-endian: W0 (2048×4096, batch norm folded in), b0 (2048),
|
| 26 |
+
W3 (2048), b3 (1). Score(quote, mention) = W3 · GELU(W0 · [h(q_start), h(q_end), h(m_start), h(m_end)] + b0) + b3.
|
| 27 |
+
- `tokenizer.json`: ModernBERT's tokenizer, unchanged.
|
| 28 |
+
|
| 29 |
+
Quality: on four PDNC novels (4,526 quotations), the converted model's speaker picks agree with the PyTorch
|
| 30 |
+
original on 98.2% of quotations, with the same accuracy (75.3% vs 75.1% speaker correct, using BookNLP's pipeline).
|
| 31 |
+
|
| 32 |
+
Credits and licenses: ModernBookNLP by its authors ([gasmichel](https://huggingface.co/gasmichel), MIT); ModernBERT by Answer.AI and LightOn
|
| 33 |
+
(Apache-2.0); BookNLP by David Bamman (MIT, see `LICENSE-BookNLP`). Converted by Quack Later; the conversion is
|
| 34 |
+
released under the MIT license.
|
speaker-head.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:75c374bd26a7b3ad1a2212dbcc9a8fd112f629f7213d29c785404710c7ba3d65
|
| 3 |
+
size 16785410
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|