{"_id":"697c3275cfe73b577d4da916","id":"zai-org/GLM-OCR","private":false,"pipeline_tag":"image-text-to-text","library_name":"transformers","tags":["transformers","safetensors","glm_ocr","image-text-to-text","conversational","zh","en","fr","es","ru","de","ja","ko","arxiv:2603.10910","license:mit","eval-results","endpoints_compatible","deploy:azure","deploy:sagemaker","region:us"],"downloads":1956836,"likes":2024,"modelId":"zai-org/GLM-OCR","author":"zai-org","sha":"ca5d8b3e287e52589e37c28385d9655ee4372f9d","lastModified":"2026-05-19T12:28:43.000Z","gated":false,"disabled":false,"model-index":null,"config":{"architectures":["GlmOcrForConditionalGeneration"],"model_type":"glm_ocr","tokenizer_config":{"eos_token":"<|endoftext|>","pad_token":"<|endoftext|>"},"chat_template_jinja":"[gMASK]<sop>\n{%- if tools -%}\n<|system|>\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{% for tool in tools %}\n{{ tool | tojson(ensure_ascii=False) }}\n{% endfor %}\n</tools>\n\nFor each function call, output the function name and arguments within the following XML format:\n<tool_call>{function-name}\n<arg_key>{arg-key-1}</arg_key>\n<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>{%- endif -%}\n{%- macro visible_text(content) -%}\n    {%- if content is string -%}\n        {{- content }}\n    {%- elif content is iterable and content is not mapping -%}\n        {%- for item in content -%}\n            {%- if item is mapping and item.type == 'text' -%}\n                {{- item.text }}\n            {%- elif item is mapping and (item.type == 'image' or 'image' in item) -%}\n                <|begin_of_image|><|image|><|end_of_image|>\n            {%- elif item is mapping and (item.type == 'video' or 'video' in item) -%}\n                <|begin_of_video|><|video|><|end_of_video|>\n            {%- elif item is string -%}\n                {{- item }}\n            {%- endif -%}\n        {%- endfor -%}\n    {%- else -%}\n        {{- content }}\n    {%- endif -%}\n{%- endmacro -%}\n{%- set ns = namespace(last_user_index=-1) %}\n{%- for m in messages %}\n    {%- if m.role == 'user' %}\n        {% set ns.last_user_index = loop.index0 -%}\n    {%- endif %}\n{%- endfor %}\n{% for m in messages %}\n{%- if m.role == 'user' -%}<|user|>\n{% if m.content is string %}\n{{ m.content }}\n{%- else %}\n{%- for item in m.content %}\n{% if item.type == 'video' or 'video' in item %}\n<|begin_of_video|><|video|><|end_of_video|>{% elif item.type == 'image' or 'image' in item %}\n<|begin_of_image|><|image|><|end_of_image|>{% elif item.type == 'text' %}\n{{ item.text }}\n{%- endif %}\n{%- endfor %}\n{%- endif %}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith(\"/nothink\")) else '' -}}\n{%- elif m.role == 'assistant' -%}\n<|assistant|>\n{%- set reasoning_content = '' %}\n{%- set content = visible_text(m.content) %}\n{%- if m.reasoning_content is string %}\n    {%- set reasoning_content = m.reasoning_content %}\n{%- else %}\n    {%- if '</think>' in content %}\n        {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n        {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n    {%- endif %}\n{%- endif %}\n{%- if loop.index0 > ns.last_user_index and reasoning_content -%}\n{{ '\\n<think>' + reasoning_content.strip() +  '</think>'}}\n{%- else -%}\n{{ '\\n<think></think>' }}\n{%- endif -%}\n{%- if content.strip() -%}\n{{ '\\n' + content.strip() }}\n{%- endif -%}\n{% if m.tool_calls %}\n{% for tc in m.tool_calls %}\n{%- if tc.function %}\n    {%- set tc = tc.function %}\n{%- endif %}\n{{ '\\n<tool_call>' + tc.name }}\n{% set _args = tc.arguments %}\n{% for k, v in _args.items() %}\n<arg_key>{{ k }}</arg_key>\n<arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>\n{% endfor %}\n</tool_call>{% endfor %}\n{% endif %}\n{%- elif m.role == 'tool' -%}\n{%- if m.content is string -%}\n{%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n    {{- '<|observation|>' }}\n{%- endif %}\n{{- '\\n<tool_response>\\n' }}\n{{- m.content }}\n{{- '\\n</tool_response>' }}\n{% elif m.content is iterable and m.content is not mapping %}\n{%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n{{- '<|observation|>' }}\n{%- endif %}\n{{- '\\n<tool_response>\\n' }}\n{%- for tr in m.content -%}\n  {%- if tr is mapping and tr.type is defined -%}\n    {%- set t = tr.type | lower -%}\n    {%- if t == 'text' and tr.text is defined -%}\n{{ tr.text }}\n    {%- elif t in ['image', 'image_url'] -%}\n<|begin_of_image|><|image|><|end_of_image|>\n    {%- elif t in ['video', 'video_url'] -%}\n<|begin_of_video|><|video|><|end_of_video|>\n    {%- else -%}\n{{ tr | tojson(ensure_ascii=False) }}\n    {%- endif -%}\n  {%- else -%}\n{{ tr.output if tr.output is defined else tr }}\n  {%- endif -%}\n{%- endfor -%}\n{{- '\\n</tool_response>' }}\n{%- else -%}\n<|observation|>{% for tr in m.content %}\n\n<tool_response>\n{{ tr.output if tr.output is defined else tr }}\n</tool_response>{% endfor -%}\n{% endif -%}\n{%- elif m.role == 'system' -%}\n<|system|>\n{{ visible_text(m.content) }}\n{%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n<|assistant|>\n{{'<think></think>\\n' if (enable_thinking is defined and not enable_thinking) else ''}}\n{%- endif -%}\n"},"cardData":{"license":"mit","language":["zh","en","fr","es","ru","de","ja","ko"],"library_name":"transformers"},"transformersInfo":{"auto_model":"AutoModelForMultimodalLM","pipeline_tag":"image-text-to-text","processor":"AutoTokenizer"},"siblings":[{"rfilename":".eval_results/mdpbench.yaml"},{"rfilename":".eval_results/olmocrbench.yaml"},{"rfilename":".gitattributes"},{"rfilename":"README.md"},{"rfilename":"chat_template.jinja"},{"rfilename":"config.json"},{"rfilename":"generation_config.json"},{"rfilename":"model.safetensors"},{"rfilename":"preprocessor_config.json"},{"rfilename":"tokenizer.json"},{"rfilename":"tokenizer_config.json"}],"spaces":["prithivMLmods/GLM-OCR-Demo","finebooks/bhl-ocr-leaderboard","eduagarcia/multilingual-tokenizer-leaderboard","valira-ai/slo-ocr-benchmark","Donyking1818/demo-glm-ocr","Chunte/Top-Downloaded-Trending-Models","mcikalmerdeka/vlms-ocr-playground","helloya20/demo-glm-ocr","lipeiying/GLM-OCR","PeterIP2023/Demo","thesatyamxyz/OCR-DEMO","Tonic/ocr-ebola","sanidhya1910/doc-agent","twoimo/glm-ocr-demo","notiv/demo-glm-ocr","Bruhn/GLM-OCR-Demo","praveenchola/OCR","praveenchola/GLM-OCR","codexxx/GLM-OCR-Demo","priyal261202gm/GLM-OCR-Demo","zz2232/UniversalOcrApp","kolar0/GLM-OCR-Demo","shunda012/sejarah-rag-fastapi","WebashalarForML/demo-glm-ocr","tanakorn123456/Image-to-text-2","tanakorn123456/test-andre","ranbac/TTQ","cafierom/OCR","Pitchaphat/assignment_6","ruangkhowza/assignment6","rehan953/glm-ocr-fixed","SimpleCodeAI/glm-ocr-fixed","nicolet8/GLM-OCR-Demo","Sujana123/testing-image","singhankit16/GLM-OCR-Studio","taoboy03/zai-org-GLM-OCR","iqAli/zai-org-GLM-OCR","Shubhvedi/zai-org-GLM-OCR","VashuTheGreat2/Multi-Rag","novammerce/glm-ocr","WebashalarForML/glm-ocr-v1","WebAshlarWA/glm-ocr-v1","adityamaurya09/project02","nina1231/OCR-Image-extraction","tonyliu404/Manglify_Backend","Enzzozink/zai-org-GLM-OCR","awww29/zai-org-GLM-OCR","khac-tuong-222/bom","sachinjat2802/zai-org-GLM-OCR","khac-tuong-222/ocr","Jacob0037/zai-org-GLM-OCR","mafiagaming8/table-top-glm","abhidev77/GLM-OCR-Demo","pawanmau01/GLM-OCR-Demo","E-will-era/easy-welfare-guide","adityamaurya09/zai-org-GLM-OCR","pk2302/zai-org-GLM-OCR","SilanLee/imagetotext","anibalin/glm-ocr-extraction","Pxeim/GLM-OCR-361","shambhuDATA/glmocr","shubhjn/whisper-ai","nomco/GLM-OCR-Demo","yuukicammy/kuzushiji-ocr","shubhjn/cosmo-ai","tabishm/zai-org-GLM-OCR","Nick-2x/Lab_report_analysis","Kaushik0909/zai-org-GLM-OCR","anandpasupuleti/evaluate-pipeline","hsshenxi/zai-org-GLM-OCR","hsshenxi/GLM-OCR-Demo","Sam20202/GLMOCR_Text_extraction","eoeooe/GLM-OCR-Demo2","Yous135774/Ocr","paridashub/OCR_Runner","theuntoldcreator/UTC-org-GLM-OCR","arthur0leywin/OCR","pranaysuyash/shopstack","pranavnairop/ocr-pipeline","LuxeFats/pdf-to-markdown","ayush1369/zai-org-GLM-OCR","Ankitkumar8987/GLM-OCR-Pipeline","Dlcastro/glm-ocr-demo","ARAX2/zai-org-GLM-OCR","muzz16/zai-org-GLM-OCR","Aamir1412/zai-org-GLM-OCR","NuttyFlash/flash-ocr-demoo","Hasmukh/dox-engine-glm-ocr","Arun0914/arabic-ocr-glm","elsory/baseer-engines","GF-John/svlm-council","pavel00002013/GLM_ORG","velakart/soa"],"createdAt":"2026-01-30T04:24:21.000Z","safetensors":{"parameters":{"BF16":1325258240},"total":1325258240},"usedStorage":2650754336}