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)
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)
| Name | Type | Default | Description |
|---|---|---|---|
| concept_name | STRING | my_concept | Name for the concept (used in filename) |
| positive_dir | STRING | Absolute path to directory of images embodying the concept. Minimum 2 images required. Supports jpg, png, webp. | |
| negative_dir | STRING | Optional: directory of images WITHOUT the concept. Strongly recommended for contrastive mode. Leave empty to use origin as contrast. | |
| target | COMBO | zimage | Target model. 'zimage' = Qwen 3.4B (2560d), 'sd15' = SigLIP (768d). |
| method | COMBO | contrastive | Training 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_steps | INT | 500100–5000 | Contrastive optimization steps (more = better but slower) |
| vl_model | STRING | VL 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_path | STRING | Path to Qwen 3.4B safetensors file (for zimage target). Leave empty to auto-detect from ComfyUI model paths. | |
| transcoder_repo | STRING | HuggingFace 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_dir | STRING | Override output directory for the lens file | |
| protect_existing | BOOLEAN | true | If the output lens file already exists, save as _v2, _v3, … instead of overwriting. Disable only when intentionally replacing. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| lens_path | STRING | — |