Theaonzarbd commited on
Commit
e1cd858
·
verified ·
1 Parent(s): e5b6964

Add recommended generation parameters and official prompt to model card

Browse files
Files changed (1) hide show
  1. README.md +43 -4
README.md CHANGED
@@ -25,6 +25,31 @@ This model was converted to MLX format from [`typhoon-ai/typhoon-ocr1.5-2b`](htt
25
 
26
  This checkpoint is quantized to **8-bit** (group size 64, affine mode), ~9.94 bits per weight. The vision encoder is kept at higher precision, so OCR accuracy is preserved while roughly halving the size (~2.5 GB). Designed for Apple Silicon.
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ## Usage
29
 
30
  ```bash
@@ -34,12 +59,26 @@ pip install -U mlx-vlm
34
  ```bash
35
  python -m mlx_vlm.generate \
36
  --model mlx-community/typhoon-ocr1.5-2b-8bit \
37
- --image path/to/page.jpg \
38
- --prompt "Extract all text from the image. Only return clean Markdown." \
39
- --max-tokens 1024 \
40
- --temperature 0.0
 
41
  ```
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ## Conversion
44
 
45
  ```bash
 
25
 
26
  This checkpoint is quantized to **8-bit** (group size 64, affine mode), ~9.94 bits per weight. The vision encoder is kept at higher precision, so OCR accuracy is preserved while roughly halving the size (~2.5 GB). Designed for Apple Silicon.
27
 
28
+ ## Prompt
29
+
30
+ Typhoon OCR is instruction-tuned and works best **only** with its official prompt. Use it verbatim (e.g. saved to `prompt.txt`):
31
+
32
+ ```text
33
+ Extract all text from the image.
34
+
35
+ Instructions:
36
+ - Only return the clean Markdown.
37
+ - Do not include any explanation or extra text.
38
+ - You must include all information on the page.
39
+
40
+ Formatting Rules:
41
+ - Tables: Render tables using <table>...</table> in clean HTML format.
42
+ - Equations: Render equations using LaTeX syntax with inline ($...$) and block ($$...$$).
43
+ - Images/Charts/Diagrams: Wrap any clearly defined visual areas (e.g. charts, diagrams, pictures) in:
44
+
45
+ <figure>
46
+ Describe the image's main elements (people, objects, text), note any contextual clues (place, event, culture), mention visible text and its meaning, provide deeper analysis when relevant (especially for financial charts, graphs, or documents), comment on style or architecture if relevant, then give a concise overall summary. Describe in Thai.
47
+ </figure>
48
+
49
+ - Page Numbers: Wrap page numbers in <page_number>...</page_number> (e.g., <page_number>14</page_number>).
50
+ - Checkboxes: Use the unchecked / checked box characters as appropriate.
51
+ ```
52
+
53
  ## Usage
54
 
55
  ```bash
 
59
  ```bash
60
  python -m mlx_vlm.generate \
61
  --model mlx-community/typhoon-ocr1.5-2b-8bit \
62
+ --image page.jpg \
63
+ --prompt "$(cat prompt.txt)" \
64
+ --max-tokens 4096 \
65
+ --temperature 0.0 \
66
+ --repetition-penalty 1.1
67
  ```
68
 
69
+ ## Recommended generation parameters
70
+
71
+ Typhoon OCR is a document-extraction model, not a chat model. It needs near-deterministic decoding so it does not hallucinate characters or loop on repeated table cells.
72
+
73
+ | Parameter | Recommended | Notes |
74
+ |---|---|---|
75
+ | `temperature` | `0.0` (greedy) | Deterministic extraction — always picks the most-confident token. SCB10X also publishes `0.1` as an alternative. |
76
+ | `repetition_penalty` | `1.1` | Stops the model looping on repeated dashes / blank cells in dense tables. Exposed as `--repetition-penalty`. |
77
+ | `max_tokens` | `4096` | Headroom for a full, dense page. |
78
+ | `top_p` | `0.6` | Only has an effect when `temperature > 0` (e.g. `0.1`). **Not** exposed by the `mlx_vlm.generate` CLI — set it via the Python sampler or the `mlx_vlm.server` request body if you raise the temperature. |
79
+
80
+ Image resolution: the Qwen3-VL processor handles dynamic resolution automatically. For dense A4 pages, feed a reasonably high-resolution scan (long side ~1500-2000 px) to keep small text sharp; on 16 GB Apple Silicon, avoid extremely large images to prevent out-of-memory. Keep the KV cache unquantized (the default).
81
+
82
  ## Conversion
83
 
84
  ```bash