How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("image-text-to-text", model="axteam/GLM-OCR-FP8-dynamic")
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("axteam/GLM-OCR-FP8-dynamic")
model = AutoModelForMultimodalLM.from_pretrained("axteam/GLM-OCR-FP8-dynamic", 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]:]))
Quick Links

GLM-OCR ยท FP8 (dynamic)

8-bit quantization of zai-org/GLM-OCR for vLLM serving. Quantized by axteam.

Base model zai-org/GLM-OCR
Method FP8 (dynamic)
Format compressed-tensors float-quantized (scheme FP8_DYNAMIC)
Weights / activations W8A8 โ€” FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations
Architecture Dense ยท GLM text backbone + vision encoder ยท MTP head ยท document/OCR VLM
Size on disk ~2.2 GB
Calibration None (data-free)
License mit

Quantization details

  • Scheme โ€” W8A8 โ€” FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations, stored as compressed-tensors float-quantized (scheme FP8_DYNAMIC).
  • Kept in BF16 โ€” the vision tower (model.visual.*), the multi-token-prediction layer, token embeddings, the LM head, and all RMSNorms (about 63% of all parameters in this build). Only the language-model backbone's attention & MLP projections are quantized, so the OCR/vision path is untouched.
  • Post-training quantization (no retraining). Tokenizer / chat_template / processor identical to the original.

Evaluation (measured)

Fidelity to the BF16 original on an internal mixed EN/KO set (100 prompts, text next-token scoring).

Metric This model BF16 original
Perplexity (lower = closer) 1.3726 1.3599 (+0.9%)
Top-1 next-token agreement 96.5% 99.4%

Requirements

Runtime vLLM โ€” the architecture is in vLLM โ‰ฅ 0.16.0; tested here with vLLM 0.32.0.
vLLM install vLLM 0.32 itself needs Python 3.11โ€“3.14, torch 2.13 (CUDA 13.0 build, so an NVIDIA driver with CUDA 13 support), transformers โ‰ฅ5.16.1,<5.20 and compressed-tensors 0.17.0 (both pinned by vLLM; 0.17.0 reads this checkpoint, which was saved with 0.19.0 โ€” do not upgrade it separately).
GPU NVIDIA Turing (sm75, e.g. T4) or newer. FP8 math runs on Ada / Hopper / Blackwell (sm89+); on Turing and Ampere vLLM switches to weight-only FP8 automatically. V100 (sm70) is not supported. (Kernel choice per GPU from vLLM 0.32's selection code; only B200 was run here.)
Memory Weights: 2.2 GB. Add KV cache (grows with context length ร— concurrent requests) and a few GB for activations / CUDA graphs; use --tensor-parallel-size N when the weights do not fit one GPU.
Transformers (without vLLM) transformers>=5.1.0 + compressed-tensors>=0.15.0 (text path checked; image input not tested).
trust_remote_code not needed

Usage (vLLM)

Start an OpenAI-compatible server:

vllm serve axteam/GLM-OCR-FP8-dynamic --max-model-len 32768

Query it:

curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
  "model": "axteam/GLM-OCR-FP8-dynamic",
  "messages": [{"role": "user", "content": "๋Œ€ํ•œ๋ฏผ๊ตญ์˜ ์ˆ˜๋„๋Š” ์–ด๋””์ธ๊ฐ€์š”?"}],
  "max_tokens": 512
}'

Offline inference in Python:

from vllm import LLM, SamplingParams

llm = LLM(model="axteam/GLM-OCR-FP8-dynamic", max_model_len=32768)
params = SamplingParams(max_tokens=1024)
out = llm.chat([{"role": "user", "content": "Explain model quantization in two sentences."}], params)
print(out[0].outputs[0].text)

# image input (URL or data: URI)
messages = [{"role": "user", "content": [
    {"type": "image_url", "image_url": {"url": "https://example.com/your-image.png"}},
    {"type": "text", "text": "Extract all text from this image."},
]}]
out = llm.chat(messages, params)
print(out[0].outputs[0].text)

