ModernBookNLP speaker attribution for Core ML: 2,560-token 6-bit encoder, head, tokenizer
Browse filesFiles changed (7)
123456789101112131415161718192021MIT License
Copyright (c) 2021 David Bamman
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123version https://git-lfs.github.com/spec/v1oid sha256:af507797eaf842ba5b1c125496bdb139c2a6f6352d91f1b588d221dcb8c2e71asize 382350123version https://git-lfs.github.com/spec/v1oid sha256:b84e0730d65ff4bb6044fec41b33c77634f1528d86f42cede702084c43eca6f9size 313339904123456789101112131415161718{ "fileFormatVersion": "1.0.0", "itemInfoEntries": { "904CF4C3-AE16-48A6-9077-E05065FDA207": { "author": "com.apple.CoreML", "description": "CoreML Model Weights", "name": "weights", "path": "com.apple.CoreML/weights" }, "CD42E891-F1E6-4CE5-8B83-2CF754F9A515": { "author": "com.apple.CoreML", "description": "CoreML Model Specification", "name": "model.mlmodel", "path": "com.apple.CoreML/model.mlmodel" } }, "rootModelIdentifier": "CD42E891-F1E6-4CE5-8B83-2CF754F9A515"}12345678910111213141516171819202122232425262728293031323334---license: mitbase_model:- gasmichel/ModernBookNLP- answerdotai/ModernBERT-largelibrary_name: coremltags:- 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 PyTorchoriginal 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 isreleased under the MIT license.123version https://git-lfs.github.com/spec/v1oid sha256:75c374bd26a7b3ad1a2212dbcc9a8fd112f629f7213d29c785404710c7ba3d65size 16785410LICENSE-BookNLPAdded+21
ModernBookNLP_L2560_pal6.mlpackage/Data/com.apple.CoreML/model.mlmodelAdded+3
ModernBookNLP_L2560_pal6.mlpackage/Data/com.apple.CoreML/weights/weight.binAdded+3
ModernBookNLP_L2560_pal6.mlpackage/Manifest.jsonAdded+18
README.mdAdded+34
speaker-head.binAdded+3
tokenizer.jsonAdded