soamikapadia commited on
Commit
c0ad7ce
·
verified ·
1 Parent(s): b58d44a

Trim model card

Browse files
Files changed (1) hide show
  1. README.md +6 -42
README.md CHANGED
@@ -22,10 +22,6 @@ content, a key-value panel, or a whole table) with a bounding box and its
22
  transcribed text. Tables are transcribed as GitHub-Flavored Markdown inside a
23
  single block. Figures, photos, and signatures are returned as image blocks.
24
 
25
- It was the production parsing model behind the Hanji document-extraction API.
26
- The accompanying open-source parse + schema-extraction server is available at
27
- **https://github.com/youlearn-ai/hanji**.
28
-
29
  ## Output contract
30
 
31
  The model returns **JSON only**: an array of records
@@ -48,10 +44,6 @@ The model returns **JSON only**: an array of records
48
 
49
  ## Usage — read this before running the model
50
 
51
- The model is **tightly coupled to its serving contract**. It was trained and
52
- served with one exact prompt, one image-preprocessing rule, and greedy
53
- decoding. Deviating from any of these produces off-distribution output.
54
-
55
  ### 1. Image preprocessing
56
 
57
  - Downscale so the image is at most **2,000,000 pixels** (2 MP), preserving
@@ -72,7 +64,7 @@ def preprocess(img: Image.Image) -> Image.Image:
72
  return img.convert("RGB").resize((w, h), Image.LANCZOS)
73
  ```
74
 
75
- ### 2. The prompt (use it verbatim)
76
 
77
  Send the page image followed by exactly this text as the user turn. Do not
78
  paraphrase, extend, or reformat it.
@@ -202,7 +194,7 @@ model = AutoModelForImageTextToText.from_pretrained(
202
  processor = AutoProcessor.from_pretrained(MODEL)
203
 
204
  image = preprocess(Image.open("page.png")) # see preprocessing above
205
- PROMPT = "..." # the exact prompt above, verbatim
206
 
207
  messages = [{
208
  "role": "user",
@@ -220,11 +212,10 @@ out = model.generate(**inputs, max_new_tokens=8192, do_sample=False)
220
  print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
221
  ```
222
 
223
- ### Serving (SGLang — the production configuration)
224
 
225
- The model was served with SGLang `v0.5.12.post1` on a single H100. N-gram
226
- speculative decoding gives a large decode speedup on this output format (the
227
- repeated JSON keys draft extremely well):
228
 
229
  ```bash
230
  python -m sglang.launch_server \
@@ -241,36 +232,9 @@ python -m sglang.launch_server \
241
  ```
242
 
243
  A ready-to-run server that implements the full preprocessing + prompt contract
244
- (and a Baseten deployment config) ships with the open-source repo:
245
  https://github.com/youlearn-ai/hanji.
246
 
247
- ## Training summary
248
-
249
- - Base: `Qwen/Qwen3-VL-4B-Instruct` (Apache-2.0). Language layers fine-tuned
250
- with LoRA (r=32, α=64, all attention + MLP projections); the **vision tower
251
- was frozen**. This repository contains the merged full weights (bf16).
252
- - 1,500 steps, effective batch 16, cosine schedule, images at up to 2 MP
253
- native resolution.
254
- - ~16k supervised pages spanning synthetic and real business documents:
255
- forms, tables (including borderless and dense grids), checkbox and Y/N
256
- grids, multilingual and RTL pages, degraded scans and faxes, receipts, and
257
- court transcripts.
258
-
259
- ## Limitations
260
-
261
- - **Prompt-coupled**: output quality degrades sharply off the exact prompt,
262
- preprocessing, and greedy decoding described above.
263
- - The base model was loaded from the `main` revision of
264
- `Qwen/Qwen3-VL-4B-Instruct` at training time (mid-2026) without a pinned
265
- commit; bit-exact re-derivation of the merge is therefore approximate.
266
- - Signatures and handwritten marks are deliberately returned as `<image>`
267
- blocks, never transcribed.
268
- - Blocks are page-scoped; the model does not merge tables that continue
269
- across pages (the serving pipeline may do so downstream).
270
- - Not an instruction-following chat model: it does one task. For arbitrary
271
- document Q&A, pair it with a downstream LLM (the open-source repo pairs it
272
- with a schema-extraction pass).
273
-
274
  ## License
275
 
276
  Apache-2.0. Fine-tuned from
 
22
  transcribed text. Tables are transcribed as GitHub-Flavored Markdown inside a
23
  single block. Figures, photos, and signatures are returned as image blocks.
24
 
 
 
 
 
25
  ## Output contract
26
 
27
  The model returns **JSON only**: an array of records
 
44
 
45
  ## Usage — read this before running the model
46
 
 
 
 
 
47
  ### 1. Image preprocessing
48
 
49
  - Downscale so the image is at most **2,000,000 pixels** (2 MP), preserving
 
64
  return img.convert("RGB").resize((w, h), Image.LANCZOS)
65
  ```
66
 
67
+ ### 2. The prompt
68
 
69
  Send the page image followed by exactly this text as the user turn. Do not
70
  paraphrase, extend, or reformat it.
 
194
  processor = AutoProcessor.from_pretrained(MODEL)
195
 
196
  image = preprocess(Image.open("page.png")) # see preprocessing above
197
+ PROMPT = "..." # the exact prompt above
198
 
199
  messages = [{
200
  "role": "user",
 
212
  print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
213
  ```
214
 
215
+ ### Serving (SGLang)
216
 
217
+ N-gram speculative decoding gives a large decode speedup on this output
218
+ format (the repeated JSON keys draft extremely well):
 
219
 
220
  ```bash
221
  python -m sglang.launch_server \
 
232
  ```
233
 
234
  A ready-to-run server that implements the full preprocessing + prompt contract
235
+ (and a schema-extraction API around it) is available at
236
  https://github.com/youlearn-ai/hanji.
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  ## License
239
 
240
  Apache-2.0. Fine-tuned from