--- library_name: transformers pipeline_tag: image-text-to-text base_model: - ibm-granite/granite-docling-v2-2b --- This is a randomly initialized tiny model based on [ibm-granite/granite-docling-v2-2b](https://huggingface.co/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 `` 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. ```python 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": ""}]}] 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="", 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 - Code: [.meta/create_model.py](.meta/create_model.py) - Model structure: [.meta/model.log](.meta/model.log) - Environment: [.meta/env.json](.meta/env.json) ### Change log - 2026-12-01: Initial tiny Granite-Docling v2 checkpoint. *This repo is generated by DeepSeek-V4.1-Flash.*