Nodes/Qwen2.5-VL GGUF Nodes/🔤 OCR Prompt Builder
ComfyUI Node

🔤 OCR Prompt Builder

Make a vision model read your screenshots like it means it

By walke2019·Created 11 months ago·Updated about a month ago· 32
🔤 OCR Prompt Builder
    • prompt
    language原文
    output_format按行

    If you've ever watched a vision model "read" a receipt and confidently produce text that wasn't there, you know why OCR needs its own prompt builder instead of a casual "what does this say". OCR Prompt Builder generates a structured text-recognition instruction for the VLM in this pack, tuned for the thing Qwen2.5-VL is actually good at: reading text that's physically in the image, in order, without inventing letters.

    It's another pure string-builder node - no model loading, no network. You pick two things and get a ready-made OCR prompt out the prompt STRING port, which you then feed into the custom_prompt of Remote VLM Business Task or a local/remote analysis node. That's the whole workflow, and it's a good one for turning a pile of screenshots, scans, or product shots into machine-readable text.

    The two inputs that matter

    • language - 中文, English, or 原文 (original). The 原文 option is the interesting one: it tells the model to output text in whatever language it finds in the image, rather than forcing a translation. That's what you want when your images are mixed-language, like a folder of international product labels.
    • output_format - 按行 (line by line), 表格 (table), or JSON. Line-by-line preserves reading order, which matters for receipts and paragraphs. JSON gives you structured output you can shove straight into JSON Result Validator. Table is for grids and columns.

    The template in utils/business_prompts.py does one thing you'll appreciate: it tells the model to mark characters it can't be sure about with [?] instead of guessing. That's the difference between OCR you can trust and OCR that silently corrupts a part number.

    Where people get burned

    The classic failure isn't the prompt - it's the model. Low quant levels (Q4 and below) noticeably hurt small-text reading; if your OCR is mangling fine print, try Q8 or a remote model before you blame the builder. And the other classic is the model "cleaning up" the text: it reads "l0gin" as "login" because it's pattern-matching English. The template pushes for verbatim transcription, but a strong model will still autocorrect. If you need byte-exact output, say so in a custom prompt layered on top of this one.

    Also worth knowing: the enum labels are Chinese. 按行 is line-by-line, 表格 is table, 原文 is original-language. The author's defaults are sensible - 原文 + 按行 is a solid starting point for almost everything.

    Install

    Same as the whole pack - it's one custom node repo:

    cd ComfyUI/custom_nodes
    git clone https://github.com/walke2019/ComfyUI-GGUF-VLM.git
    cd ComfyUI-GGUF-VLM
    pip install -r requirements.txt
    

    Then restart ComfyUI. Manager users can search the pack title instead. OCR Prompt Builder itself only needs the repo's utils, so it'll run even if you've skipped the heavy model dependencies.

    Troubleshooting

    If the output ignores your format request - you asked for JSON and got prose - check that you're actually feeding the generated prompt into the node's custom_prompt and that you haven't left a competing default prompt in place. If the model is in a workflow where another node overwrote the system prompt, that can also flatten your instruction. OCR is one of those tasks where a garbage-in-garbage-out loop is easy to miss: verify on a single test image with known text before you run a batch of a thousand.

    Category🤖 GGUF-VLM/🚀 Business

    Inputs (2)

    NameTypeDefaultDescription
    languageCOMBO原文3 options: 中文, English, 原文
    output_formatCOMBO按行3 options: 按行, 表格, JSON

    Outputs (1)

    NameTypeDescription
    promptSTRING