Image-Text-to-Text
Transformers
Safetensors
Portuguese
qwen2_5_vl
ocr
document-understanding
structured-extraction
specialized-small-language-model
brazilian-portuguese
conversational
text-generation-inference
compressed-tensors
Instructions to use Dharma-AI/Dharma-OCR-LITE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Dharma-AI/Dharma-OCR-LITE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Dharma-AI/Dharma-OCR-LITE") 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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Dharma-AI/Dharma-OCR-LITE") model = AutoModelForImageTextToText.from_pretrained("Dharma-AI/Dharma-OCR-LITE") 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Dharma-AI/Dharma-OCR-LITE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Dharma-AI/Dharma-OCR-LITE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dharma-AI/Dharma-OCR-LITE", "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/Dharma-AI/Dharma-OCR-LITE
- SGLang
How to use Dharma-AI/Dharma-OCR-LITE 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 "Dharma-AI/Dharma-OCR-LITE" \ --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": "Dharma-AI/Dharma-OCR-LITE", "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 "Dharma-AI/Dharma-OCR-LITE" \ --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": "Dharma-AI/Dharma-OCR-LITE", "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 Dharma-AI/Dharma-OCR-LITE with Docker Model Runner:
docker model run hf.co/Dharma-AI/Dharma-OCR-LITE
| { | |
| "architectures": [ | |
| "Qwen2_5_VLForConditionalGeneration" | |
| ], | |
| "attention_dropout": 0.0, | |
| "bos_token_id": 151643, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 151645, | |
| "hidden_act": "silu", | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 11008, | |
| "max_position_embeddings": 128000, | |
| "max_window_layers": 70, | |
| "model_type": "qwen2_5_vl", | |
| "num_attention_heads": 16, | |
| "num_hidden_layers": 36, | |
| "num_key_value_heads": 2, | |
| "quantization_config": { | |
| "config_groups": { | |
| "group_0": { | |
| "format": "float-quantized", | |
| "input_activations": { | |
| "actorder": null, | |
| "block_structure": null, | |
| "dynamic": false, | |
| "group_size": null, | |
| "num_bits": 8, | |
| "observer": "minmax", | |
| "observer_kwargs": {}, | |
| "strategy": "tensor", | |
| "symmetric": true, | |
| "type": "float" | |
| }, | |
| "output_activations": null, | |
| "targets": [ | |
| "Linear" | |
| ], | |
| "weights": { | |
| "actorder": null, | |
| "block_structure": null, | |
| "dynamic": false, | |
| "group_size": null, | |
| "num_bits": 8, | |
| "observer": "minmax", | |
| "observer_kwargs": {}, | |
| "strategy": "tensor", | |
| "symmetric": true, | |
| "type": "float" | |
| } | |
| } | |
| }, | |
| "format": "float-quantized", | |
| "global_compression_ratio": null, | |
| "ignore": [ | |
| "model.visual.blocks.0.attn.qkv", | |
| "model.visual.blocks.0.attn.proj", | |
| "model.visual.blocks.0.mlp.gate_proj", | |
| "model.visual.blocks.0.mlp.up_proj", | |
| "model.visual.blocks.0.mlp.down_proj", | |
| "model.visual.blocks.1.attn.qkv", | |
| "model.visual.blocks.1.attn.proj", | |
| "model.visual.blocks.1.mlp.gate_proj", | |
| "model.visual.blocks.1.mlp.up_proj", | |
| "model.visual.blocks.1.mlp.down_proj", | |
| "model.visual.blocks.2.attn.qkv", | |
| "model.visual.blocks.2.attn.proj", | |
| "model.visual.blocks.2.mlp.gate_proj", | |
| "model.visual.blocks.2.mlp.up_proj", | |
| "model.visual.blocks.2.mlp.down_proj", | |
| "model.visual.blocks.3.attn.qkv", | |
| "model.visual.blocks.3.attn.proj", | |
| "model.visual.blocks.3.mlp.gate_proj", | |
| "model.visual.blocks.3.mlp.up_proj", | |
| "model.visual.blocks.3.mlp.down_proj", | |
| "model.visual.blocks.4.attn.qkv", | |
| "model.visual.blocks.4.attn.proj", | |
| "model.visual.blocks.4.mlp.gate_proj", | |
| "model.visual.blocks.4.mlp.up_proj", | |
| "model.visual.blocks.4.mlp.down_proj", | |
| "model.visual.blocks.5.attn.qkv", | |
| "model.visual.blocks.5.attn.proj", | |
| "model.visual.blocks.5.mlp.gate_proj", | |
| "model.visual.blocks.5.mlp.up_proj", | |
| "model.visual.blocks.5.mlp.down_proj", | |
| "model.visual.blocks.6.attn.qkv", | |
| "model.visual.blocks.6.attn.proj", | |
| "model.visual.blocks.6.mlp.gate_proj", | |
| "model.visual.blocks.6.mlp.up_proj", | |
| "model.visual.blocks.6.mlp.down_proj", | |
| "model.visual.blocks.7.attn.qkv", | |
| "model.visual.blocks.7.attn.proj", | |
| "model.visual.blocks.7.mlp.gate_proj", | |
| "model.visual.blocks.7.mlp.up_proj", | |
| "model.visual.blocks.7.mlp.down_proj", | |
| "model.visual.blocks.8.attn.qkv", | |
| "model.visual.blocks.8.attn.proj", | |
| "model.visual.blocks.8.mlp.gate_proj", | |
| "model.visual.blocks.8.mlp.up_proj", | |
| "model.visual.blocks.8.mlp.down_proj", | |
| "model.visual.blocks.9.attn.qkv", | |
| "model.visual.blocks.9.attn.proj", | |
| "model.visual.blocks.9.mlp.gate_proj", | |
| "model.visual.blocks.9.mlp.up_proj", | |
| "model.visual.blocks.9.mlp.down_proj", | |
| "model.visual.blocks.10.attn.qkv", | |
| "model.visual.blocks.10.attn.proj", | |
| "model.visual.blocks.10.mlp.gate_proj", | |
| "model.visual.blocks.10.mlp.up_proj", | |
| "model.visual.blocks.10.mlp.down_proj", | |
| "model.visual.blocks.11.attn.qkv", | |
| "model.visual.blocks.11.attn.proj", | |
| "model.visual.blocks.11.mlp.gate_proj", | |
| "model.visual.blocks.11.mlp.up_proj", | |
| "model.visual.blocks.11.mlp.down_proj", | |
| "model.visual.blocks.12.attn.qkv", | |
| "model.visual.blocks.12.attn.proj", | |
| "model.visual.blocks.12.mlp.gate_proj", | |
| "model.visual.blocks.12.mlp.up_proj", | |
| "model.visual.blocks.12.mlp.down_proj", | |
| "model.visual.blocks.13.attn.qkv", | |
| "model.visual.blocks.13.attn.proj", | |
| "model.visual.blocks.13.mlp.gate_proj", | |
| "model.visual.blocks.13.mlp.up_proj", | |
| "model.visual.blocks.13.mlp.down_proj", | |
| "model.visual.blocks.14.attn.qkv", | |
| "model.visual.blocks.14.attn.proj", | |
| "model.visual.blocks.14.mlp.gate_proj", | |
| "model.visual.blocks.14.mlp.up_proj", | |
| "model.visual.blocks.14.mlp.down_proj", | |
| "model.visual.blocks.15.attn.qkv", | |
| "model.visual.blocks.15.attn.proj", | |
| "model.visual.blocks.15.mlp.gate_proj", | |
| "model.visual.blocks.15.mlp.up_proj", | |
| "model.visual.blocks.15.mlp.down_proj", | |
| "model.visual.blocks.16.attn.qkv", | |
| "model.visual.blocks.16.attn.proj", | |
| "model.visual.blocks.16.mlp.gate_proj", | |
| "model.visual.blocks.16.mlp.up_proj", | |
| "model.visual.blocks.16.mlp.down_proj", | |
| "model.visual.blocks.17.attn.qkv", | |
| "model.visual.blocks.17.attn.proj", | |
| "model.visual.blocks.17.mlp.gate_proj", | |
| "model.visual.blocks.17.mlp.up_proj", | |
| "model.visual.blocks.17.mlp.down_proj", | |
| "model.visual.blocks.18.attn.qkv", | |
| "model.visual.blocks.18.attn.proj", | |
| "model.visual.blocks.18.mlp.gate_proj", | |
| "model.visual.blocks.18.mlp.up_proj", | |
| "model.visual.blocks.18.mlp.down_proj", | |
| "model.visual.blocks.19.attn.qkv", | |
| "model.visual.blocks.19.attn.proj", | |
| "model.visual.blocks.19.mlp.gate_proj", | |
| "model.visual.blocks.19.mlp.up_proj", | |
| "model.visual.blocks.19.mlp.down_proj", | |
| "model.visual.blocks.20.attn.qkv", | |
| "model.visual.blocks.20.attn.proj", | |
| "model.visual.blocks.20.mlp.gate_proj", | |
| "model.visual.blocks.20.mlp.up_proj", | |
| "model.visual.blocks.20.mlp.down_proj", | |
| "model.visual.blocks.21.attn.qkv", | |
| "model.visual.blocks.21.attn.proj", | |
| "model.visual.blocks.21.mlp.gate_proj", | |
| "model.visual.blocks.21.mlp.up_proj", | |
| "model.visual.blocks.21.mlp.down_proj", | |
| "model.visual.blocks.22.attn.qkv", | |
| "model.visual.blocks.22.attn.proj", | |
| "model.visual.blocks.22.mlp.gate_proj", | |
| "model.visual.blocks.22.mlp.up_proj", | |
| "model.visual.blocks.22.mlp.down_proj", | |
| "model.visual.blocks.23.attn.qkv", | |
| "model.visual.blocks.23.attn.proj", | |
| "model.visual.blocks.23.mlp.gate_proj", | |
| "model.visual.blocks.23.mlp.up_proj", | |
| "model.visual.blocks.23.mlp.down_proj", | |
| "model.visual.blocks.24.attn.qkv", | |
| "model.visual.blocks.24.attn.proj", | |
| "model.visual.blocks.24.mlp.gate_proj", | |
| "model.visual.blocks.24.mlp.up_proj", | |
| "model.visual.blocks.24.mlp.down_proj", | |
| "model.visual.blocks.25.attn.qkv", | |
| "model.visual.blocks.25.attn.proj", | |
| "model.visual.blocks.25.mlp.gate_proj", | |
| "model.visual.blocks.25.mlp.up_proj", | |
| "model.visual.blocks.25.mlp.down_proj", | |
| "model.visual.blocks.26.attn.qkv", | |
| "model.visual.blocks.26.attn.proj", | |
| "model.visual.blocks.26.mlp.gate_proj", | |
| "model.visual.blocks.26.mlp.up_proj", | |
| "model.visual.blocks.26.mlp.down_proj", | |
| "model.visual.blocks.27.attn.qkv", | |
| "model.visual.blocks.27.attn.proj", | |
| "model.visual.blocks.27.mlp.gate_proj", | |
| "model.visual.blocks.27.mlp.up_proj", | |
| "model.visual.blocks.27.mlp.down_proj", | |
| "model.visual.blocks.28.attn.qkv", | |
| "model.visual.blocks.28.attn.proj", | |
| "model.visual.blocks.28.mlp.gate_proj", | |
| "model.visual.blocks.28.mlp.up_proj", | |
| "model.visual.blocks.28.mlp.down_proj", | |
| "model.visual.blocks.29.attn.qkv", | |
| "model.visual.blocks.29.attn.proj", | |
| "model.visual.blocks.29.mlp.gate_proj", | |
| "model.visual.blocks.29.mlp.up_proj", | |
| "model.visual.blocks.29.mlp.down_proj", | |
| "model.visual.blocks.30.attn.qkv", | |
| "model.visual.blocks.30.attn.proj", | |
| "model.visual.blocks.30.mlp.gate_proj", | |
| "model.visual.blocks.30.mlp.up_proj", | |
| "model.visual.blocks.30.mlp.down_proj", | |
| "model.visual.blocks.31.attn.qkv", | |
| "model.visual.blocks.31.attn.proj", | |
| "model.visual.blocks.31.mlp.gate_proj", | |
| "model.visual.blocks.31.mlp.up_proj", | |
| "model.visual.blocks.31.mlp.down_proj", | |
| "model.visual.merger.mlp.0", | |
| "model.visual.merger.mlp.2", | |
| "lm_head" | |
| ], | |
| "kv_cache_scheme": null, | |
| "quant_method": "compressed-tensors", | |
| "quantization_status": "compressed", | |
| "sparsity_config": {}, | |
| "transform_config": {}, | |
| "version": "0.13.0" | |
| }, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": { | |
| "mrope_section": [ | |
| 16, | |
| 24, | |
| 24 | |
| ], | |
| "rope_type": "default", | |
| "type": "default" | |
| }, | |
| "rope_theta": 1000000.0, | |
| "sliding_window": 32768, | |
| "text_config": { | |
| "_name_or_path": "models/model_ocr_dpo_v0_Nanonets-OCR2-3B_3epochs_lr1e-05_(fft)_batch32-prompt_generic_(Nanonets-OCR2-3B_3epochs_lr1e-05_(fft)_batch32-prompt_generic)->(preference_train_fit_recompressed.parquet)|lr:1e-05_3epochs|dpo", | |
| "architectures": [ | |
| "Qwen2_5_VLForConditionalGeneration" | |
| ], | |
| "attention_dropout": 0.0, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 151645, | |
| "hidden_act": "silu", | |
| "hidden_size": 2048, | |
| "image_token_id": 151655, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 11008, | |
| "layer_types": [ | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention" | |
| ], | |
| "max_position_embeddings": 128000, | |
| "max_window_layers": 70, | |
| "model_type": "qwen2_5_vl_text", | |
| "num_attention_heads": 16, | |
| "num_hidden_layers": 36, | |
| "num_key_value_heads": 2, | |
| "pad_token_id": 151643, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": { | |
| "mrope_section": [ | |
| 16, | |
| 24, | |
| 24 | |
| ], | |
| "rope_type": "default", | |
| "type": "default" | |
| }, | |
| "rope_theta": 1000000.0, | |
| "sliding_window": null, | |
| "tie_word_embeddings": true, | |
| "use_cache": false, | |
| "use_sliding_window": false, | |
| "video_token_id": 151656, | |
| "vision_end_token_id": 151653, | |
| "vision_start_token_id": 151652, | |
| "vision_token_id": 151654, | |
| "vocab_size": 151936 | |
| }, | |
| "transformers_version": "4.57.3", | |
| "use_cache": true, | |
| "use_sliding_window": false, | |
| "vision_config": { | |
| "depth": 32, | |
| "dtype": "bfloat16", | |
| "fullatt_block_indexes": [ | |
| 7, | |
| 15, | |
| 23, | |
| 31 | |
| ], | |
| "hidden_act": "silu", | |
| "hidden_size": 1280, | |
| "in_channels": 3, | |
| "in_chans": 3, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 3420, | |
| "model_type": "qwen2_5_vl", | |
| "num_heads": 16, | |
| "out_hidden_size": 2048, | |
| "patch_size": 14, | |
| "spatial_merge_size": 2, | |
| "spatial_patch_size": 14, | |
| "temporal_patch_size": 2, | |
| "tokens_per_second": 2, | |
| "window_size": 112 | |
| }, | |
| "vision_token_id": 151654, | |
| "vocab_size": 151936 | |
| } |