44# "datasets>=3.1.0",
55# "huggingface-hub",
66# "pillow",
7- # "vllm",
87# "toolz",
9- # "torch",
108# ]
119#
12- # [[tool.uv.index]]
13- # url = "https://wheels.vllm.ai/nightly/cu129"
14- #
15- # [tool.uv]
16- # prerelease = "allow"
17- # override-dependencies = ["transformers>=5.1.0"]
18- #
1910# [tool.hf-jobs]
11+ # image = "vllm/vllm-openai:v0.29.0"
12+ # python = "/usr/bin/python3"
13+ # env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }
2014# flavor = "a10g-small"
2115# secrets = ["HF_TOKEN"]
2216# ///
2822Uses CogViT visual encoder with GLM-0.5B language decoder and Multi-Token Prediction
2923(MTP) loss for fast, accurate document parsing.
3024
31- NOTE: Requires vLLM nightly wheels from cu129 variant (GLM-OCR added in v0.16.0,
32- PR #33005) and transformers>=5.1.0 ( GLM-OCR support landed in stable release).
33- Uses https://wheels.vllm.ai/nightly/cu129 which has x86_64 wheels.
34- First run may take a few minutes to download and install dependencies .
25+ NOTE: On Jobs, vLLM, torch and transformers come from the vllm/vllm-openai: v0.29.0
26+ image pinned in the [tool.hf-jobs] header (`hf` CLI 1.32+). GLM-OCR needs vLLM
27+ >=0.16.0 (PR #33005) and transformers>=5.1.0; the image has both. To run on your
28+ own GPU: `uv run --with vllm==0.29.0 glm-ocr.py ...` .
3529
3630Features:
3731- 0.9B parameters (ultra-compact)
4337- MIT licensed
4438
4539Model: zai-org/GLM-OCR
46- vLLM: Requires vLLM nightly build + transformers>=5.1.0
40+ vLLM: vllm/vllm-openai:v0.29.0 image (see the header)
4741Performance: 94.62% on OmniDocBench V1.5
4842"""
4943
6761# default uv-script image lacks (engine init then crashes). Greedy OCR doesn't use it; this
6862# lets the plain default-image command work. On the vllm/vllm-openai image it's a harmless no-op.
6963os .environ .setdefault ("VLLM_USE_FLASHINFER_SAMPLER" , "0" )
70- # Same story for DeepGEMM (nightly vLLM) : its init calls _find_cuda_home, which asserts on the
64+ # Same story for DeepGEMM: its init calls _find_cuda_home, which asserts on the
7165# nvcc-less base image (a non-fatal warning that clutters the log and hides the real traceback).
7266# Greedy OCR doesn't need the DeepGEMM JIT path, so disable it explicitly.
7367os .environ .setdefault ("VLLM_USE_DEEP_GEMM" , "0" )
@@ -524,20 +518,20 @@ def update_inference_info(example):
524518 print (" table - Table extraction" )
525519 print ("\n Examples:" )
526520 print ("\n 1. Basic OCR:" )
527- print (" uv run glm-ocr.py input-dataset output-dataset" )
521+ print (" uv run --with vllm==0.29.0 glm-ocr.py input-dataset output-dataset" )
528522 print ("\n 2. Formula recognition:" )
529- print (" uv run glm-ocr.py docs results --task formula" )
523+ print (" uv run --with vllm==0.29.0 glm-ocr.py docs results --task formula" )
530524 print ("\n 3. Table extraction:" )
531- print (" uv run glm-ocr.py docs results --task table" )
525+ print (" uv run --with vllm==0.29.0 glm-ocr.py docs results --task table" )
532526 print ("\n 4. Test with small sample:" )
533- print (" uv run glm-ocr.py large-dataset test --max-samples 10 --shuffle" )
527+ print (" uv run --with vllm==0.29.0 glm-ocr.py large-dataset test --max-samples 10 --shuffle" )
534528 print ("\n 5. Running on HF Jobs (hardware and HF_TOKEN come from the" )
535529 print (" script's [tool.hf-jobs] header; --flavor/--timeout override it):" )
536530 print (
537531 " hf jobs uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \\ "
538532 )
539533 print (" input-dataset output-dataset --batch-size 16" )
540- print ("\n For full help: uv run glm-ocr.py --help" )
534+ print ("\n For full help: uv run --with vllm==0.29.0 glm-ocr.py --help" )
541535 sys .exit (0 )
542536
543537 parser = argparse .ArgumentParser (
@@ -550,9 +544,9 @@ def update_inference_info(example):
550544 table Table extraction
551545
552546Examples:
553- uv run glm-ocr.py my-docs analyzed-docs
554- uv run glm-ocr.py docs results --task formula
555- uv run glm-ocr.py large-dataset test --max-samples 50 --shuffle
547+ uv run --with vllm==0.29.0 glm-ocr.py my-docs analyzed-docs
548+ uv run --with vllm==0.29.0 glm-ocr.py docs results --task formula
549+ uv run --with vllm==0.29.0 glm-ocr.py large-dataset test --max-samples 50 --shuffle
556550 """ ,
557551 )
558552
0 commit comments