benbaker76 commited on
Commit
7ec82be
·
verified ·
1 Parent(s): e4f6fbc

Describe the 4-bit model

Browse files
Files changed (1) hide show
  1. README.md +14 -8
README.md CHANGED
@@ -12,9 +12,9 @@ base_model:
12
  - Helsinki-NLP/opus-mt-es-en
13
  ---
14
 
15
- # pdftool models
16
 
17
- ONNX exports of the models used by pdftool, a C++ command-line
18
  tool that converts PDFs to Markdown and translates PDFs in place. They run on ONNX Runtime with no
19
  Python involved.
20
 
@@ -23,17 +23,18 @@ weights and stays under the original author's licence.
23
 
24
  | Folder | Size | Use | Original weights | Licence |
25
  | --- | --- | --- | --- | --- |
26
- | `deepseek-ocr2-fp16/` | 6.6 GB | PDF to Markdown, GPU | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
27
- | `deepseek-ocr2-fp32/` | 13 GB | PDF to Markdown, CPU | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
 
28
  | `opus-mt-es-en/` | 0.6 GB | Spanish to English translation | [Helsinki-NLP/opus-mt-es-en](https://huggingface.co/Helsinki-NLP/opus-mt-es-en) | Apache-2.0 |
29
 
30
  Each folder is self-contained. Download the whole folder and keep the file names: an `.onnx` file
31
  loads its weights from the `.onnx.data` file beside it.
32
 
33
  ```sh
34
- hf download baker76/pdftool-models --include "deepseek-ocr2-fp16/*" --local-dir models
35
- pdftool convert in.pdf -o out.md --model models/deepseek-ocr2-fp16
36
- pdftool translate in.pdf -o out.pdf --model models/opus-mt-es-en
37
  ```
38
 
39
  ## DeepSeek-OCR-2
@@ -48,9 +49,14 @@ pdftool translate in.pdf -o out.pdf --model models/opus-mt-es-en
48
  On one test page the fp32 export reproduced the PyTorch model's output token for token; the fp16
49
  export produced the same text with two bounding-box coordinates differing by 1.
50
 
 
 
 
 
 
51
  ## OPUS-MT
52
 
53
  `encoder.onnx` and `decoder.onnx` (no cache; the decoder is re-run each step), with the original
54
  `source.spm`, `target.spm` and `vocab.json`. Logits match PyTorch to within 1e-5.
55
 
56
- The scripts that produced these files are in the pdftool repository under `tools/export/`.
 
12
  - Helsinki-NLP/opus-mt-es-en
13
  ---
14
 
15
+ # ocrtool models
16
 
17
+ ONNX exports of the models used by ocrtool, a C++ command-line
18
  tool that converts PDFs to Markdown and translates PDFs in place. They run on ONNX Runtime with no
19
  Python involved.
20
 
 
23
 
24
  | Folder | Size | Use | Original weights | Licence |
25
  | --- | --- | --- | --- | --- |
26
+ | `deepseek-ocr2-int4/` | 2.9 GB | PDF to Markdown, CPU or GPU (recommended download) | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
27
+ | `deepseek-ocr2-fp16/` | 6.6 GB | PDF to Markdown, GPU, fastest | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
28
+ | `deepseek-ocr2-fp32/` | 13 GB | Full precision; the source for quantizing | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
29
  | `opus-mt-es-en/` | 0.6 GB | Spanish to English translation | [Helsinki-NLP/opus-mt-es-en](https://huggingface.co/Helsinki-NLP/opus-mt-es-en) | Apache-2.0 |
30
 
31
  Each folder is self-contained. Download the whole folder and keep the file names: an `.onnx` file
32
  loads its weights from the `.onnx.data` file beside it.
33
 
34
  ```sh
35
+ hf download baker76/pdftool-models --include "deepseek-ocr2-int4/*" --local-dir models
36
+ ocrtool convert in.pdf -o out.md --model models/deepseek-ocr2-int4
37
+ ocrtool translate in.pdf -o out.pdf --model models/opus-mt-es-en
38
  ```
39
 
40
  ## DeepSeek-OCR-2
 
49
  On one test page the fp32 export reproduced the PyTorch model's output token for token; the fp16
50
  export produced the same text with two bounding-box coordinates differing by 1.
51
 
52
+ `deepseek-ocr2-int4` is the fp32 export with the decoder's weights stored in 4 bits and the vision
53
+ encoder's in 8 (ONNX Runtime `MatMulNBits`); the two SAM graphs are unchanged. On four test pages its
54
+ text matched the fp16 model's apart from a few formatting differences. It decodes more slowly than
55
+ fp16 on a GPU (about 50 against 80 tokens per second on an RTX 4090).
56
+
57
  ## OPUS-MT
58
 
59
  `encoder.onnx` and `decoder.onnx` (no cache; the decoder is re-run each step), with the original
60
  `source.spm`, `target.spm` and `vocab.json`. Logits match PyTorch to within 1e-5.
61
 
62
+ The scripts that produced these files are in the ocrtool repository under `tools/export/`.