Nodes/ComfyUI-HY-MT1.5/HY-MT Translator
ComfyUI Node

HY-MT Translator

Translate 33 Languages Inside ComfyUI — No API, No Key, No Cloud

By starsFriday·Created 10 months ago·Updated 5 months ago· 1
HY-MT Translator
  • model
  • translation
◄text►
◄target_languageen | 英语►
◄max_new_tokens512►
◄temperature0.70►
◄top_p0.60►
◄top_k20►
◄repetition_penalty1.05►

The HY-MT Translator is the actual translator in this pack - the node that takes your text, runs it through Tencent's local Hunyuan Translation model, and returns a clean string. No API to sign up for, no key to paste, no text leaving your machine. If you've ever wanted translation inside a ComfyUI workflow rather than bouncing out to Google Translate or an LLM API, this is the thing.

The name is a bit of a lie, by the way: the pack is called ComfyUI-HY-MT1.5, but the real star these days is Hy-MT2-1.8B, Tencent's "pocket-sized" 33-language translation model. The Translator handles both the newer Hy-MT2 weights and legacy HY-MT1.5 checkpoints. It's a fork of Tencent's official HY-MT repo, adapted into a ComfyUI node by starsFriday.

How it works

Under the hood it's a small language model doing a narrow job, which is exactly the pattern that works well in this ecosystem. It builds a prompt from Tencent's official templates - a Chinese template when your source text contains CJK characters or your target is Chinese/Traditional Chinese/Cantonese, an English template otherwise - then applies the model's chat template, generates, and returns only the new tokens after the prompt.

That last bit matters more than it looks. A raw LLM answer comes wrapped in chat scaffolding ("Here is your translation:") that would pollute anything you feed downstream. This node strips all of it and hands you just the translation string, so whatever you wire it into gets clean text.

The inputs that matter

  • text - a multiline box for your source text. Empty text raises an error, so feed it something real.
  • target_language - a dropdown of 38 languages, each labeled as code | native name (so en | 英语, zh | 中文, ja | 日语, and so on). The default is English. This is the one you'll change constantly.

The optional model input takes the handle from the HY-MT Loader. Leave it empty and the Translator auto-loads the first model it finds - convenient, but you don't get to choose which one. If you have both Hy-MT2 and a legacy HY-MT1.5 installed and you care which is used, wire the Loader in.

The rest are sampling knobs with sensible defaults: max_new_tokens (512, hard-capped at 4096), temperature (0.7), top_p (0.6), top_k (20), repetition_penalty (1.05). Leave them alone until something's wrong.

Output: a single translation string, ready for any text input - a CLIP text encode for prompt translation, a caption pipeline, or just a preview box to read the result.

Installing it

Same pack as the Loader, so one install covers both. ComfyUI Manager: search ComfyUI-HY-MT. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/starsFriday/ComfyUI-HY-MT1.5

Restart ComfyUI. The code leans only on transformers and torch - both already in a working ComfyUI - with the README's warning that Hy-MT2 wants transformers>=5.6.0. The real download is the weights: put Hy-MT2-1.8B under models/Hy-MT2-1.8B/ or a legacy checkpoint under models/HY-MT1.5/<name>/. A 1.8B model is a few GB and runs comfortably on 8GB-class cards.

Common issues

  • First translation is slow. That's the model loading. Wire up the Loader to pre-load it and see exactly when it happens; subsequent runs are cached and fast.
  • Long text gets cut off. Raise max_new_tokens (up to 4096). Longer generations cost more VRAM and time - stay inside your GPU's limits, as the README puts it.
  • Output repeats or loops. Nudge repetition_penalty up from 1.05.
  • Hy-MT2 fails to load. Check the transformers version first - older releases may not support the model's code.

A couple of honest caveats. This pack is a small side project with a thin community footprint, so don't expect heavy support. And before you ship a product around it, remember Tencent's models ship under the Tencent Community License - read the license file on the HuggingFace model card for the version you use, because the territorial terms have bitten people before. For personal workflow use - translating prompts between Chinese and English, captioning batches, keeping everything local and free per call - it's quietly excellent.

CategoryHY-MT

Inputs (8)

NameTypeDefaultDescription
textSTRING—
target_languageCOMBOen | 英语38 options: zh | 中文, zh-Hant | 繁体中文, yue | 粤语, en | 英语, fr | 法语, pt | 葡萄牙语, +32
modeloptHYMT_MODEL—
max_new_tokensoptINT5121–4096—
temperatureoptFLOAT0.700–2—
top_poptFLOAT0.600–1—
top_koptINT201–100—
repetition_penaltyoptFLOAT1.050.5–2—

Outputs (1)

NameTypeDescription
translationSTRING—