Extensions/ComfyUI_Tencent_hunyuan_MT
ComfyUI Extension

ComfyUI_Tencent_hunyuan_MT

使用腾讯混元MT模型的轻量化本地翻译节点

By idealisticABO·Created 4 months ago·Updated about a month ago· 1
idealisticABO/ComfyUI_Tencent_hunyuan_MT
Nodes
On cloudLocal install
Stars1
Updatedabout a month ago
Readme

ComfyUI_Tencent_hunyuan_MT

English | 中文


中文

ComfyUI 自定义节点,使用本地腾讯 Hunyuan / HY-MT 模型进行翻译。

功能特性

  • 在 ComfyUI 内部完成本地翻译,无需连接 Ollama 或外部 API。
  • 支持腾讯 Hunyuan / HY-MT 系列翻译模型。
  • 支持从 ModelScope 或 HuggingFace 自动下载模型。
  • 模型分片完整性校验,自动识别损坏或不完整的下载。
  • 支持下载超时设置。
  • 自动分段翻译:输入超长时按段落/句子拆分,避免超出模型上下文窗口。
  • 节点界面已中文化。

支持的模型

  • HY-MT1.5-1.8B-FP8(推荐)
  • HY-MT1.5-1.8B
  • HY-MT1.5-7B-FP8
  • Hunyuan-MT-7B-fp8

注意:GGUF、GPTQ、AngelSlim 1.25bit 等量化模型目前不被内置 Transformers 后端支持。

安装

将仓库克隆到 ComfyUI 的 custom_nodes 目录:

cd ComfyUI/custom_nodes
git clone https://github.com/idealisticABO/ComfyUI_Tencent_hunyuan_MT.git

进入目录并安装依赖:

cd ComfyUI_Tencent_hunyuan_MT
python -m pip install -r requirements.txt

请确保使用 ComfyUI 实际运行的 Python 环境执行上述命令。

使用方法

  1. 重启 ComfyUI。
  2. 在节点列表中找到 腾讯混元机器翻译(Tencent Hunyuan MT Translate)。
  3. 在节点中选择模型、目标语言,输入待翻译文本。
  4. 首次使用时会自动下载模型,默认保存到 ComfyUI/models/llm_translate/

参数说明

| 参数 | 说明 | 默认值 | |---|---|---| | 文本 | 待翻译文本 | - | | 模型 | 选择使用的模型 | HY-MT1.5-1.8B-FP8 | | 目标语言 | 选择翻译目标语言 | 中文 | | 最大新token数 | 模型每次最多生成多少个 token | 1024 | | 温度 | 采样温度,0 为贪心解码 | 0.7 | | top_p / top_k | 采样参数 | 0.6 / 20 | | 重复惩罚 | 降低重复内容 | 1.05 | | 数据类型 | 模型加载精度 | auto | | 下载源 | 模型下载来源 | ModelScope | | 下载超时_分钟 | 下载超时时间 | 30 | | 强制重新下载 | 删除旧模型并重新下载 | False | | 自动分段 | 超长文本自动分段翻译 | True | | 按句子分段 | 每句话单独翻译 | False | | 自定义目标语言 | 覆盖默认目标语言 | 空 |

自动分段说明

  • 当输入文本长度加上生成长度接近或超过模型上下文窗口时,节点会自动将文本拆分成多个小块分别翻译。
  • 默认按段落拆分,段落超长时按句子组合。
  • 打开 按句子分段 后,每个句子都会单独翻译,适合需要逐句精确控制的场景。

常见问题

模型下载失败怎么办?

尝试切换下载源(ModelScope / HuggingFace),或打开 强制重新下载 重新下载。

翻译结果被截断?

增大 最大新token数

出现依赖错误?

请在 ComfyUI 实际使用的 Python 环境中安装:

python -m pip install -U transformers torch accelerate huggingface_hub safetensors modelscope compressed-tensors

English

A ComfyUI custom node for local translation using Tencent Hunyuan / HY-MT models.

Features

  • Local translation inside ComfyUI, no Ollama or external API server required.
  • Supports Tencent Hunyuan / HY-MT translation models.
  • Auto-download models from ModelScope or HuggingFace.
  • Model shard completeness check to detect corrupted or incomplete downloads.
  • Configurable download timeout.
  • Auto chunking: splits long input into paragraphs/sentences to fit the model context window.
  • Chinese UI labels.

Supported Models

  • HY-MT1.5-1.8B-FP8 (recommended)
  • HY-MT1.5-1.8B
  • HY-MT1.5-7B-FP8
  • Hunyuan-MT-7B-fp8

Note: GGUF, GPTQ, and AngelSlim 1.25bit quantized models are not supported by the built-in Transformers backend yet.

Installation

Clone this repository into your ComfyUI custom_nodes folder:

cd ComfyUI/custom_nodes
git clone https://github.com/idealisticABO/ComfyUI_Tencent_hunyuan_MT.git

Install dependencies:

cd ComfyUI_Tencent_hunyuan_MT
python -m pip install -r requirements.txt

Make sure to use the Python environment that ComfyUI actually runs on.

Usage

  1. Restart ComfyUI.
  2. Find the 腾讯混元机器翻译 (Tencent Hunyuan MT Translate) node in the node list.
  3. Select the model, target language, and enter the text to translate.
  4. The model will be downloaded automatically on first use to ComfyUI/models/llm_translate/ by default.

Parameters

| Parameter | Description | Default | |---|---|---| | 文本 (text) | Text to translate | - | | 模型 (model) | Model to use | HY-MT1.5-1.8B-FP8 | | 目标语言 (target language) | Target language | Chinese | | 最大新token数 (max_new_tokens) | Max tokens to generate per call | 1024 | | 温度 (temperature) | Sampling temperature, 0 for greedy | 0.7 | | top_p / top_k | Sampling parameters | 0.6 / 20 | | 重复惩罚 (repetition_penalty) | Penalty for repetition | 1.05 | | 数据类型 (dtype) | Model precision | auto | | 下载源 (download_source) | Where to download models | ModelScope | | 下载超时_分钟 (download_timeout_minutes) | Download timeout | 30 | | 强制重新下载 (force_redownload) | Delete and re-download model | False | | 自动分段 (auto_chunk) | Auto split long text | True | | 按句子分段 (sentence_chunk) | Translate each sentence separately | False | | 自定义目标语言 (custom_target_language) | Override target language | empty |

Auto Chunking

  • When the input plus generation length approaches the model's context window, the node automatically splits the text into smaller chunks.
  • By default it splits by paragraph; if a paragraph is too long it splits by sentences.
  • Enable 按句子分段 (sentence_chunk) to translate each sentence individually, useful for fine-grained control.

FAQ

Download failed?

Try switching the download source (ModelScope / HuggingFace) or enable 强制重新下载 (force_redownload).

Output truncated?

Increase 最大新token数 (max_new_tokens).

Dependency error?

Install dependencies in the Python environment used by ComfyUI:

python -m pip install -U transformers torch accelerate huggingface_hub safetensors modelscope compressed-tensors