Image-Text-to-Text
MLX
Safetensors
Chinese
ocr
rare-characters
ids
ideographic-description-sequence
glyphwiki
palaeography
Instructions to use OpenGlyph/OpenGlyph-OCR-IDS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use OpenGlyph/OpenGlyph-OCR-IDS with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("OpenGlyph/OpenGlyph-OCR-IDS") config = load_config("OpenGlyph/OpenGlyph-OCR-IDS") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
File size: 27,002 Bytes
20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e a9aab5c 20fc05e | 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 | ---
license: apache-2.0
base_model: OpenGlyph/OpenGlyph-OCR-0
base_model_relation: finetune
pipeline_tag: image-text-to-text
language:
- zh
tags:
- ocr
- mlx
- rare-characters
- ids
- ideographic-description-sequence
- glyphwiki
- palaeography
---
# OpenGlyph-OCR-IDS
读古文字学论著里**排印的行**:一行图进去,文字出来。它是 [OpenGlyph-OCR-0](https://huggingface.co/OpenGlyph/OpenGlyph-OCR-0) 的下一版,多了两样本事:
- **没有码位、GlyphWiki 也没有收的字,写成 IDS。** IDS(表意文字描述序列)用 Unicode 的结构符写出一个字由哪些部件怎样拼成,例如 `⿰亻木` 就是“休”。这样的字它写成 `<ids>⿰拍嵩</ids>`,作者新造、哪个字表都没有的字也有了写法。
- **生僻字按部件再拼一遍。** 凡是读出生僻字或字形记号的地方,另一套权重都照着图把这个字再拼成 IDS;拼出的若是有码位的字,把握又够,就换成那个字。测试用的四篇论文,整行全对从 83.4% 升到 87.2%,字错率从 0.90% 降到 0.70%;其中含难字的片段,整段全对从 80.5% 升到 88.2%,字错率从 2.89% 降到 1.88%。
有码位的字照 Unicode 写;没有码位、GlyphWiki 有收的字形写成 `<gw:字形名>`(同 OpenGlyph-OCR-0)。另可要它把每处的**第二选项**一并给出(见下文“输出”)。

## 它读什么,不读什么
- **读**:论文、著作里排印出来的一行横排文字(正文、脚注),包括其中的扩展区汉字、隶定字、造字。
- **整页也能读,但推荐一行一行读。** 我们拿一页排印的论文试过(单栏横排,22 行,691 项,行内有一处古文字摹形插图;答案是逐字对着原图录的,凡读法有出入处都放大原图核过):整页一次读完,错 8 项(1.16%),两次测得用时 33 秒和 16 秒;切成 22 行一行行读,错 5 项(0.72%),13 个生僻字全对。整页读时,拼字的两条路用不上——它们按一行里的位置找字,整页上找不准——所以整页读出来的就是 OpenGlyph-OCR-0 的读法;要用上 IDS 和按部件拼生僻字,就切成行读。整页读用 `read_page`(见下文),不写换行。只试过这一页,多栏、表格、竖排的页面没有试过。测量用的论文行高约 100–150 像素,专项测试的行高约 96 像素。
- **不读原始材料**:甲骨、金文、简帛的照片和拓片不在它的范围里,它读的是论著里印出来的字。
- 竖排、手写没有测过。高大于宽的图被当作竖排,不开 IDS,只按 OpenGlyph-OCR-0 读。
## 输出
```python
out = read_line(ocr, "line.png")
out["text"] # 一行文字:Unicode 字、<gw:字形名>、<ids>IDS</ids>
out["ids"] # 它写的每个 IDS,以及拼出的是什么:有码位的字 / 有记号的字形 / 新的字形
```
下面是专项测试里一行的真实输出(这一行整行读对):
```text
𤪷也庾參與<gw:u2ff1-u65e5-u82f1><gw:ebag_s093-073><ids>⿰拍嵩</ids>了燒造磚瓦的工作
```
`text` 里三种写法的意思:
| 写法 | 意思 |
|---|---|
| 普通的字,如 `𤪷` | 有码位的字,照 Unicode 写;生僻字可能是拼出 IDS 之后换回的 |
| `<gw:u2ff0-u79c0-u6208>` | GlyphWiki 有收、没有码位的字形,名字可到 `https://glyphwiki.org/wiki/字形名` 查 |
| `<ids>⿰…</ids>` | 没有码位、GlyphWiki 也没有收(或它不认得)的字,由它拼出的 IDS |
**第二选项。** `read_line(ocr, "line.png", options=True)` 另给 `out["options"]`:凡有另一种读法的地方,给出那一读法和它的来历——问过拼字的两条路的地方,给没有采用的那一读(拼出的 IDS,或原来那个字);没问过、但它对第一选择把握不大的地方(第一选择的分数比第二选择高不到 4,分数指模型输出的 logit),给它的第二选择。`text` 本身不因此而变。在 313 段论文片段上,生僻字按第一选择读对 93.0%,算上第二选项读对 94.8%;平均每段给出 0.54 个第二选项。论文片段里的一段(`at_text` 是这一处在 `text` 里的位置):
```json
{
"text": "(陳)榑叄立事歲右<ids>⿳亠回米</ids>(廩)釜",
"options": [
{
"at_text": 3,
"stands_text": "榑",
"other_text": "搏",
"other_from": "the reader",
"lead": 0.562
},
{
"at_text": 4,
"stands_text": "叄",
"other_text": "<ids>⿳𠫯八三</ids>",
"other_from": "the speller",
"lead": 2.951
},
{
"at_text": 9,
"stands_text": "<ids>⿳亠回米</ids>",
"other_text": "稟",
"other_from": "the reader",
"lead": 1.256
},
{
"at_text": 27,
"stands_text": "釜",
"other_text": "釡",
"other_from": "the reader's second choice",
"lead": 1.625
}
]
}
```
## 怎么用(MLX,Apple 芯片)
```bash
hf download OpenGlyph/OpenGlyph-OCR-IDS --local-dir OpenGlyph-OCR-IDS
cd OpenGlyph-OCR-IDS
pip install -r requirements.txt
python -m openglyph_ocr_ids line.png # 每行图输出一行 JSON
python -m openglyph_ocr_ids line.png --options # 连同第二选项
python -m openglyph_ocr_ids page.png --page # 整页一次读(按 OpenGlyph-OCR-0 的读法,不写 IDS)
```
```python
from openglyph_ocr_ids import load, read_line, atoms
ocr = load() # 本仓库所在的目录
out = read_line(ocr, "line.png")
print(out["text"])
print(atoms(out["text"])) # [('text', '其'), ('glyph', 'u2ff0-u79c0-u6208'), ('ids', '⿰…'), …]
page = read_page(ocr, "page.png") # 整页一次读;切成行用 read_line 读,效果更好
print(page["text"], page["complete"]) # complete 为 False 时,加大 max_tokens(默认 2048)
```
- **只有 MLX 版。** 读一行要四套权重轮流上场,还要按图把字切成部件再读,这一整套是在 MLX 上写、也在 MLX 上量的,暂时没有 PyTorch 版。只要 OpenGlyph-OCR-0 那一部分的话,它有 `transformers` 版。
- 版本要照 `requirements.txt` 装(mlx 0.32.3、mlx-vlm 0.3.12、transformers 5.18.0、tokenizers 0.23.2)。底模是 16 位浮点,换了版本算出来的数会有细微出入,下面的成绩就不一定原样重现。torch 和 torchvision 只用来预处理图像(装了它们,图像的预处理才与测量时逐像素相同)。
- **发布前核对过**:这个文件夹里的代码搭出的模型,每个数组、每张表都与测量所用的模型逐位相同(1,330 项);拿它重读测试里的 190 行,每行的输出、每个拼字处的记录都与测量时的读法相同,另有 32 行连同第二选项也相同;整页试读的那一页,用它整页读,也与试读时一字不差。
## 成绩
以下都是 2026 年 11 月用这一套权重、MLX 版量的。“原版”指 Xiaomi-OCR-0 原样、用它自己的提示词去读同样的图。整行(整段)一字不差才算全对(空格不计,全角半角算同一个字);字错率 = 编辑距离 ÷ 答案的字数(一个字形记号算一个字)。写出的 IDS 若画的正是答案那个字,算读对;严格按写出的字符串算的数,凡有不同,都在表下注明。
### 真实论文
四篇古文字学论文的电子版和一本书的四页扫描,都不在任何一套权重的训练材料里。“含难字的片段”是从那四篇论文里切出的、带难字的片段,每段 4–16 个字。
| | | 原版 Xiaomi-OCR-0 | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|---|---|
| **论文整行**(398 行,四篇论文的整行) | 整行全对 | 272(68.3%) | 332(83.4%) | **347(87.2%)** |
| | 字错率 | 3.71% | 0.90% | **0.70%** |
| **论文里含难字的片段**(313 段,同四篇论文,每段 4–16 字) | 整段全对 | 225(71.9%) | 252(80.5%) | **276(88.2%)** |
| | 字错率 | 5.14% | 2.89% | **1.88%** |
| **一本书的扫描页**(93 行,四页) | 整行全对 | 54(58.1%) | 69(74.2%) | **75(80.6%)** |
| | 字错率 | 2.20% | 1.12% | **0.83%** |
注:论文里含难字的片段:严格按写出的字符串算,OpenGlyph-OCR-IDS 整段全对 275 段,字错率 1.94%。两者逐行相比,论文整行里只有 OpenGlyph-OCR-IDS 读对的 21 行,只有 OpenGlyph-OCR-0 读对的 6 行;论文里含难字的片段里只有 OpenGlyph-OCR-IDS 读对的 24 段,只有 OpenGlyph-OCR-0 读对的 0 段;一本书的扫描页里只有 OpenGlyph-OCR-IDS 读对的 7 行,只有 OpenGlyph-OCR-0 读对的 1 行。
### 真实论文里的几行

图中六行的出处(截图只用来说明模型读得怎样,著作权归原作者和出版者):
1. 何義軍:《戰國陶文綜合研究》,吉林大學博士學位論文,2023 年 12 月,第 192 頁。
2. 陈晶晶:《清华简典型楚文字及相关问题研究》,河北大学博士学位论文,2025 年 5 月,第 36 页。
3. 沈奇石:《「隼」字異讀考論》,《臺大中文學報》第 84 期,2024 年 3 月,第 27 頁(全文第 1–36 頁),DOI:10.6281/NTUCL.202403_(84).0001。
4. 鄔可晶:《甲骨金文語文論稿》,上海:上海古籍出版社,2024 年 9 月,第 1 頁(書頁掃描)。
5. 同上,第 4 頁(書頁掃描)。
6. 何義軍:《戰國陶文綜合研究》,第 514 頁。
测试用的四篇论文,除上面三篇外,还有一篇 2025 年的学位论文;我们不知道它是否已经公开,这里不列名,也不用它的截图。那本书的四页扫描,是《甲骨金文語文論稿》的第 1–4 頁。
### 生僻字

| | | 原版 Xiaomi-OCR-0 | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|---|---|
| 论文里含难字的片段(313 段) | 基本区的生僻字 | 298 / 354 | 318 / 354 | 339 / 354 |
| | 扩展区的字 | 0 / 33 | 11 / 33 | 21 / 33 |
| 一本书的扫描页(93 行) | 扩展区的字 | 0 / 13 | 3 / 13 | 12 / 13 |
| 论文整行(398 行) | 基本区的生僻字 | 326 / 402 | 355 / 402 | 370 / 402 |
| | 扩展区的字 | 0 / 31 | 13 / 31 | 21 / 31 |
| 专项测试(300 行) | 基本区的生僻字 | 121 / 300 | 73 / 300 | 256 / 300 |
| | 扩展区的字 | 0 / 300 | 151 / 300 | 221 / 300 |
注:严格按写出的字符串算,OpenGlyph-OCR-IDS 在论文里含难字的片段的扩展区字为 19 / 33。
“基本区的生僻字”指基本区里分词器要拆成两三个记号的字;“扩展区的字”指扩展 A 至 J 区的字。专项测试是程序排印的 300 行:句子取自测试用的论文,每行嵌入一个基本区的生僻字、一个扩展区的字(各有一半取自这些论文,一半从全部生僻字里随机抽取)、两个 GlyphWiki 字形和一个只能写成 IDS 的字。
生僻字的提高,大多来自按部件再拼一遍:专项测试里,它读对的 256 个基本区生僻字里,232 个是拼成 IDS 读出来的(拼出的 IDS 画的正是这个字),扩展区的字也是如此(221 个里 186 个)。拼出的 IDS 若在 `canon.json` 里查得到有码位的字,输出时就换成那个字:论文片段里它写了 263 个 IDS,257 个这样换了回去。
### 写成 IDS 的字

| 专项测试里只能写成 IDS 的字 | 原版 | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|---|
| 两个部件(左右或上下) | 0 / 195 | 0 / 195 | 109 / 195(55.9%) |
| 包围结构 | 0 / 29 | 0 / 29 | 8 / 29(27.6%) |
| 三个部件 | 0 / 22 | 0 / 22 | 7 / 22(31.8%) |
| 嵌套(部件本身又是拼成的) | 0 / 54 | 0 / 54 | 2 / 54(3.7%) |
| 有部件在训练里一次也没出现过 | 0 / 52 | 0 / 52 | 18 / 52(34.6%) |
| **合计** | 0 / 300 | 0 / 300 | **126 / 300(42.0%)** |
写对的 126 个里,116 个与答案的 IDS 一字不差,10 个换了一种写法、画出来是同一个字(例如把上下两层再分上下,写成 ⿳)。
### 几行例子

### GlyphWiki 字形
| | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|
| 专项测试,600 个 GlyphWiki 字形 | 402 / 600 | 414 / 600 |
| 其中 ebag 系列 60 个 | 42 / 60 | 22 / 60 |
| 其中按 IDS 命名的 240 个 | 164 / 240 | 199 / 240 |
| 四页扫描,27 处 GlyphWiki 字形 | 16 / 27 | 14 / 27 |
### 读得快慢
在一台 24 GB 内存的 Apple 芯片 Mac 上(MLX):
| 每行用时(中位数) | 原版 | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|---|
| 论文的整行 | 0.5 秒 | 1.1 秒 | 2.0 秒 |
| 论文里含难字的片段 | 0.2 秒 | 0.4 秒 | 1.4 秒 |
| 扫描书页的一行 | 0.5 秒 | 1.0 秒 | 2.4 秒 |
| 专项测试的一行(每行五个难字) | 0.4 秒 | 0.4 秒 | 16.9 秒 |
慢在拼字:每个要问的地方,要把字切成部件读几遍,还要再拼一遍。生僻字越多越慢。读一行时内存最多占到约 5 GB。
## 毛病
- **嵌套的字差得多。** 部件本身又是拼成的字(嵌套),专项测试 54 个里只写对 2 个;包围结构 8 / 29,三个部件 7 / 22。
- **没见过的部件。** 有部件在训练里一次也没出现过的字,写对 18 / 52。
- **会把已有字形写成 IDS。** 有记号的 GlyphWiki 字形,它有时拼成 IDS 而拼错:专项测试里 ebag 系列的字形读对 22 / 60,OpenGlyph-OCR-0 是 42 / 60;四页扫描里的字形 14 / 27 对 16 / 27。
- **会在不该拼的地方拼。** 专项测试里,答案不是拼字的地方留下了 57 个 IDS。真实论文里,答案不是拼字、它却留下了 IDS 的地方:论文整行 398 行里 4 处,论文里含难字的片段 313 段里 3 处,一本书的扫描页 93 行里 3 处。
- **慢**,见上。
- 拼字只认 `⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻` 十二个结构符。
- 什么时候开 IDS、拼出的 IDS 采用与否,由几道门槛决定(`reading.json`)。门槛是在另一批调试用的行上选的,从没看过测试;换一类材料,最合适的门槛未必相同。
- 整页读只试过一页(见上文):整页读时用不上拼字,比切成行读多错几处。
## 它是怎么来的
读一行时,同一个模型里有四套权重:
1. **读字的**:OpenGlyph-OCR-0 原样(Xiaomi-OCR-0 加 LoRA、重新训练过的视觉塔末四层、159,052 个新增记号),写出整行。
2. **开口的**:在 OpenGlyph-OCR-0 上再加的 14 个记号(`<ids>`、`</ids>` 和十二个结构符)和语言层 18–23 的 LoRA(秩 8),沿着读字的写出的行看,说哪里该写 IDS、可能是什么结构。
3. **拆字读部件的**:照读字的那一刻注意力落在图上的位置找到这个字,用程序按几种结构切开,每个部件放大成一个字的大小,由另一套 LoRA(语言层 18–23,秩 8)当普通的字来读。
4. **拼字的**:照着图把整个字拼成 IDS,不切。语言层 18–23 的 LoRA(秩 64)、视觉塔全部十二层和合并层的 LoRA(秩 64)、结构符自己的输出行,再加上为部件的每一步另学的输出行,共约 3,485 万个权重。
两条路拼出同一个字,就采用;不同时,看拼字的有多大把握,按这处的类别(拼出的是有码位的字、有记号的字形,还是新的字形;读字的原来写的是生僻字、字形记号还是常用字)各有一道门槛;都不够,就留下读字的原来那个字。读字的自己写出生僻字或字形记号的地方,即使开口的没有说,也请拼字的拼一遍。
训练开口的那一套,用的是程序排印的拼字行,加上 OpenGlyph-OCR-0 训练时用过的几类行,以守住旧有的本事(其中 3,000 行是从 26 篇论文电子版裁出的真实行);拆字读部件的用同一批行,部件按排字程序的记录切开,另把行里一些有码位的字也切开来练习。拼字的只用程序排印的行:用部件拼出的字(含左右、上下、包围、三部件、嵌套)嵌在论文的句子里,GlyphWiki 上按 IDS 命名的字形,以及按部件拼写的生僻字,先后训练了七轮。测试用的四篇论文和那本书都不在任何一套的训练材料里;专项测试里那 300 个只能写成 IDS 的字,是在全部训练用的拼字之外另造的,也没有在训练行里出现过。本仓库不含任何训练或测试数据。
## 对 han2ids 的借鉴
[han2ids](https://github.com/mkpoli/han2ids)(mkpoli,MIT 许可,模型在 [Hugging Face](https://huggingface.co/mkpoli))是一个只读一个字的图、把它写成 IDS 的小模型:约 3,500 万个参数,ViT 编码器加四层解码器,在九万多个有码位的字的字图上训练,标签是 BabelStone 的 IDS。2026 年 11 月我们读过它的设计,也在我们的测试上试过它。借鉴的是这几点:
1. **部件要有自己的输出。** han2ids 给每个部件一个自己的记号;我们的模型写部件时用的是整字的输出行,不少部件要两三个记号才写得出来。我们因此给拼字的加了部件的输出行:为写部件的每一步另学一行,只在拼 IDS 时起作用(见上文“它是怎么来的”第 4 条)。
2. **可训练的分量。** han2ids 的全部权重都参与训练;我们当时的拼字只有约 260 万个 LoRA 权重。对比之后,拼字的 LoRA 秩从 8 提到了 64(约 2,080 万个权重)。
3. **怎样算写对。** han2ids 的评测把同一方向上的嵌套看作同一个结构(⿱⿱ABC 和 ⿳ABC 画出来相同);我们后来定下的计法——画出来是同一个字就算对——与此一致。
此外,我们拿它当过一回尺子:把我们测试里的拼字按框一个个切出来给它读(它只读单字,要先告诉它字在哪里),和我们的模型在整行里自己找字、自己拼相比。当时的一版拼字,部件都练过的 600 个字,han2ids 写对 238 个,我们 272 个;带有训练里从未出现的部件的 400 个字,han2ids 232 个,我们 132 个。在没见过的部件上差距很大,这也是本模型现在的毛病之一。
我们没有用它的代码、权重或数据,本仓库里没有 han2ids 的任何东西。两者设计上的根本不同在于:han2ids 读一个字,要给框;我们的模型读整行,自己决定哪里该写 IDS,其余照常写字。
## 仓库里有什么
| 文件 | 内容 |
|---|---|
| `base/` | Xiaomi-OCR-0 的六个文件,一字节未改 |
| `openglyph-ocr-0.safetensors`、`tokens.json` | 读字的:OpenGlyph-OCR-0 训练出来的全部数组和新增的 159,052 个记号(与 OpenGlyph-OCR-0 仓库里的同名文件相同) |
| `opener.safetensors` | 开口的:14 个新记号的输出行与偏置,语言层 18–23 的 LoRA |
| `part-reader.safetensors` | 拆字读部件的:语言层 18–23 的 LoRA |
| `speller.safetensors` | 拼字的:语言层与视觉塔的 LoRA、结构符的输出行、部件的输出行 |
| `ids-tables.json` | 14 个新记号,它们的输入行取自底模的哪些行,拼字的设定 |
| `canon.json` | 由 IDS 查有码位的字或 GlyphWiki 字形的表(196,911 条) |
| `token-counts.json` | 每个字要底模分词器的几个记号(据此分常用字与生僻字) |
| `reading.json` | 开口与采用的门槛(测量时所用的) |
| `openglyph_ocr_ids/` | 读一行的代码(MLX) |
| `figures/` | 本页的图(其中真实论文的截图出处见上文) |
| `requirements.txt` | 测量时所用的各库版本 |
另有 `release.json`,记着每个文件的 SHA-256 和来历。
## 许可与出处
本仓库按 Apache-2.0 发布。`base/` 是 Xiaomi-OCR-0,其作者以 Apache-2.0 发布,它又建立在 Qwen3.5-0.8B-Base 之上;这里原样转发,未作改动。`canon.json` 由几种 IDS 资料推出:CJKVI IDS(出自 CHISE IDS,按 CHISE 的条款,即 GPLv2)、BabelStone 的 IDS 表(作者声明可自由使用)和 GlyphWiki 的字形资料;这个文件按其来源的条款使用。字形名和用来排字的字形数据来自 GlyphWiki。本模型不是小米或 Xiaomi-OCR-0 作者的产品,也未经他们认可。详见 `NOTICE`。
---
## English summary
**What it is.** The next version of [OpenGlyph-OCR-0](https://huggingface.co/OpenGlyph/OpenGlyph-OCR-0), an OCR model for single lines of printed Chinese scholarly text dense with rare characters (Xiaomi-OCR-0, 0.8B, with LoRA, a retrained vision tail and 159,052 added output tokens). It adds two things. (1) A character that has neither a code point nor a GlyphWiki glyph is written as an Ideographic Description Sequence, `<ids>⿰…</ids>`. (2) Wherever the reader writes a rare character or a glyph token, the glyph is also spelt from its parts as an IDS; where that spelling is sure enough, the character it spells is written (an IDS that spells an encoded character becomes that character). On the 398 whole lines of four papers that gave no training line, lines read exactly right rise from 332 (OpenGlyph-OCR-0) to 347 and the character error rate falls from 0.90% to 0.70%; on 313 pieces of those papers' lines that hold hard characters (4 to 16 characters each), pieces read exactly right rise from 252 to 276 and the error rate falls from 2.89% to 1.88%.
**Whole pages.** A whole page can be read in one go (`read_page`, or `--page` on the command line), but line by line reads better. On the one page tried (a printed paper page, single column, 22 lines, 691 items), the page read whole had 8 items wrong (1.16%), the same page cut into its 22 lines 5 (0.72%). Read whole, the IDS routes are not used — they find a glyph by its place within one line — so a page read whole is read as OpenGlyph-OCR-0 reads it.
**How it reads a line.** Four sets of weights in one model: the reader (OpenGlyph-OCR-0, unchanged) writes the line; the opener (14 added tokens and rank-8 LoRA in language layers 18–23) says where an IDS is due; at such a place, and wherever the reader itself writes a rare character or a glyph token, the glyph is read two more ways — unfolded (located by the reader's attention, cut into parts by a program, the parts read by a rank-8 LoRA part reader) and spelt whole (the speller: rank-64 LoRA in language layers 18–23 and in all twelve vision blocks and the merger, its own structure-token rows and per-step part rows, about 34.8 million weights). An IDS both routes write alike stands; otherwise the speller's stands if it is sure enough by a gate set per kind of place; otherwise the reader's own character stands. The gates were chosen on tuning lines, never on a test. With `options=True` the reading also returns a second option at every place that has one (the reading not taken where the routes were asked; the reader's second choice where its lead is under 4 logits); the text is the same with and without.
**Measured** (November 2026, MLX form; "base" is Xiaomi-OCR-0 as released, with its own prompt; an IDS that draws exactly the answer's glyph counts as right — strict counts are given in the Chinese tables where they differ):
| | base | OpenGlyph-OCR-0 | OpenGlyph-OCR-IDS |
|---|---|---|---|
| 398 whole lines of four papers: lines exactly right | 272 | 332 | 347 |
| the same lines: character error rate | 3.71% | 0.90% | 0.70% |
| 313 pieces of lines with hard characters (4 to 16 characters) from the same papers: pieces exactly right | 225 | 252 | 276 |
| the same pieces: character error rate | 5.14% | 2.89% | 1.88% |
| 93 lines of four scanned book pages: lines exactly right | 54 | 69 | 75 |
| the same lines: character error rate | 2.20% | 1.12% | 0.83% |
| special test, 300 rare basic-block characters | 121 / 300 | 73 / 300 | 256 / 300 |
| special test, 300 extension characters | 0 / 300 | 151 / 300 | 221 / 300 |
| special test, 300 characters only an IDS can write | 0 / 300 | 0 / 300 | 126 / 300 |
**Known defects.** Nested composites are rarely right (2 of 54 on the special test), surrounds 8 of 29, three-part 7 of 22; composites with a part never seen in training 18 of 52. It sometimes spells a GlyphWiki glyph it has a token for as a wrong IDS (ebag-family glyphs 22 / 60 against OpenGlyph-OCR-0's 42 / 60; scanned-page glyphs 14 / 27 against 16 / 27), and leaves stray IDS where no composite is (57 on the special test; on the real sets 4 in the 398 whole lines of four papers, 3 in the 313 pieces of lines with hard characters, 3 in the 93 lines of four scanned book pages). It is several times slower than OpenGlyph-OCR-0. Only the MLX form exists (the reading runs four weight sets and cuts glyphs with a program; it was written and measured in MLX); OpenGlyph-OCR-0 alone has a `transformers` form.
**Real lines and their sources.** The card shows crops of real lines, each with its source: 何義軍《戰國陶文綜合研究》(Jilin University PhD thesis, 2023), 陈晶晶《清华简典型楚文字及相关问题研究》(Hebei University PhD thesis, 2025), 沈奇石《「隼」字異讀考論》(*臺大中文學報* 84, 2024, DOI 10.6281/NTUCL.202403_(84).0001), 鄔可晶《甲骨金文語文論稿》(Shanghai Guji, 2024). The fourth test paper, a 2025 thesis, is not named or shown: we do not know that it is public.
**What we took from han2ids.** [han2ids](https://github.com/mkpoli/han2ids) (MIT) reads ONE glyph picture into an IDS. From it we took the idea that parts need outputs of their own (hence the speller's part rows), the comparison of trainable size that made us raise the speller's LoRA rank from 8 to 64, and its convention that nesting along one axis is one structure (as our "same picture counts as right"). We also used it as a yardstick: given each composite's box, it wrote 238 of 600 test composites with practised parts against 272 for an earlier version of our speller reading whole lines, and 232 of 400 with parts never seen in training against our 132. No code, weights or data of han2ids are in this model or repository.
**Before release** the package in this repository was checked against the code that was measured: every array and table of the model it builds is bit for bit the measured one (1,330 entries), and 190 test lines read with it come out exactly as they were measured, every note of every place included (32 more with the second options); the page of the whole-page trial, read whole with it, comes out letter for letter as in the trial.
**Licence.** Apache-2.0. `base/` is Xiaomi-OCR-0, redistributed unchanged under its Apache-2.0 licence. `canon.json` is derived from CJKVI IDS (from CHISE IDS, under CHISE's terms, GPLv2), BabelStone's IDS table (free for any use) and GlyphWiki data, and is used under the terms of those sources. Not a product of Xiaomi or of the authors of Xiaomi-OCR-0, and not endorsed by them.
|