Thinking mode is on by default in the chat template; to turn it off pass chat_template_kwargs={"enable_thinking": False} (Python llm.chat(..., chat_template_kwargs=...), or "chat_template_kwargs": {"enable_thinking": false} in the request body). For task-specific OCR prompts (tables, formulas, layout) see the original model card.

Reducing KV-cache memory (optional, serve-time)

The KV cache is kept in BF16 by default. KV-cache precision is a runtime choice, independent of the weight quantization above; for long contexts or large batches FP8 roughly halves KV-cache memory:

vllm serve axteam/GLM-OCR-FP8-dynamic --kv-cache-dtype fp8

License

Quantized derivative of zai-org/GLM-OCR (mit). Original weights & processor belong to the upstream authors.


ํ•œ๊ตญ์–ด ์š”์•ฝ

zai-org/GLM-OCR์˜ FP8 (W8A8) ์–‘์žํ™” ๋นŒ๋“œ ยท ์ œ์ž‘ axteam

๊ฐœ์š”

ํ•ญ๋ชฉ ๋‚ด์šฉ
์›๋ณธ ๋ชจ๋ธ zai-org/GLM-OCR
์–‘์žํ™” ๋ฐฉ์‹ FP8 ๋™์  ์–‘์žํ™” (W8A8)
์ €์žฅ ํ˜•์‹ compressed-tensors float-quantized (scheme FP8_DYNAMIC)
๋ชจ๋ธ ๊ตฌ์กฐ Dense ยท GLM ํ…์ŠคํŠธ ๋ฐฑ๋ณธ + ๋น„์ „ ํƒ€์›Œ ยท MTP ํ—ค๋“œ ยท ๋ฌธ์„œยทOCR์šฉ VLM
์šฉ๋Ÿ‰ ์•ฝ 2.2 GB
๋ณด์ • ๋ฐ์ดํ„ฐ ์—†์Œ (๊ฐ€์ค‘์น˜ ์Šค์ผ€์ผ์€ ๊ฐ€์ค‘์น˜๋งŒ์œผ๋กœ ๊ณ„์‚ฐ, ํ™œ์„ฑํ™” ์Šค์ผ€์ผ์€ ์‹คํ–‰ ์‹œ ๊ณ„์‚ฐ)

์–‘์žํ™” ์ƒ์„ธ

  • ๊ฐ€์ค‘์น˜: FP8(E4M3), ์ถœ๋ ฅ ์ฑ„๋„๋ณ„ ์Šค์ผ€์ผ
  • ํ™œ์„ฑํ™”: ์‹คํ–‰ ์‹œ ํ† ํฐ๋ณ„ ๋™์  FP8
  • ์–‘์žํ™” ์ ˆ์ฐจ: PTQ(ํ•™์Šต ํ›„ ์–‘์žํ™”, ์žฌํ•™์Šต ์—†์Œ), ๊ฐ€์ค‘์น˜ ์Šค์ผ€์ผ์€ ๋ฏธ๋ฆฌ ๊ณ„์‚ฐํ•˜๊ณ  ํ™œ์„ฑํ™” ์Šค์ผ€์ผ์€ ์‹คํ–‰ ์‹œ ํ† ํฐ๋งˆ๋‹ค ๊ณ„์‚ฐ
  • BF16 ์œ ์ง€: ๋น„์ „ ํƒ€์›Œ(model.visual.*), MTP ํ—ค๋“œ(๋‹ค์ค‘ ํ† ํฐ ์˜ˆ์ธก ์ธต), ํ† ํฐ ์ž„๋ฒ ๋”ฉ, LM ํ—ค๋“œ, ๋ชจ๋“  RMSNorm โ€” ์ „์ฒด ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์•ฝ 63%
  • ์–‘์žํ™” ๋Œ€์ƒ: ์–ธ์–ด๋ชจ๋ธ ๋ฐฑ๋ณธ์˜ ์–ดํ…์…˜ยทMLP ์„ ํ˜•์ธต(projection) (OCRยท๋น„์ „ ๊ฒฝ๋กœ๋Š” ์›๋ณธ ๊ทธ๋Œ€๋กœ)
  • ์›๋ณธ ํŒŒ์ผ: ํ† ํฌ๋‚˜์ด์ €ยทchat templateยทprocessor๋Š” ์›๋ณธ๊ณผ ๋™์ผ

