Nodes/ComfyUI-PromptWrapper/Prompt Translation
ComfyUI Node

Prompt Translation

Translate prompts locally with Helsinki-NLP opus-mt — no API key, no cloud

By clouddreamfly·Created about a year ago·Updated 8 months ago· 4
Prompt Translation
    • text
    model_name
    promptA beautiful photo of

    The pack this node lives in is, at heart, a translation tool - its Chinese README leads with "ComfyUI 提示翻译" (prompt translation), and the English-speaking community has barely noticed. Prompt Translation is the straightforward version: you hand it text in Chinese or English, it hands back a translated prompt, and the whole thing runs locally through a Helsinki-NLP opus-mt model on your own GPU or CPU. No API key, no data leaving your machine. That's the appeal, and it's the only genuinely model-dependent node family in ComfyUI-PromptWrapper - everything else in the pack is pure Python.

    How it works

    Pick one of three models and the node loads it from ComfyUI/models/nlp/<model_name>, then runs a Hugging Face translation pipeline (AutoTokenizer + AutoModelForSeq2SeqLM, GPU if torch.cuda.is_available(), else CPU). The three options:

    • Helsinki-NLP/opus-mt-zh-en - Chinese → English, small and fast.
    • Helsinki-NLP/opus-mt-en-zh - English → Chinese.
    • Helsinki-NLP/opus-mt-tc-bible-big-zhx-en - the "bible-big" variant, a beefier Chinese → English model that handles traditional characters and fuller sentences better.

    Output is the translated text string, ready to wire into a CLIP Text Encode or a Combine Prompt.

    Install and the model download (this is the actual install)

    The node itself comes with the pack via ComfyUI Manager (search ComfyUI-PromptWrapper) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/clouddreamfly/ComfyUI-PromptWrapper
    

    But the models are not auto-downloaded - that's the gotcha. You must create the folder under models/nlp/ and drop in the full model directory (config, tokenizer, pytorch_model.bin - everything):

    mkdir -p models/nlp/Helsinki-NLP/opus-mt-zh-en
    # then place all files from:
    # https://huggingface.co/Helsinki-NLP/opus-mt-zh-en/tree/main
    

    The README links the hf-mirror.com copies of all three models. It also needs transformers and torch, which a standard ComfyUI install already has - the pack's own requirements file is empty, so there's nothing extra to pip install.

    Where people get burned

    The classic failure is a hard ValueError: "Local model not found at ... Please download the model and place it in the ComfyUI/models/nlp folder." The path in that error is exact - the folder must be named models/nlp/Helsinki-NLP/opus-mt-zh-en, matching the enum value byte-for-byte, or the node refuses to run. This "where do the opus-mt files go" confusion is a known community stumble - other workflows use the same model and people regularly ask where it lives. A second, quieter issue: opus-mt is an old seq2seq model from ~2020. It's fine for tag-style prompts but mangles long prose, and it only knows the languages its pair was trained for - it is not a general translator. For broad multilingual output, the pack's Prompt Translation HY node with Tencent's Hunyuan-MT is the bigger hammer, at the cost of a much heavier model download.

    CategoryPromptWrapper

    Inputs (2)

    NameTypeDefaultDescription
    model_nameCOMBO3 options: Helsinki-NLP/opus-mt-zh-en, Helsinki-NLP/opus-mt-en-zh, Helsinki-NLP/opus-mt-tc-bible-big-zhx-en
    promptSTRINGA beautiful photo of

    Outputs (1)

    NameTypeDescription
    textSTRING