Tao Finetune Clip 标志

Tao Finetune Clip

组织
NVIDIA-TAO
tao-finetune-clip

CLIP 视觉语言模型,支持图文检索、零样本分类、嵌入提取、ONNX 导出和 TensorRT 部署。微调或训练 CLIP、运行零样本分类、计算图像嵌入,或将 CLIP 部署到 ONNX/TensorRT 时使用。这是一个单次操作的模型技能;不要用于反复训练和评估、直到进展停滞的弱属性改进循环,此类任务应使用 tao-run-deft-pas。

Add to TypingMind

概览

发布者NVIDIA-TAO
代码仓库tao-skill-bank
技能名称tao-finetune-clip
星标数
98
复刻数
28
附带文件
21
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 21 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 NVIDIA-TAO 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Tao Finetune Clip AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/NVIDIA-TAO/tao-skill-bank/tree/main/skills/models/tao-finetune-clip
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/NVIDIA-TAO/tao-skill-bank.git /tmp/tao-skill-bank
mkdir -p .claude/skills
cp -r /tmp/tao-skill-bank/skills/models/tao-finetune-clip .claude/skills/tao-finetune-clip
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Tao Finetune Clip,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Tao Finetune Clip。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Tao Finetune Clip 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

CLIP

Standalone install? Read CLIP standalone setup and verify the bank checkout before running tao-setup or launching a CLIP action.

Contrastive Language-Image Pre-training model for zero-shot and fine-tuned image classification, image-text retrieval, and embedding extraction. Fine-tuning adapts CLIP's shared image-text embedding space to domain-specific image-caption data.

No default NGC pretrained checkpoint is required for spec construction, but unset checkpoint behavior is action-specific. In the validation-fixes PyTorch image, export.checkpoint: null exports the selected CLIP architecture and may initialize weights when pretrained weights are unavailable. Do not assume inference.checkpoint: null loads pretrained weights: clip inference currently calls the checkpoint loader with None and fails before embedding extraction. For PyTorch inference, checkpoint-backed evaluation/export, resume, and retrain flows, resolve and pass an exact checkpoint from the parent train output. For trusted TAO checkpoints produced by the current run or a known parent job, set TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 on checkpoint-dependent PyTorch actions so PyTorch 2.6 can load the Lightning checkpoint metadata; do not set this for untrusted checkpoints.

Supported actions: train, evaluate, inference, export, gen_trt_engine.

Train Action Policy

This model is AutoML-enabled at the model layer. Before handling any train-stage request, read references/skill_info.yaml and resolve the run override from either an explicit automl_policy value or the user's workflow request. Use automl_policy: on by default and only expose on / off in new launch prompts. Treat phrases like "turn off AutoML", "disable AutoML", "no HPO", or "plain training" as automl_policy: off for this run only. When automl_policy: on, automl_enabled: true, and both schemas/train.schema.json and references/spec_template_train.yaml are packaged, route the train action through tao-skill-bank:tao-run-automl by default with this model's skill_dir. Preserve workflow/application overrides for datasets, specs, output directories, GPU/platform settings, parent checkpoints, and automl_policy. Use direct model training only when automl_policy: off or the packaged train schema/template is missing; in the missing-schema case, report that AutoML is enabled but not runnable for this model until schemas are generated.

The packaged CLIP train schema enables train.optim.vision_lr and train.optim.text_lr as default AutoML search parameters. For smoke tests, keep the search small by using the Bayesian algorithm with two recommendations and narrow LR ranges.

PAS fine-tuning method integration

For every new PAS DEFT run, ask one mutually exclusive question when the user has not already chosen a method:

text
Fine-tuning method: LoRA (default) or full-parameter SFT?

This LoRA-default contract is scoped to PAS. Standalone CLIP training keeps its packaged SFT image and template behavior; it does not default to LoRA. Do not transfer PAS image capabilities or this selection table to standalone CLIP.