ํ’ˆ์งˆ (์‹ค์ธก)

  • ์›๋ณธ ๋Œ€๋น„ ์ถฉ์‹ค๋„: PPL 1.3726 (์›๋ณธ 1.3599, +0.9%, ๋‚ฎ์„์ˆ˜๋ก ์›๋ณธ์— ๊ฐ€๊นŒ์›€), ๋‹ค์Œ ํ† ํฐ top-1 ์ผ์น˜์œจ 96.5% (์›๋ณธ ์ž์ฒด ๊ธฐ์ค€๊ฐ’ 99.4%) โ€” ๋‚ด๋ถ€ ์˜์–ดยทํ•œ๊ตญ์–ด ํ˜ผํ•ฉ ํ”„๋กฌํ”„ํŠธ 100๊ฐœ, ํ…์ŠคํŠธ ๋‹ค์Œ ํ† ํฐ ๊ธฐ์ค€์œผ๋กœ ์ธก์ •

์š”๊ตฌ์‚ฌํ•ญ

  • ์‹คํ–‰ ์—”์ง„: vLLM 0.16.0 ์ด์ƒ(์ด ๊ตฌ์กฐ๋ฅผ ์ง€์›ํ•˜๋Š” ์ฒซ ๋ฒ„์ „), ์ด ๋นŒ๋“œ๋Š” vLLM 0.32.0์—์„œ ์‹คํ–‰ ํ™•์ธ
  • vLLM 0.32 ์„ค์น˜ ์กฐ๊ฑด: Python 3.11~3.14, torch 2.13(CUDA 13.0 ๋นŒ๋“œ, CUDA 13 ์ง€์› ๋“œ๋ผ์ด๋ฒ„ ํ•„์š”), transformers 5.16.1 ์ด์ƒ 5.20 ๋ฏธ๋งŒ, compressed-tensors 0.17.0 โ€” transformersยทcompressed-tensors๋Š” vLLM์ด ๋ฒ„์ „์„ ๊ณ ์ •ํ•˜๋ฏ€๋กœ compressed-tensors๋ฅผ ๋”ฐ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜์ง€ ๋ง ๊ฒƒ (์ด ์ฒดํฌํฌ์ธํŠธ๋Š” 0.19.0์œผ๋กœ ์ €์žฅ๋์ง€๋งŒ 0.17.0์—์„œ๋„ ๋กœ๋“œ๋จ)
  • GPU: NVIDIA Turing(sm75, ์˜ˆ: T4) ์ด์ƒ, V100(sm70) ๋ฏธ์ง€์› โ€” FP8 ์—ฐ์‚ฐ์€ AdaยทHopperยทBlackwell(sm89 ์ด์ƒ)์—์„œ ์ˆ˜ํ–‰, TuringยทAmpere๋Š” vLLM์ด ๊ฐ€์ค‘์น˜ ์ „์šฉ FP8๋กœ ์ž๋™ ์ „ํ™˜ (GPU๋ณ„ ์ง€์› ์—ฌ๋ถ€๋Š” vLLM 0.32 ์ปค๋„ ์„ ํƒ ์ฝ”๋“œ ๊ธฐ์ค€, ์‹ค์ œ ์‹คํ–‰์€ B200์—์„œ๋งŒ ํ™•์ธ)
  • ๋ฉ”๋ชจ๋ฆฌ: ๊ฐ€์ค‘์น˜ 2.2 GB + KV ์บ์‹œ(์ปจํ…์ŠคํŠธ ๊ธธ์ด ร— ๋™์‹œ ์š”์ฒญ ์ˆ˜์— ๋น„๋ก€) + ํ™œ์„ฑํ™”ยทCUDA graph์šฉ ์ˆ˜ GB โ€” GPU ํ•œ ์žฅ์— ๋‹ค ๋“ค์–ด๊ฐ€์ง€ ์•Š์œผ๋ฉด --tensor-parallel-size N์œผ๋กœ ๋ถ„์‚ฐ
  • Transformers๋กœ ์ง์ ‘ ์‚ฌ์šฉ: transformers 5.1.0 ์ด์ƒ + compressed-tensors 0.15.0 ์ด์ƒ (ํ…์ŠคํŠธ ๊ฒฝ๋กœ๋งŒ ํ™•์ธ, ์ด๋ฏธ์ง€ ์ž…๋ ฅ์€ ์‹คํ–‰ ๋ฏธํ™•์ธ)
  • trust_remote_code: ๋ถˆํ•„์š”

