> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sglang.io/llms.txt
> Use this file to discover all available pages before exploring further.

# NVIDIA Nemotron 3.5 Parse

> Parse document images into text, layout blocks, tables, and bounding boxes with SGLang.

## Overview

[Nemotron 3.5 Parse](https://huggingface.co/nvidia/Nemotron-3.5-Parse) extracts text and document structure from page images. This recipe sends one page through the chat API, then converts the output into Markdown and JSON blocks with the checkpoint's postprocessing helpers.

## Installation

Install SGLang on an NVIDIA CUDA system using the [installation guide](https://docs.sglang.io/docs/get-started/install.md). The BF16 checkpoint has been tested on A100, H100, and B200 GPUs.

Install the dependencies for the client and postprocessing examples:

```bash theme={null}
pip install requests Pillow huggingface_hub beautifulsoup4 numpy
```

## Start the server

```bash theme={null}
sglang serve \
  --model-path nvidia/Nemotron-3.5-Parse \
  --trust-remote-code
```

The checkpoint's configuration and image processor require `--trust-remote-code`. SGLang loads the Parse chat template automatically. The server uses the checkpoint's 16,384-token context limit, including image tokens, the task prompt, and generated output.

On A100, you can add `--mm-attention-backend sdpa`; it avoided two-column omissions on the tested reference pages. Some A100 and H100 outputs can differ in formatting or reading order, or omit a line. No reliable H100 workaround has been confirmed.

## Parse a page

Save an RGB page image as `page.png`. For a small example, you can create one with Pillow's built-in font:

```python theme={null}
from PIL import Image, ImageDraw, ImageFont

page = Image.new("RGB", (850, 1050), "white")
ImageDraw.Draw(page).multiline_text(
    (50, 50),
    "Paris Travel Guide\n\nParis is the capital of France.",
    font=ImageFont.load_default(size=32),
    fill="black",
    spacing=16,
)
page.save("page.png")
```

Send the page to the server's default address:

```python theme={null}
import base64
from pathlib import Path

import requests

prompt = "</s><s><predict_bbox><predict_classes><output_markdown><predict_text_in_pic>"
image = base64.b64encode(Path("page.png").read_bytes()).decode()
response = requests.post(
    "http://127.0.0.1:30000/v1/chat/completions",
    json={
        "model": "nvidia/Nemotron-3.5-Parse",
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": prompt},
                    {
                        "type": "image_url",
                        "image_url": {"url": "data:image/png;base64," + image},
                    },
                ],
            }
        ],
        "temperature": 0,
        "max_tokens": 8744,
        "repetition_penalty": 1.1,
        "skip_special_tokens": False,
    },
    timeout=300,
)
response.raise_for_status()
result = response.json()["choices"][0]
Path("page.raw.txt").write_text(result["message"]["content"], encoding="utf-8")
print(result["message"]["content"])
print("Finish reason:", result["finish_reason"])
```

For the sample page, the output should contain its title and the sentence about Paris, along with coordinate and class tokens. Keep `skip_special_tokens` set to `False`: those tokens carry the document structure used below. A `finish_reason` of `length` means the output hit `max_tokens`; allow more output tokens if the remaining context permits.

Use the task prompt as written, rather than a general chat instruction such as "describe this image." To parse a PDF, render its pages as images and send one page per request.

## Export Markdown and structured blocks

The postprocessing code runs on the client. Download just those helpers, without downloading the model weights again:

```python theme={null}
import json
import sys
from pathlib import Path

from huggingface_hub import snapshot_download
from PIL import Image

helpers = snapshot_download(
    "nvidia/Nemotron-3.5-Parse", allow_patterns=["nemotron_parse/**"]
)
sys.path.insert(0, helpers)
from nemotron_parse import postprocess_document

with Image.open("page.png") as image:
    document = postprocess_document(
        Path("page.raw.txt").read_text(encoding="utf-8"), image_size=image.size
    )
Path("page.md").write_text(document["markdown"], encoding="utf-8")
Path("page.json").write_text(json.dumps(document, indent=2), encoding="utf-8")
print(document["markdown"])
print(document["blocks"])
```

`page.md` contains the rendered document, including HTML tables when needed to preserve merged cells. Each block in `page.json` includes its class, normalized bounding box, pixel bounding box, and text, in model reading order. For the sample, both the title and sentence should appear in the rendered document.

## Supported inputs and limits

* Send one document image per request. PDF rendering and combining results across pages happen on the client.
* The prompt above performs a single full-page parse. See the [model card](https://huggingface.co/nvidia/Nemotron-3.5-Parse#task-prompts) for other task prompts.
* Vision CUDA graphs (`SGLANG_VIT_ENABLE_CUDA_GRAPH=1`) are not supported because they do not preserve page boundaries. Default decoder CUDA graphs remain supported.
* MTP, DFlash2 speculative decoding, and pipeline parallelism are not supported by this integration.

You can also send the task prompt and image through [SGLang's native API](https://docs.sglang.io/docs/basic_usage/send_request.md#using-native-generation-apis). See [multimodal models](https://docs.sglang.io/docs/supported-models/multimodal_language_models.md) for a `/generate` example.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.