Views
No views yet
lm_head, embeddings, MoE routers, and the Mamba conv/dt paths are kept in BF16 to preserve accuracy-sensitive components.hf_quant_config.json, loadable by vLLM with --quantization modelopt.</think> and answers.1vllm serve stockmark/Stockmark-Nemotron-3-Nano-Omni-JapanDocReader-FP8 \
2 --served-model-name japandocreader-fp8 \
3 --host 0.0.0.0 --port 8000 \
4 --quantization modelopt \
5 --dtype auto \
6 --max-model-len 210000 \
7 --tensor-parallel-size 1 \
8 --trust-remote-code \
9 --reasoning-parser nemotron_v3 \
10 --allowed-local-media-path / \
11 --media-io-kwargs '{"video": {"fps": 2, "num_frames": 256}}' \
12 --video-pruning-rate 0.5Compared to the BF16 model, the only changes are--quantization modeloptand--dtype auto(the quantized dtype is picked up from the checkpoint'shf_quant_config.json).
| Parameter | Value | Note |
|---|---|---|
| temperature | 0.6 | official thinking-mode setting |
| top_p | 0.95 | official thinking-mode setting |
| repetition_penalty | 1.0 | recommended default (no penalty); keeps picture descriptions intact |
| reasoning_budget | 16384 | thinking token budget |
| max_tokens | 20480 | must be > reasoning_budget (leaves room for the answer) |
| max_model_len | 210000 | server-side |
max_tokens > reasoning_budgetis required: the budget caps the think block, and the remainingmax_tokens − reasoning_budgettokens hold the answer. Setting them equal starves the answer.
⚠️ Use this exact prompt. The model was trained with the fixed Japanese docparse prompt below. The prompt defines the task, the JSON schema, the allowedclassvalues, and the coordinate convention — the model's output format is conditioned on it. Do not paraphrase, translate, or reorder it; changing the prompt degrades layout accuracy and JSON validity. Keep it verbatim, including the trailingReturn ONLY the JSON objectinstruction.
1import base64, json, re, urllib.request
2
3PROMPT = """画像に含まれるドキュメントの構造をJSON形式で抽出してください。
4出力フォーマット:
5{
6 "document_structure": [
7 {
8 "class": "title" | "heading" | "text" | "table" | "list" | "picture" | "formula",
9 "bbox": [x1, y1, x2, y2],
10 "contents": "内容(pictureの場合は画像内容の説明、formulaの場合は数式のlatex表記)",
11 "caption": "pictureのキャプション文字(オプション)"
12 }
13 ]
14}
15classの種類: title(タイトル)、heading(見出し)、text(本文)、table(表)、list(リスト)、picture(画像)、formula(数式)
16bboxは左上(x1,y1)と右下(x2,y2)の座標です。bboxの座標系は0-1000の相対座標です。
17Return ONLY the JSON object. No markdown, no extra commentary."""
18
19def parse_document(image_path, base_url="http://127.0.0.1:8000"):
20 with open(image_path, "rb") as f:
21 b64 = base64.b64encode(f.read()).decode()
22 payload = {
23 "model": "japandocreader-fp8",
24 "messages": [{"role": "user", "content": [
25 {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
26 {"type": "text", "text": PROMPT},
27 ]}],
28 "temperature": 0.6, "top_p": 0.95,
29 "repetition_penalty": 1.0,
30 "max_tokens": 20480,
31 "chat_template_kwargs": {"enable_thinking": True, "reasoning_budget": 16384},
32 "thinking_token_budget": 17408, # reasoning_budget + grace
33 }
34 req = urllib.request.Request(
35 base_url.rstrip("/") + "/v1/chat/completions",
36 data=json.dumps(payload).encode(),
37 headers={"Content-Type": "application/json", "Authorization": "Bearer EMPTY"},
38 method="POST")
39 with urllib.request.urlopen(req, timeout=1800) as r:
40 msg = r.read(); msg = json.loads(msg)["choices"][0]["message"]
41 # thinking is split into reasoning_content; the answer is the JSON in `content`
42 answer = msg.get("content") or ""
43 m = re.search(r"\{.*\}", answer, re.DOTALL)
44 return json.loads(m.group(0) if m else answer) # -> {"document_structure": [...]}
45
46result = parse_document("document.png")
47print(json.dumps(result, ensure_ascii=False, indent=2))<think> and
answers in natural language:1payload["messages"] = [{"role": "user", "content": [
2 {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
3 {"type": "text", "text": "この文書について: <your question in Japanese>"},
4]}]
5# same sampling params as above; the answer is in message.content, the reasoning in reasoning_content1@misc{stockmark_japandocreader_fp8_2026,
2 title={Stockmark-Nemotron-3-Nano-Omni-JapanDocReader-FP8},
3 author={Stockmark Inc.},
4 year={2026}
5}