PAS methodEnableDisablePAS image support
full-parameter SFTset both encoder freeze flags to false and peft.enabled: falseselect LoRAsupported
LoRA (default selection)set peft.enabled: true, peft.method: lora, and nested vision/text adapter blocksset peft.enabled: false and use SFT settingssupported for SigLIP2; use targets q_proj, k_proj, v_proj, out_proj

An image capability probe is a launch-gated docker run, so include it in the approval summary before executing it. Documentation, an image tag, or an unrecognized Hydra override is not proof of LoRA support. If the probe does not expose a complete adapter contract (enable flag/config, target modules, rank, alpha, dropout, checkpoint behavior), report LoRA as unsupported for that image and stop before materializing a run.

Non-train actions such as evaluate, inference, export, and deploy flows stay in this model skill. The per-run automl_policy override does not change model metadata.

Instructions

Use this skill for NVIDIA TAO CLIP jobs: training, evaluation, embedding inference, ONNX export, and TensorRT engine generation. Start by identifying the requested action, then read references/skill_info.yaml for image, command, and data-source wiring; references/spec_template_<action>.yaml for packaged action defaults; and schemas/<action>.schema.json when packaged for parameter metadata. Use references/spec_template.yaml for the full spec shape and references/tao-deploy-clip.md for TensorRT actions.

For dataset-backed actions, collect the required image, caption, list, or prompt files from the user and place the resolved paths in spec_overrides. For local Docker runs, mount extracted folders in the container and point image_dir / caption_dir at those folders; if a data source provides .tar.gz archives, extract them before running the in-container CLIP commands. For export and gen_trt_engine, infer parent artifacts from the upstream job when available; otherwise require explicit checkpoint, ONNX, or engine paths. Run gen_trt_engine, TensorRT evaluate, and TensorRT inference in the TAO Deploy image.

For TAO Deploy TensorRT actions (gen_trt_engine, TensorRT evaluate, and TensorRT inference), read references/tao-deploy-clip.md first. Deploy spec templates live in this skill's references/ folder with the spec_template_deploy_*.yaml prefix.

Training Requirements

  • Dataset type: image_text
  • Formats: custom image/caption folders or WebDataset shards
  • Monitoring metric: val/t2i_mAP for paired-caption retrieval; val/pas/overall_mAP for PAS metadata matching

