---
title: TongGuOCR
canonical_url: "https://www.modelscope.ai/models/jzzh2004/TongGuOCR"
md_url: "https://www.modelscope.ai/models/jzzh2004/TongGuOCR.md"
repository: jzzh2004/TongGuOCR
chinese_name: TongGuOCR
last_updated: 2026-11-02
license: apache-2.0
model_type:
  - glm_ocr
architectures:
  - GlmOcrForConditionalGeneration
base_model:
  - zai-org/GLM-OCR
base_model_relation: finetune
parameters: 1.2B
tensor_type:
  - F32
library_name:
  - safetensors
  - pytorch
frameworks:
  - Pytorch
language:
  - zh
downloads: 4
stars: 1
tags:
  - ocr
  - historical-documents
  - tongguocr
---

# TongGuOCR

> TongGuOCR - An open-source model by jzzh2004 on ModelScope. A Layout-Aware and Token-Augmented OCR MLLM for Chinese Historical Documents.

jzzh2004/TongGuOCR is a 1.2B-parameter machine learning model on ModelScope. licensed under apache-2.0. derived from zai-org/GLM-OCR.

- **Repository**: jzzh2004/TongGuOCR
- **License**: apache-2.0
- **Parameters**: 1.2B
- **Base model**: zai-org/GLM-OCR
- **Tags**: ocr, historical-documents, tongguocr
- **Downloads**: 4
- **Stars**: 1
- **Last updated**: 2026-11-02

Source: https://www.modelscope.ai/models/jzzh2004/TongGuOCR

---

# TongGuOCR

A Layout-Aware and Token-Augmented OCR MLLM for Chinese Historical Documents.

[Paper](https://arxiv.org/abs/2608.07917) |
[Code and installation](https://github.com/jzzh2004/TongGuOCR) |
[Project page](https://jzzh2004.github.io/TongGuOCR) |
[Online demo](https://guji-ocr.com) |
[Hugging Face](https://huggingface.co/jzzh2004/TongGuOCR) |
[ModelScope International](https://modelscope.ai/models/jzzh2004/TongGuOCR)

This repository contains the final inference OCR checkpoint,
its matching processor and tokenizer, and the text-line detection checkpoint.
The weights have been checked against the original release SHA-256 manifest.
It is hosted on [ModelScope International](https://modelscope.ai/models/jzzh2004/TongGuOCR).
TongGuOCR's own OCR adaptations, detection checkpoint and documentation use
Apache-2.0. Third-party
components retain their original licenses; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).

## Model

TongGuOCR combines layout-aware preprocessing with token-augmented recognition
for Chinese historical document pages with complex layouts, rare characters,
and nontrivial reading orders. The OCR architecture is
`GlmOcrForConditionalGeneration`, adapted from GLM-OCR with an expanded
84,083-token vocabulary. This is the final Stage 3 inference checkpoint,
not the historical Stage 1 or Stage 2 checkpoints.

## Files

| Path | Purpose |
| --- | --- |
| `model.safetensors` | Final OCR checkpoint, 4,733,086,904 bytes |
| `config.json`, `generation_config.json` | OCR model and generation configuration |
| `processor_config.json` | Image/text processor configuration |
| `tokenizer.json`, `tokenizer_config.json`, `chat_template.jinja` | Matching tokenizer and prompt template |
| `layout/finetune_infer.pth` | Text-line detection checkpoint, 122,471,457 bytes |
| `SHA256SUMS` | Checksums of the packaged files |

## Download and Run

Install the inference environment following the code repository's README.
Run the following inside the updated TongGuOCR code checkout. While a model
repository is private, set `MODELSCOPE_API_TOKEN` or `HF_TOKEN` to a token
with read access for the respective platform.

```bash
python -m pip install modelscope
bash tools/download_weights.sh modelscope
```

The ModelScope repository is hosted on `modelscope.ai`. Hugging Face is
also available:

```bash
bash tools/download_weights.sh huggingface
```

If Hugging Face is unreachable, use the ModelScope command above. Both paths
install OCR files in `weights/ocr/` and the detector checkpoint at
`weights/layout/finetune_infer.pth`.

```bash
python -m tongguocr -i /path/to/page.jpg -o output/ --print-result
```

The full pipeline uses the code repository's detector configuration, block
construction, crop refinement, and relation-token processing. Loading the OCR
checkpoint alone does not reproduce full-page pipeline results. The validated
default uses bf16, greedy decoding, at most 8,192 output tokens, and an image
budget of 1,048,576 pixels per recognition crop. See the code repository for
environment setup and the optional vLLM backend.

## Evaluation

Paper results:

| Dataset | AR | CR | NED | RO-ED x100 |
| --- | ---: | ---: | ---: | ---: |
| MTHv2 | 97.93 | 98.33 | 2.05 | 1.51 |
| M5HisDoc | 93.76 | 94.46 | 6.15 | 3.49 |

Fresh inference can differ slightly by backend and batch settings. The code
repository's `evaluation/README.md` records fresh results for both backends
and explains the metric protocol. Evaluation datasets are distributed by
their respective owners and are not included here.

## License and Attribution

TongGuOCR's own OCR adaptations, detection checkpoint and documentation are provided under
[Apache-2.0](LICENSE), as selected by the model owner. The upstream GLM-OCR
model retains MIT terms; see the
[GLM-OCR license and recorded source](THIRD_PARTY_LICENSES/GLM-OCR-MIT.md).

The HDC text-line detection checkpoint at `layout/finetune_infer.pth` is
distributed under Apache-2.0 as selected by the model owner. This grant covers
rights controlled by the TongGuOCR contributors; applicable third-party terms
remain in force. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).

## Citation

```bibtex
@article{zhou2026tongguocr,
  title = {TongGuOCR: A Layout-Aware and Token-Augmented OCR MLLM for Chinese Historical Documents},
  author = {Zhou, Zhongheng and Sun, Yi and He, Huiguo and Zhang, Yuyi and Zhang, Peirong and Fang, Yulin and Peng, Dezhi and Liao, Minghui and Jin, Lianwen},
  journal = {arXiv preprint arXiv:2608.07917},
  year = {2026}
}
```