์‚ฌ์šฉ๋ฒ•

  • ์„œ๋ฒ„ ์‹คํ–‰: vllm serve axteam/GLM-OCR-FP8-dynamic --max-model-len 32768 โ€” OpenAI ํ˜ธํ™˜ API
  • Python: LLM(model="axteam/GLM-OCR-FP8-dynamic", max_model_len=32768).chat(...) โ€” ์ „์ฒด ์˜ˆ์‹œ๋Š” ์œ„ ์˜์–ด ๋ณธ๋ฌธ 'Usage (vLLM)' ์ ˆ ์ฐธ๊ณ 
  • thinking ๋ชจ๋“œ: ๊ธฐ๋ณธ ์ผœ์ง โ€” ๋„๋ ค๋ฉด chat_template_kwargs={"enable_thinking": False} ์ „๋‹ฌ(Python์€ llm.chat() ์ธ์ž, HTTP๋Š” ์š”์ฒญ ๋ณธ๋ฌธ์˜ "chat_template_kwargs": {"enable_thinking": false})
  • ์ด๋ฏธ์ง€ ์ž…๋ ฅ: ๋ฉ”์‹œ์ง€์— image_url ํ•ญ๋ชฉ ์‚ฌ์šฉ
  • OCR ํ”„๋กฌํ”„ํŠธ: ํ‘œยท์ˆ˜์‹ยท๋ ˆ์ด์•„์›ƒ ๋“ฑ ์ž‘์—…๋ณ„ ํ”„๋กฌํ”„ํŠธ๋Š” ์›๋ณธ ์นด๋“œ ์ฐธ๊ณ 
  • KV ์บ์‹œ ์ ˆ๊ฐ(์„ ํƒ): vllm serve์— --kv-cache-dtype fp8 ์ถ”๊ฐ€ โ€” ๊ธฐ๋ณธ BF16์ธ KV ์บ์‹œ๋ฅผ FP8๋กœ ์ €์žฅํ•ด KV ์บ์‹œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์•ฝ ์ ˆ๋ฐ˜์œผ๋กœ ์ค„์ž„ (๊ธด ์ปจํ…์ŠคํŠธยท๋™์‹œ ์š”์ฒญ์ด ๋งŽ์„ ๋•Œ ์œ ๋ฆฌ, ๊ฐ€์ค‘์น˜ ์–‘์žํ™”์™€ ๋ณ„๊ฐœ์ธ ์‹คํ–‰ ์˜ต์…˜)

๋ผ์ด์„ ์Šค

  • ๋ผ์ด์„ ์Šค: MIT โ€” ์›๋ณธ ๋ชจ๋ธ์˜ ๋ผ์ด์„ ์Šค๋ฅผ ๊ทธ๋Œ€๋กœ ๋”ฐ๋ฆ„
  • ๊ถŒ๋ฆฌ: ์›๋ณธ ๊ฐ€์ค‘์น˜ยทprocessor๋Š” Z.ai ์†Œ์œ , ์ด ๋ฆฌํฌ๋Š” ์–‘์žํ™” ํŒŒ์ƒ๋ฌผ
Downloads last month
78
Safetensors
Model size
1B params
Tensor type
BF16
ยท
F8_E4M3
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for axteam/GLM-OCR-FP8-dynamic

Base model

zai-org/GLM-OCR
Quantized
(40)
this model

Collection including axteam/GLM-OCR-FP8-dynamic