Before selecting a PAS AutoML objective or comparing training and evaluation, read PAS metric guidance. PAS validation logs val/pas/{easy,medium,hard,overall}_{mAP,rank1,rank5}; standalone PAS evaluate writes CSVs rather than test/* scalars. For a like-for-like comparison, use the same checkpoint and validation subset, set evaluate.pas_ground_truth_mode: scalar_attributes, and read nvidia_pas_metadata_metrics_weighted_aggregate.csv.

Supported Models

  • OpenCLIP / NV-CLIP: ViT-L-14-SigLIP-CLIPA-224 (default), ViT-L-14-SigLIP-CLIPA-336, ViT-H-14-SigLIP-CLIPA-224, ViT-H-14-SigLIP-CLIPA-336, ViT-H-14-SigLIP-CLIPA-574
  • Radio-CLIP: c-radio_v3-b, c-radio_v3-l, c-radio_v3-h, c-radio_v3-g
  • SigLIP2: siglip2-so400m-patch16-256, siglip2-so400m-patch14-224, siglip2-so400m-patch14-384, siglip2-so400m-patch16-384, siglip2-so400m-patch16-512, siglip2-so400m-patch16-naflex

Radio-CLIP requires model.adaptor_name to be set to siglip or clip.

Under the tower mode contract, OpenCLIP supports full / frozen, but rejects lora. See backbone support.

LoRA and preservation regularization

Before constructing a LoRA spec or PEFT AutoML search space, read CLIP PEFT guidance for per-tower fields, defaults, backbone target modules, numeric bounds, migration from tower enabled to mode, and encoder-freeze precedence. peft and regularization are top-level spec blocks; use the selected runtime's config contract.

With PEFT enabled under the tower mode contract, tower modes override model.freeze_*_encoder: frozen freezes the tower, full trains it, and lora trains adapters with the backbone frozen. Remove conflicting freeze flags and verify per-tower trainable-parameter counts.

LoRA checkpoints contain the full model; budget full-model storage. Preservation regularization adds a full frozen teacher on the GPU and a teacher forward pass. Keep regularization.enabled: false for recommended SigLIP2 PAS runs: preservation loss has not been fully validated there. The teacher is excluded from checkpoints.

Per-Action Dataset Requirements

ActionSpec KeySourceFilesList?
traindataset.train.datasetstrain_datasetsimage_dir: images.tar.gz, image_list_file: image_list.txt, caption_dir: captions.tar.gzYes
traindataset.train.wds.root_dirtrain_wds_datasetroot directory containing .tar shardsNo
traindataset.train.wds.shard_list_filetrain_wds_datasetshards.txt listing shard pathsNo
traindataset.val.datasetseval_datasetimage_dir: images.tar.gz, image_list_file: image_list.txt, caption_dir: captions.tar.gzYes
evaluatedataset.val.datasetseval_datasetimage_dir: images.tar.gz, image_list_file: image_list.txt, caption_dir: captions.tar.gzYes
inferenceinference.datasetsinference_datasetimage_dir: images.tar.gzYes
inferenceinference.text_fileinference_datasetprompts.txtNo
exportexport.checkpointparent train job or explicit checkpointcheckpoint .pth, optional for pretrained exportNo
gen_trt_enginegen_trt_engine.onnx_fileparent export job or explicit ONNXclip_model.onnxNo

For custom training, set dataset.train.type: custom and provide dataset.train.datasets entries. Image and caption files must share the same base name. caption_file_suffix defaults to .txt, and image_list_file is optional.

To run inference on a subset, place only the selected images in a separate directory and set inference.datasets[].image_dir to that directory.

When no native CLIP image-caption dataset is available, do not silently treat image-classification data as CLIP data. If the user explicitly allows a plumbing-only validation fallback, derive caption files from class labels, document that the captions are generated from labels, and keep each image/caption pair on the same base filename. Without an image_list_file, the TAO custom loader scans the configured image directory for image files; keep validation folders flat unless you provide a list file.

For WDS training, set dataset.train.type: wds and provide at least one of dataset.train.wds.root_dir or dataset.train.wds.shard_list_file. root_dir is scanned recursively for .tar shards. shard_list_file is a text file with one shard path per line; relative lines resolve under the list-file directory unless root_dir is also supplied, in which case they resolve under root_dir. Validation/evaluation data remains custom format via dataset.val.datasets.

Typical Spec Overrides

Data source overrides are mandatory for dataset-backed actions. Construct paths from the Per-Action Dataset Requirements table and include them in spec_overrides. For inference, provide at least one of inference.datasets or inference.text_file.

python
S3_TRAIN = "s3://bucket/data/train"
S3_WDS = "s3://bucket/data/wds"
S3_EVAL = "s3://bucket/data/eval"
S3_INFER = "s3://bucket/data/infer"

train, custom dataset:

python
{
    "train.num_epochs": 10,
    "dataset.train.type": "custom",
    "dataset.train.datasets": [{"image_dir": f"{S3_TRAIN}/images.tar.gz", "image_list_file": f"{S3_TRAIN}/image_list.txt", "caption_dir": f"{S3_TRAIN}/captions.tar.gz"}],
    "dataset.val.datasets": [{"image_dir": f"{S3_EVAL}/images.tar.gz", "image_list_file": f"{S3_EVAL}/image_list.txt", "caption_dir": f"{S3_EVAL}/captions.tar.gz"}],
}

train, WDS dataset:

python
{
    "train.num_epochs": 10,
    "dataset.train.type": "wds",
    "dataset.train.wds.root_dir": f"{S3_WDS}",
    "dataset.train.wds.shard_list_file": f"{S3_WDS}/shards.txt",
    "dataset.train.wds.samples_per_shard": 10000,
    "dataset.val.datasets": [{"image_dir": f"{S3_EVAL}/images.tar.gz", "image_list_file": f"{S3_EVAL}/image_list.txt", "caption_dir": f"{S3_EVAL}/captions.tar.gz"}],
}

evaluate:

python
{
    "dataset.val.datasets": [{"image_dir": f"{S3_EVAL}/images.tar.gz", "image_list_file": f"{S3_EVAL}/image_list.txt", "caption_dir": f"{S3_EVAL}/captions.tar.gz"}],
}

Leave evaluate.checkpoint unset for zero-shot evaluation with pretrained weights. Set evaluate.trt_engine instead of evaluate.checkpoint for TensorRT evaluation.

inference:

python
{
    "inference.datasets": [{"image_dir": f"{S3_INFER}/images.tar.gz"}],
    "inference.text_file": f"{S3_INFER}/prompts.txt",
}

Inference writes image_embeddings.h5 and/or text_embeddings.h5 under results_dir. The saved embeddings are L2-normalized.

export:

python
{
    "export.onnx_file": "${results_dir}/export/clip_model.onnx",
    "export.encoder_type": "combined",
    "export.batch_size": -1,
}

Set export.encoder_type: separate when deployment should use independent vision and text encoders. Separate export writes _vision.onnx and _text.onnx variants derived from the base export.onnx_file.

For checkpoint-dependent actions, use the model-specific checkpoint resolver output from the parent train job. CLIP training writes checkpoints such as model_epoch_000_step_00020.pth and a clip_latest.pth symlink. Use the exact resolved checkpoint for evaluate.checkpoint, inference.checkpoint, export.checkpoint, and train.resume_training_checkpoint_path; use clip_latest.pth only when the user explicitly asks for latest.

For LoRA checkpoints, preserve the training model settings and complete top-level peft block in PyTorch evaluate, inference, and export specs. Read checkpoint configuration before constructing those specs; action defaults alone omit PEFT.

When the resolved checkpoint is trusted TAO output, checkpoint-backed PyTorch evaluate, inference, export, and resume training should run with TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1. PyTorch 2.6 otherwise defaults checkpoint loading to weights-only mode and can reject CLIP Lightning checkpoints containing NumPy scalar metadata.

gen_trt_engine:

python
{
    "gen_trt_engine.onnx_file": "${results_dir}/export/clip_model.onnx",
    "gen_trt_engine.trt_engine": "${results_dir}/deploy/clip_model.engine",
    "gen_trt_engine.batch_size": -1,
    "gen_trt_engine.tensorrt.data_type": "fp16",
    "gen_trt_engine.tensorrt.min_batch_size": 1,
    "gen_trt_engine.tensorrt.opt_batch_size": 1,
    "gen_trt_engine.tensorrt.max_batch_size": 16,
}

Eval Dataset

Optional for training. If provided, validation metrics are computed at validation intervals. Required for evaluate.

Deploy Workflow

The skill exposes gen_trt_engine as the deploy action. In generated SDK runners, use model_info["actions"]["gen_trt_engine"] and run it in the TAO Deploy image, not the PyTorch training image. The in-container command is clip gen_trt_engine -e {config_path}; direct TAO Launcher usage spells the same action as tao deploy clip gen_trt_engine -e /path/to/spec.yaml.

TAO Deploy inference can discover combined engines, paired separate engines, or single-pillar _vision.engine / _text.engine files. For full TensorRT retrieval evaluation or image+text TensorRT inference, export with export.encoder_type: separate and run clip gen_trt_engine twice: build clip_model_vision.onnx to an engine ending in _vision.engine, then build clip_model_text.onnx to the matching _text.engine in the same directory. For image-only TensorRT inference, building only the _vision.engine is sufficient and inference.text_file must be null. TensorRT evaluate and text inference require a text-capable engine; if only a vision engine is present, deploy evaluation fails because text embeddings cannot be extracted.

Use evaluate.trt_engine for TensorRT evaluation and inference.trt_engine for TensorRT embedding extraction. These TensorRT paths also run in the TAO Deploy image. Direct TAO Launcher usage spells these as tao deploy clip evaluate and tao deploy clip inference.

Important Parameters

  • model.type: Backbone family and resolution. Use a TAO-registered CLIP model ID such as ViT-L-14-SigLIP-CLIPA-224. Prefer the listed OpenCLIP / NV-CLIP IDs for AutoML smoke tests because the current TAO container registry routes them through the supported augmentation adapter.
  • model.adaptor_name: Required for Radio-CLIP. Set to siglip or clip.
  • model.image_size: Training transform image resolution. Keep it aligned with the selected fixed-resolution backbone.
  • train.num_epochs: CLIP fine-tuning often converges quickly. Start with 10-20 epochs for domain adaptation, then increase only if validation loss is still improving.
  • train.optim.vision_lr / train.optim.text_lr: Learning rates for the two encoders. CLIP is sensitive to high learning rates; reduce both if loss is unstable.
  • model.freeze_vision_encoder / model.freeze_text_encoder: Defaults are false. These flags control encoder freezing when peft.enabled: false. With PEFT enabled under the tower mode contract, peft.vision.mode / peft.text.mode override them, even if they disagree: full trains the encoder, frozen freezes it, and lora trains adapters. See PEFT precedence and remove conflicting freeze flags.
  • train.loss_type: siglip is recommended for SigLIP2 and Radio-CLIP. Use clip for CLIP-style softmax loss.
  • export.encoder_type: combined exports one ONNX graph. separate exports independent vision and text graphs.
  • gen_trt_engine.tensorrt.data_type: TensorRT deployment supports fp16 and fp32.

Hardware

Single-GPU training works for small datasets. Use 4+ GPUs for datasets with more than 100k images or large backbones. Use 16GB+ VRAM per GPU for small/fixed-resolution runs with preservation regularization disabled and larger GPUs for Radio-CLIP or high-resolution OpenCLIP variants.

The 16GB+ guidance does not account for the additional full teacher model created by regularization.enabled: true. If testing regularization, budget VRAM for that second model and its forward-pass intermediates, measure peak memory and step time for the actual backbone and batch size, and reduce dataset.train.batch_size or use a larger GPU as needed. Extra memory depends on the model's resident dtype; train.precision: fp16 alone does not guarantee that the teacher weights occupy half precision.

Error Patterns

See references/error-patterns.md for the full list of CLIP error symptoms and fixes (CUDA OOM, NaN loss, retrieval quality, dataset format/size, Radio-CLIP and model-ID validation, ONNX external data, TensorRT shape mismatch, PyTorch 2.6 checkpoint load, null-checkpoint inference, TensorRT text/retrieval failures, attention_mask handling, and spec/schema merge errors).

Spec Param / Parent Model Inference

See references/spec-param-inference.md for the packaged model-specific action/spec-field/inference-function mappings that generated runners apply with SDK helpers before create_job(), plus parent_job_id resolution rules.

Deployment

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Tao Finetune Clip AI 技能有什么作用?

CLIP 视觉语言模型,支持图文检索、零样本分类、嵌入提取、ONNX 导出和 TensorRT 部署。微调或训练 CLIP、运行零样本分类、计算图像嵌入,或将 CLIP 部署到 ONNX/TensorRT 时使用。这是一个单次操作的模型技能;不要用于反复训练和评估、直到进展停滞的弱属性改进循环,此类任务应使用 tao-run-deft-pas。

为什么在 TypingMind 中使用 Tao Finetune Clip?

因为您只需安装一次,就能搭配任何模型使用。Tao Finetune Clip 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Tao Finetune Clip?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/NVIDIA-TAO/tao-skill-bank/tree/main/skills/models/tao-finetune-clip。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Tao Finetune Clip?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Tao Finetune Clip 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Tao Finetune Clip 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Tao Finetune Clip AI 技能免费吗?

是的。NVIDIA-TAO 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