Instructions to use hitxhslhy/realocr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hitxhslhy/realocr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="hitxhslhy/realocr") 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("hitxhslhy/realocr") model = AutoModelForMultimodalLM.from_pretrained("hitxhslhy/realocr", 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 hitxhslhy/realocr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hitxhslhy/realocr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hitxhslhy/realocr", "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/hitxhslhy/realocr
- SGLang
How to use hitxhslhy/realocr 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 "hitxhslhy/realocr" \ --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": "hitxhslhy/realocr", "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 "hitxhslhy/realocr" \ --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": "hitxhslhy/realocr", "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 hitxhslhy/realocr with Docker Model Runner:
docker model run hf.co/hitxhslhy/realocr
realocr
A 2B-parameter end-to-end document parsing model: page image in, full-page Markdown out. Built for the MDPBench protocol (17 languages, digital and photographed documents, 3,400 images).
This repository contains standalone bf16 weights for direct inference:
from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration
model = Qwen3_5ForConditionalGeneration.from_pretrained("hitxhslhy/realocr")
processor = AutoProcessor.from_pretrained("hitxhslhy/realocr")
Requires transformers>=5.3.0 (architecture Qwen3_5ForConditionalGeneration,
model_type: qwen3_5).
How to run inference
pip install -r inference/requirements.txt
python inference/infer_mdpbench.py \
--model . \
--image-dir /path/to/MDPBench_img_public \
--out-dir /path/to/result/our_model
Writes one .md per page image (filename = image stem) โ exactly what the MDPBench
evaluation pipeline expects. See SUBMISSION_README.md for the full recipe and the exact
inference settings, and VALIDATION.md for what was tested on real hardware.
Key settings that must be kept: official MDPBench prompt (embedded verbatim in
inference/infer_mdpbench.py), greedy decoding, max_new_tokens=8192, native resolution
(max_pixels=16777216), enable_thinking=False, and the Conv3d โ Linear patch for the
vision patch-embed (applied automatically by the script).
Note: the vision patch-embed is nn.Conv3d in stock transformers; on some GPUs this hits
a pathological cuDNN kernel (~39.5 s per call, 99.8% of the forward pass). The provided
script replaces it with a mathematically equivalent Linear matmul before loading.
- Downloads last month
- 2