Nodes/Concept Steer/Train Lens (Few-Shot)
ComfyUI Node

Train Lens (Few-Shot)

Train a concept lens from example images. Three modes: • Contrastive (default): SigLIP embeddings + contrastive optimization • VL Caption: A VL model captions images → native text-encoder training (best) • Centroid: Simple mean difference (fast but weak)

By Nynxz·Created 5 months ago·Updated 5 months ago· 4
Train Lens (Few-Shot)
    • lens_path
    concept_namemy_concept
    positive_dir
    negative_dir
    targetzimage
    methodcontrastive
    contrastive_steps500
    vl_model
    encoder_path
    transcoder_repo
    output_dir
    protect_existingtrue
    CategoryConcept Steer

    Inputs (11)

    NameTypeDefaultDescription
    concept_nameSTRINGmy_conceptName for the concept (used in filename)
    positive_dirSTRINGAbsolute path to directory of images embodying the concept. Minimum 2 images required. Supports jpg, png, webp.
    negative_dirSTRINGOptional: directory of images WITHOUT the concept. Strongly recommended for contrastive mode. Leave empty to use origin as contrast.
    targetCOMBOzimageTarget model. 'zimage' = Qwen 3.4B (2560d), 'sd15' = SigLIP (768d).
    methodCOMBOcontrastiveTraining method: • contrastive: SigLIP embeddings + paired margin optimization (recommended) • vl_caption: VL model captions → native text-encoder training (best quality, needs VL model) • centroid: Simple mean difference (fast but weak)
    contrastive_stepsINT500100–5000Contrastive optimization steps (more = better but slower)
    vl_modelSTRINGVL model for captioning (only used in vl_caption mode). Leave empty to auto-detect. Examples: • Qwen/Qwen2.5-VL-7B-Instruct (best, ~8GB VRAM) • Qwen/Qwen2.5-VL-3B-Instruct (good, ~4GB VRAM) • microsoft/Florence-2-large (light, ~1.5GB)
    encoder_pathSTRINGPath to Qwen 3.4B safetensors file (for zimage target). Leave empty to auto-detect from ComfyUI model paths.
    transcoder_repoSTRINGHuggingFace repo for pretrained transcoders (e.g. 'mwhanna/qwen3-4b-transcoders'). When set with VL caption mode, captions are decomposed through 163,840 monosemantic transcoder features for much better concept isolation. Only supported for zimage target.
    output_dirSTRINGOverride output directory for the lens file
    protect_existingBOOLEANtrueIf the output lens file already exists, save as _v2, _v3, … instead of overwriting. Disable only when intentionally replacing.

    Outputs (1)

    NameTypeDescription
    lens_pathSTRING