Image-Text-to-Text
Transformers
Safetensors
granite_docling
granite
docling
doclang
ocr
document-parsing
document-conversion
layout-analysis
table-recognition
formula-recognition
vllm
autoround
w4a16
gptq
compressed-tensors
quantized
conversational
Instructions to use Vishva007/granite-docling-v2-2b-LLM-Compressor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vishva007/granite-docling-v2-2b-LLM-Compressor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Vishva007/granite-docling-v2-2b-LLM-Compressor") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Vishva007/granite-docling-v2-2b-LLM-Compressor") model = AutoModelForMultimodalLM.from_pretrained("Vishva007/granite-docling-v2-2b-LLM-Compressor", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vishva007/granite-docling-v2-2b-LLM-Compressor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Vishva007/granite-docling-v2-2b-LLM-Compressor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vishva007/granite-docling-v2-2b-LLM-Compressor", "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
docker model run hf.co/Vishva007/granite-docling-v2-2b-LLM-Compressor
- SGLang
How to use Vishva007/granite-docling-v2-2b-LLM-Compressor with 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 "Vishva007/granite-docling-v2-2b-LLM-Compressor" \ --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": "Vishva007/granite-docling-v2-2b-LLM-Compressor", "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 "Vishva007/granite-docling-v2-2b-LLM-Compressor" \ --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": "Vishva007/granite-docling-v2-2b-LLM-Compressor", "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" } } ] } ] }' - Docker Model Runner
How to use Vishva007/granite-docling-v2-2b-LLM-Compressor with Docker Model Runner:
docker model run hf.co/Vishva007/granite-docling-v2-2b-LLM-Compressor
Download processor_config.json from Vishva007/granite-docling-v2-2b-LLM-Compressor: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/Vishva007/granite-docling-v2-2b-LLM-Compressor/resolve/main/processor_config.json
- Command line
-
hf download hf://Vishva007/granite-docling-v2-2b-LLM-Compressor/processor_config.json
-
curl -L -o processor_config.json https://huggingface.co/Vishva007/granite-docling-v2-2b-LLM-Compressor/resolve/main/processor_config.json
789 Bytes
| { | |
| "image_processor": { | |
| "crop_to_patches": true, | |
| "dense_max_aspect": 2.5, | |
| "dense_max_patches": 54, | |
| "dense_max_scale": 0.75, | |
| "dense_min_aspect": 0.0, | |
| "do_convert_rgb": true, | |
| "do_normalize": true, | |
| "do_rescale": true, | |
| "do_resize": true, | |
| "fine_route": false, | |
| "image_mean": [ | |
| 0.48145466, | |
| 0.4578275, | |
| 0.40821073 | |
| ], | |
| "image_processor_type": "GraniteDoclingImageProcessor", | |
| "image_std": [ | |
| 0.26862954, | |
| 0.26130258, | |
| 0.27577711 | |
| ], | |
| "max_patches": 32, | |
| "max_tiles_per_side": 16, | |
| "min_patches": 1, | |
| "resample": 3, | |
| "rescale_factor": 0.00392156862745098, | |
| "size": { | |
| "height": 512, | |
| "width": 512 | |
| } | |
| }, | |
| "image_seq_len": 256, | |
| "processor_class": "GraniteDoclingProcessor" | |
| } | |