How to use from
SGLang
Install from pip and serve model
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
    --model-path "tiny-random/granite-docling-v2" \
    --host 0.0.0.0 \
    --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "tiny-random/granite-docling-v2",
		"messages": [
			{
				"role": "user",
				"content": [
					{
						"type": "text",
						"text": "Describe this image in one sentence."
					},
					{
						"type": "image_url",
						"image_url": {
							"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
						}
					}
				]
			}
		]
	}'
Use Docker images
docker run --gpus all \
    --shm-size 32g \
    -p 30000:30000 \
    -v ~/.cache/huggingface:/root/.cache/huggingface \
    --env "HF_TOKEN=<secret>" \
    --ipc=host \
    lmsysorg/sglang:latest \
    python3 -m sglang.launch_server \
        --model-path "tiny-random/granite-docling-v2" \
        --host 0.0.0.0 \
        --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "tiny-random/granite-docling-v2",
		"messages": [
			{
				"role": "user",
				"content": [
					{
						"type": "text",
						"text": "Describe this image in one sentence."
					},
					{
						"type": "image_url",
						"image_url": {
							"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
						}
					}
				]
			}
		]
	}'
Quick Links

This is a randomly initialized tiny model based on ibm-granite/granite-docling-v2-2b for testing and debugging.

Feature Source This repo
Checkpoint tensor elements 2.68B BF16 9.15M BF16
Safetensors weight files 5.37 GB (model.safetensors) 18.32 MB (model.safetensors)
Vocabulary rows 133,800 Same
Text layers 24 4
Text width / heads / KV heads / head dim 2,048 / 16 / 4 / 128 64 / 4 / 1 / 16
Text intermediate width 8,192 256
Positional context / RoPE theta 131,072 / 1e7 Same
Granite multipliers (embed / residual / attention / logits) 12 / 0.22 / 1/128 / 8 Same
Vision layers / width / heads 27 / 1,152 / 16 3 / 64 / 2
Vision intermediate width 4,304 256
Tile size / patch size / pixel shuffle 512 / 16 / 2 Same
Image tokens per tile (coarse path) 256 Same
DeepStack taps [8, 16, 24] (3 x 9-layer stacks) [0, 1, 2] (3 x 1-layer stacks)
Fine connector path / density router absent / absent Same
MTP heads 3 mtp.* layers, ignored by Transformers Not serialized
Serialized precision BF16 Same
File path Size
model.safetensors 18.3MB

Example usage

Transformers (โœ… verified)

Requires transformers>=5.23. The snippet feeds one 512x512 page tile; the processor expands <image> to 256 image tokens per tile and the connector adds three DeepStack feature taps to the decoder. The model is random-initialized, so the generated markup is not meaningful.

def run_model(model_id: str) -> None:
    import torch
    from PIL import Image, ImageDraw
    from transformers import AutoModelForImageTextToText, AutoProcessor

    model_id = str(model_id)
    processor = AutoProcessor.from_pretrained(model_id)
    model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16).to("cuda").eval()

    image = Image.new("RGB", (512, 512), "white")
    draw = ImageDraw.Draw(image)
    draw.rectangle((40, 40, 472, 90), outline="black", width=3)
    for row in range(5):
        draw.rectangle((40, 130 + row * 60, 432, 142 + row * 60), fill="black")

    messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "<doclang>"}]}]
    prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
    inputs = processor(text=prompt, images=image, return_tensors="pt").to(model.device)
    print("prompt tokens:", tuple(inputs["input_ids"].shape))
    print(
        "tiles:",
        tuple(inputs["pixel_values"].shape),
        "image tokens:",
        int((inputs["input_ids"] == model.config.image_token_id).sum()),
    )

    with torch.inference_mode():
        logits = model(**inputs).logits
        generated = model.generate(**inputs, max_new_tokens=64, do_sample=False)
    print("logits:", tuple(logits.shape), logits.dtype, float(logits.float().abs().max()))
    print(processor.decode(generated[0, inputs["input_ids"].shape[1] :], skip_special_tokens=False))

    text_ids = processor(text="<doclang>", return_tensors="pt").to(model.device)
    with torch.inference_mode():
        text_logits = model(**text_ids).logits
    print("text-only logits:", tuple(text_logits.shape), float(text_logits.float().abs().max()))


if __name__ == "__main__":
    run_model(model_id="tiny-random/granite-docling-v2")

Creating this repo

Change log

  • 2026-12-01: Initial tiny Granite-Docling v2 checkpoint.

This repo is generated by DeepSeek-V4.1-Flash.

Downloads last month
19
Safetensors
Model size
9.15M params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for tiny-random/granite-docling-v2

Collection including tiny-random/granite-docling-v2