Image-Text-to-Text
Transformers
Safetensors
English
Chinese
glm_ocr
ocr
document-parsing
block-diffusion
speculative-decoding
glm-ocr
conversational
Instructions to use trillionlabs/GravityOCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trillionlabs/GravityOCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trillionlabs/GravityOCR") 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 AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("trillionlabs/GravityOCR") model = AutoModelForMultimodalLM.from_pretrained("trillionlabs/GravityOCR", 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 = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trillionlabs/GravityOCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trillionlabs/GravityOCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trillionlabs/GravityOCR", "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/trillionlabs/GravityOCR
- SGLang
How to use trillionlabs/GravityOCR 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 "trillionlabs/GravityOCR" \ --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": "trillionlabs/GravityOCR", "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 "trillionlabs/GravityOCR" \ --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": "trillionlabs/GravityOCR", "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 trillionlabs/GravityOCR with Docker Model Runner:
docker model run hf.co/trillionlabs/GravityOCR
Commit History
-
Model card: training section removed
Verified signaturebdbe9ab -
Model card: training trimmed, limitations folded into Use
Verified signaturea8b320d -
Model card restructured: links, Figure 1, results, clip, use, details, training
Verified signaturea9d63d1 -
Model card: Figure 1
Verified signatureda267e7 -
Clip: softer palette
Verified signaturee59b44c -
Clip: stronger block colours
Verified signature4269e6c -
Clip: blocks as outlined chips
Verified signature2a4a41f -
Clip: colour legend
Verified signature177aba0 -
Clip: summary first, then the race
Verified signaturebda6451 -
Model card: shorter clip caption
Verified signature8891189 -
Clip: longer final hold
Verified signature7937bcb -
Model card: clip caption states the measured boundary
Verified signature71a339c -
Remove the superseded crop clip
Verified signature80204e8 -
Model card: page-race clip
Verified signature6c849de -
Model card clip: one page at measured speed
Verified signature871cec4 -
Clip: one-quarter wall time
Verified signaturef5cc5fe -
Model card: clip at one-quarter wall time
Verified signaturebbd87fc -
Clip: one-fifth wall time
Verified signature8b83715 -
Model card: clip at one-fifth wall time
Verified signaturefac1456 -
Model card clip: 7x wall time
Verified signatured4fc798 -
Model card: paper title and data description; clip at 7x wall time
Verified signature0406f22 -
Model card clip: faster shared clock
Verified signaturea5d8c76
-
Model card asset: AR vs self-speculative clip
Verified signature65bb40d -
Model card: GravityOCR naming, final measurements, decoding clip
Verified signaturec7b1fae
-
license (MIT)
Verified signature527be9d -
model card
Verified signaturec42d7a9 -
TrillionOCR-D final weights (GRPO v17, step 500)
Verified signature61c07d2 -
initial commit
Verified signature994c631