{
  "hf_id": "zai-org/GLM-OCR",
  "meta": {
    "title": "GLM-OCR",
    "slug": "glm-ocr",
    "provider": "GLM (Z-AI)",
    "description": "GLM-OCR image-to-text model with built-in MTP speculative decoding for high-throughput OCR serving",
    "date_added": "2026-01-26",
    "date_updated": "2026-04-17",
    "tasks": [
      "multimodal"
    ],
    "performance_headline": "Multilingual end-to-end OCR VLM with MTP-accelerated decoding",
    "related_recipes": []
  },
  "recommended_command": {
    "hardware": "h200",
    "strategy": "single_node_tp",
    "variant": "default",
    "node_count": 1,
    "deploy_type": "single_node",
    "env": {},
    "docker_image": "vllm/vllm-openai:latest",
    "command": "vllm serve zai-org/GLM-OCR \\\n  --tensor-parallel-size 1 \\\n  --speculative-config.method mtp \\\n  --speculative-config.num_speculative_tokens 1",
    "argv": [
      "vllm",
      "serve",
      "zai-org/GLM-OCR",
      "--tensor-parallel-size",
      "1",
      "--speculative-config.method",
      "mtp",
      "--speculative-config.num_speculative_tokens",
      "1"
    ],
    "docker_command": "docker run --gpus all \\\n  --privileged --ipc=host -p 8000:8000 \\\n  -v ~/.cache/huggingface:/root/.cache/huggingface \\\n  vllm/vllm-openai:latest zai-org/GLM-OCR \\\n  --tensor-parallel-size 1 \\\n  --speculative-config.method mtp \\\n  --speculative-config.num_speculative_tokens 1",
    "docker_argv": [
      "docker",
      "run",
      "--gpus",
      "all",
      "--privileged",
      "--ipc=host",
      "-p",
      "8000:8000",
      "-v",
      "~/.cache/huggingface:/root/.cache/huggingface",
      "vllm/vllm-openai:latest",
      "zai-org/GLM-OCR",
      "--tensor-parallel-size",
      "1",
      "--speculative-config.method",
      "mtp",
      "--speculative-config.num_speculative_tokens",
      "1"
    ],
    "strategy_spec": {
      "name": "single_node_tp",
      "deploy_type": "single_node",
      "display_name": "Tensor Parallel",
      "short_label": "TP",
      "orientation": "latency",
      "description": "Single-node tensor parallel. Splits the model across all local GPUs. TP size is set to the GPU count at deploy time. The simplest multi-GPU strategy — works for all model architectures.\n",
      "hardware_match": {
        "min_gpus": 1,
        "max_gpus": 8,
        "multi_node": false
      },
      "vllm_args": [],
      "parallel_flag": "--tensor-parallel-size"
    },
    "hardware_profile": {
      "brand": "NVIDIA",
      "generation": "hopper",
      "compute_arch": "sm90",
      "display_name": "H200",
      "description": "NVIDIA H200 SXM 141 GB HBM3e · 8-GPU HGX node",
      "gpu_count": 8,
      "vram_gb": 1128,
      "multi_node": false
    },
    "alternatives": {
      "multi_node_tp": "/zai-org/GLM-OCR/strategies/multi_node_tp.json",
      "kv_store_centralized_mooncake": "/zai-org/GLM-OCR/strategies/kv_store_centralized_mooncake.json",
      "kv_store_distributed_mooncake": "/zai-org/GLM-OCR/strategies/kv_store_distributed_mooncake.json"
    },
    "by_hardware": {
      "h200": "/zai-org/GLM-OCR/hw/h200.json",
      "h100": "/zai-org/GLM-OCR/hw/h100.json",
      "b200": "/zai-org/GLM-OCR/hw/b200.json",
      "gb200": "/zai-org/GLM-OCR/hw/gb200.json",
      "b300": "/zai-org/GLM-OCR/hw/b300.json",
      "gb300": "/zai-org/GLM-OCR/hw/gb300.json",
      "mi300x": "/zai-org/GLM-OCR/hw/mi300x.json",
      "mi325x": "/zai-org/GLM-OCR/hw/mi325x.json",
      "mi350x": "/zai-org/GLM-OCR/hw/mi350x.json",
      "mi355x": "/zai-org/GLM-OCR/hw/mi355x.json"
    }
  },
  "model": {
    "model_id": "zai-org/GLM-OCR",
    "min_vllm_version": "0.16.0",
    "architecture": "dense",
    "parameter_count": "0.9B",
    "active_parameters": "0.9B",
    "context_length": 131072,
    "base_args": [],
    "base_env": {},
    "install": {
      "pip": {
        "command": "uv venv\nsource .venv/bin/activate\nuv pip install -U vllm --torch-backend auto"
      },
      "docker": {
        "command": "docker pull vllm/vllm-openai:latest"
      },
      "extras": [
        {
          "note": "GLM-OCR requires the nightly vllm wheel",
          "command": "uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly"
        },
        {
          "note": "transformers from source for GLM-OCR tokenizer support",
          "command": "uv pip install git+https://github.com/huggingface/transformers.git"
        }
      ]
    }
  },
  "features": {
    "spec_decoding": {
      "description": "Multi-Token Prediction speculative decoding using the model's built-in MTP layers",
      "args": [
        "--speculative-config.method",
        "mtp",
        "--speculative-config.num_speculative_tokens",
        "1"
      ]
    },
    "text_only": {
      "description": "Skip loading the vision encoder for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel.",
      "args": [
        "--language-model-only"
      ]
    },
    "encoder_parallel": {
      "description": "Run the vision encoder in data-parallel mode — avoids TP comm overhead on the small encoder. Mutually exclusive with text_only.",
      "args": [
        "--mm-encoder-tp-mode",
        "data"
      ]
    }
  },
  "opt_in_features": [
    "text_only",
    "encoder_parallel"
  ],
  "variants": {
    "default": {
      "precision": "bf16",
      "vram_minimum_gb": 2,
      "description": "Full precision BF16 — single-GPU deployment"
    }
  },
  "kv_offload_support": {
    "offloading_cpu": "verified",
    "offloading_fs": "verified"
  },
  "hardware_overrides": {},
  "guide": "## Overview\n\nGLM-OCR is a vision-language model for end-to-end OCR. It includes built-in\nMulti-Token Prediction (MTP) layers enabling speculative decoding for higher\nthroughput generation.\n\n## Prerequisites\n\n- **vLLM version:** nightly recommended (or latest stable with MTP support)\n- **Transformers:** >= 5.0.0 (install from source for latest)\n\n### Install vLLM\n\n```bash\nuv venv\nsource .venv/bin/activate\nuv pip install -U vllm --torch-backend auto\n```\n\nOr nightly:\n\n```bash\nuv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly\nuv pip install git+https://github.com/huggingface/transformers.git\n```\n\n## Launching the Server\n\n### With MTP Speculative Decoding\n\n```bash\nvllm serve zai-org/GLM-OCR \\\n     --speculative-config.method mtp \\\n     --speculative-config.num_speculative_tokens 1\n```\n\n## Client Usage\n\n### OpenAI SDK\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(api_key=\"EMPTY\", base_url=\"http://localhost:8000/v1\", timeout=3600)\n\nmessages = [{\n    \"role\": \"user\",\n    \"content\": [\n        {\"type\": \"image_url\", \"image_url\": {\"url\": \"https://ofasys-multimodal-wlcb-3-toshanghai.oss-accelerate.aliyuncs.com/wpf272043/keepme/image/receipt.png\"}},\n        {\"type\": \"text\", \"text\": \"Text Recognition:\"}\n    ]\n}]\n\nresponse = client.chat.completions.create(\n    model=\"zai-org/GLM-OCR\",\n    messages=messages,\n    max_tokens=2048,\n    temperature=0.0,\n)\nprint(response.choices[0].message.content)\n```\n\n### cURL\n\n```bash\ncurl -s http://localhost:8000/v1/chat/completions \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n          \"model\": \"zai-org/GLM-OCR\",\n          \"messages\": [{\n               \"role\": \"user\",\n               \"content\": [\n                    {\"type\": \"image_url\", \"image_url\": {\"url\": \"https://example.com/receipt.png\"}},\n                    {\"type\": \"text\", \"text\": \"Text Recognition:\"}\n               ]\n          }],\n          \"max_tokens\": 2048,\n          \"temperature\": 0.0\n     }'\n```\n\n## Troubleshooting\n\n- **Greedy sampling recommended:** Use `temperature=0.0` for optimal OCR accuracy.\n- **Transformers version:** Requires `transformers >= 5.0.0`.\n\n## References\n\n- [Model card](https://huggingface.co/zai-org/GLM-OCR)\n",
  "source": {
    "source": "vllm",
    "repo": "vllm-project/vllm",
    "ref": "main",
    "sha": "389ffebe555705c85337025d5df108d0384d365e",
    "path": "recipes/models/zai-org/GLM-OCR.yaml",
    "edit_url": "https://github.com/vllm-project/vllm/edit/main/recipes/models/zai-org/GLM-OCR.yaml",
    "overlays": []
  }
}