Nodes/Index Translate · T8star-Aix/Index Translate 本地翻译
ComfyUI Node

Index Translate 本地翻译

A 2B translator living inside your ComfyUI graph

By T8mars·Created 22 days ago·Updated 16 days ago· 9
Index Translate 本地翻译
    • translation
    • metadata
    ◄text你好,世界。►
    ◄model_pathIndex-Translate-2B►
    ◄sourceauto►
    ◄targeten►
    ◄device▾►
    ◄precision▾►
    ◄output_budget1024►
    ◄context_limit4096►
    ◄glossary{}►

    A translator that never phones home

    Most "translate" buttons in this ecosystem are an API call wearing a node's clothes. This one isn't. IndexTranslateText loads a real translation model on your machine and runs it inside the ComfyUI process. No key, no endpoint, no calls to the author's Windows bundle - the README says so and the code backs it up.

    The model is IndexTeam's Index-Translate (bilibili's Index org, of Index-AniSora fame), wrapped as a node by T8star-Aix, a Chinese-community workflow author you may know from OpenArt or YouTube. The same repo's Chrome extension and Windows bundle pair with a local service; the node ignores both.

    Why reach for it? A prompt is the one part of a workflow you can't fix in post. If you think in Chinese and your encoder thinks in English, or you're translating a foreign prompt, caption, or subtitle line, an offline translator in the graph is the "second LLM, small and obedient" pattern from the LLM-in-ComfyUI playbook: text in, text out, upstream of the sampler, free per call.

    How it actually works

    It's a Qwen3_5ForConditionalGeneration checkpoint loaded through Transformers with local_files_only=True, trust_remote_code=False and SDPA attention. Translation-tuned, not a general chat model - the node wraps your text in a fixed instruction ("translate into <language>, output only the translation"), applies the chat template with thinking disabled, and decodes greedily.

    It's deterministic. do_sample=False means no seed widget, no lottery. Same text, same model revision, same translation, every time.

    It frees the model after every run. release() runs in a finally block: collect, empty_cache(), and _cuda_clearCublasWorkspaces() so cuBLAS workspaces don't pin a memory segment. VRAM goes back to the diffusion model; the cost is a reload every execution - seconds for 2B, noticeably more for 9B. It's not a warm translation server; don't read the Windows bundle's cached latency as this node's speed.

    A module-level lock serializes translations, and IS_CHANGED hashes the model directory plus the vendored core files, so upgrading the pack re-runs the node instead of serving stale cached output. Truncation, an incomplete model folder, or a placeholder mismatch raises instead of returning half a translation.

    Inputs and outputs that matter

    text is the point - multiline, defaulting to 你好,世界。 source defaults to auto, target to en. Both take codes or plain names; auto/zh/en/ja/ko/de/fr/es/ru/ar/pt/it/vi/th/hi are recognized and anything else is passed to the model as written. Target can't be auto - it throws rather than guessing.

    model_path is a folder name inside ComfyUI/models/index_translate/, or a full absolute path.

    Leave device and precision on auto unless you know better: it picks CUDA with bf16 when free VRAM covers the weights plus ~2 GiB, otherwise CPU with fp32. The other two precisions are conditional - nf4 wants bitsandbytes and an NVIDIA card, convrot-int8 wants a quantized checkpoint and an extra install.

    output_budget (default 1024) and context_limit (default 4096) set your length ceiling: the budget must stay under context_limit - 64, and long input plus a generous budget overflows the context and errors. glossary is a JSON object of up to 100 pairs, injected into the instruction so your terms survive intact - {"Lora": "LoRA"}.

    translation is a plain STRING - wire it into any text input, or a PreviewAny / "Preview as Text" to read it. metadata is a JSON string with finish_reason, token counts, seconds, model_id, model_revision, device, precision and peak CUDA bytes - handy for logging.

    Installing it

    Manager users: search Index Translate · T8star-Aix. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/T8mars/Comfyui-Index-Translate-T8
    python -m pip install -r Comfyui-Index-Translate-T8/requirements.txt   # ComfyUI's own Python
    

    Restart, then drop a complete Index-Translate-2B (~4.24 GiB at bf16) or 9B folder as-is into ComfyUI/models/index_translate/. No renaming:

    python ComfyUI/custom_nodes/Comfyui-Index-Translate-T8/download_model.py \
      --directory ComfyUI/models/index_translate/Index-Translate-2B --model 2B
    

    It verifies per-file SHA256 hashes against a pinned catalog and resumes rather than half-installing. There's also an example workflow to drag onto the canvas.

    Where people get burned

    Use ComfyUI's Python, not yours. requirements.txt pins transformers==5.17.0, which the README admits can disturb other nodes on the host. It never touches torch - don't let pip replace that either. Skip the step and the error arrives in Chinese.

    The 35B preview is unsupported - its snapshot is missing shards. The node reports an incomplete model instead of failing somewhere deep in Transformers. Start with 2B.

    NF4 and INT8 are extra installs, not just dropdown entries. NF4 needs requirements-nf4.txt plus an NVIDIA GPU. ConvRot INT8 needs its own complete checkpoint directory (2.67 GB for 2B) and install_convrot.py run with ComfyUI's Python - it pins comfy-kitchen and drops cuBLAS wheels in a separate directory, leaving host torch alone. Back out by deleting index_translate_convrot.pth. Expect a 40–60 second first-compile wait on 2B; that's compilation, not inference.

    Wire the output to something. is_output_node is false, so with nothing downstream the node never executes and you'll sit there wondering why nothing happened. A Preview node costs nothing.

    CategoryIndex Translate

    Inputs (9)

    NameTypeDefaultDescription
    textSTRING你好,世界。—
    model_pathSTRINGIndex-Translate-2B—
    sourceSTRINGauto—
    targetSTRINGen—
    deviceCOMBO3 options: auto, cuda, cpu
    precisionCOMBO5 options: auto, bf16, fp32, nf4, convrot-int8
    output_budgetINT10241–32704—
    context_limitINT4096256–32768—
    glossaryoptSTRING{}—

    Outputs (2)

    NameTypeDescription
    translationSTRING—
    metadataSTRING—