Tao Finetune Cosmos Embed 标志

Tao Finetune Cosmos Embed

组织
NVIDIA-TAO
tao-finetune-cosmos-embed

Cosmos-Embed1 视频-文本嵌入,用于文本到视频检索、视频间搜索、语义去重和 LoRA 微调。用户提出“微调 Cosmos-Embed1”“在 PhysicalAI-Event-Videos 上对 Cosmos-Embed1 进行 LoRA 微调”“在 vad_r1_chunks 清单上训练 Cosmos-Embed1”“在训练期间为文本到视频检索基准测试评分”“运行 cosmos-embed 推理”“将 Cosmos-Embed1 导出为 ONNX”“嵌入视频”或“用文本搜索视频”等请求时使用。

Add to TypingMind

概览

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

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

  • 兼容任何大语言模型

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

  • 14 个附带文件

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

  • 开源

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

安装

在 TypingMind 中安装 Tao Finetune Cosmos Embed 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-cosmos-embed
  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-cosmos-embed .claude/skills/tao-finetune-cosmos-embed
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

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

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

兼容任何 AI 模型

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

  • 仅在需要时加载

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

  • 在聊天中切换模型

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

技能指令

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

Cosmos-Embed

Standalone install? If this session was not initialized by the TAO skill bank plugin, run the tao-setup skill first (host preflight, credentials, cross-skill discovery).

Cosmos-Embed1 is a joint video-text embedder for text-to-video retrieval, video-to-video search, zero-shot/kNN classification, and semantic deduplication. The packaged CLI is cosmos-embed1 and supports train, evaluate, inference, and export.

Container image and per-action commands are in references/skill_info.yaml. Compact starting specs are in references/spec_template_*.yaml; the LoRA fine-tuning recipe on chunk manifests is in references/lora-finetune-physicalai.md with references/spec_template_train_lora.yaml.

Release note: the pinned 7.3.0-cosmos-embed image is the first that trains ViT LoRA adapters, accepts caption_mode, label_mode, and train.grad_accum_iter, scores the in-training retrieval_benchmark, and validates large ONNX exports by file path. On 7.1.0-cosmos-embed the ViT adapters silently stay at zero and the vision ONNX export exits 1 after writing valid files.

Train Action Policy

AutoML is not packaged for this model skill (no Cosmos-Embed schemas under schemas/). Use the direct train, evaluate, inference, and export actions even when a higher-level request includes automl_policy: on; the per-run override does not change model metadata, and non-train and deploy flows stay in this skill.

Quick Start

Use the published container pinned below (also declared in references/skill_info.yaml); do not build from the Cosmos-Embed1 source tree for normal skill use.

bash
COSMOS_EMBED_IMAGE_DEFAULT=nvcr.io/nvidia/tao/tao-toolkit:7.3.0-cosmos-embed  # versions-key: images.tao_toolkit.cosmos_embed
COSMOS_EMBED_IMAGE="${COSMOS_EMBED_IMAGE:-$COSMOS_EMBED_IMAGE_DEFAULT}"
docker pull "$COSMOS_EMBED_IMAGE"

Expected local workspace layout:

text
workspace/
├── data/
│   ├── msrvtt_test_1k.json
│   └── video/
│       ├── video7020.mp4
│       └── ...
├── model/
│   └── Cosmos-Embed1-224p/        # optional if using HF repo id
├── specs/
│   ├── train.yaml                 # or train_lora.yaml from references/
│   ├── evaluate.yaml
│   ├── inference.yaml
│   ├── export_onnx.yaml
│   └── export_hf.yaml
└── results/

Use these Docker options for all actions unless the local Docker/platform skill gives a stricter environment-specific command:

bash
set -a; source /path/to/.env; set +a   # omit if already exported
COSMOS_EMBED_IMAGE_DEFAULT=nvcr.io/nvidia/tao/tao-toolkit:7.3.0-cosmos-embed  # versions-key: images.tao_toolkit.cosmos_embed
COSMOS_EMBED_IMAGE="${COSMOS_EMBED_IMAGE:-$COSMOS_EMBED_IMAGE_DEFAULT}"
RUN_ROOT="${RUN_ROOT:-$PWD}"
COSMOS_EMBED_PRETRAINED_CACHE="${COSMOS_EMBED_PRETRAINED_CACHE:-$RUN_ROOT/pretrained_checkpoints}"
mkdir -p "$COSMOS_EMBED_PRETRAINED_CACHE"
DOCKER_COMMON=(
  --rm --gpus all --ipc=host --network=host
  --shm-size=64g
  --ulimit memlock=-1
  --ulimit stack=67108864
  -w /results
  -e HF_TOKEN
  -e WANDB_DISABLED=true
  -e WANDB_MODE=disabled
  -e HUGGINGFACE_HUB_CACHE=/hf_cache
  -v "$RUN_ROOT/data:/data:ro"
  -v "$RUN_ROOT/model:/model"
  -v "$RUN_ROOT/specs:/specs:ro"
  -v "$RUN_ROOT/results:/results"
  -v "$RUN_ROOT/hf_cache:/hf_cache"
  --mount "type=bind,source=$COSMOS_EMBED_PRETRAINED_CACHE,target=/usr/local/lib/python3.12/dist-packages/pretrained_checkpoints"
)

The image downloads the BERT Q-Former component under /usr/local/lib/python3.12/dist-packages/pretrained_checkpoints regardless of the Hugging Face cache variables, so the bind mount above must exist and be writable by the container UID chosen by the platform skill. Verify the cache location before reusing this path with another image version.

Keep -w /results: with a cold Triton cache, a working directory containing specs/ makes GCC read ./specs as a compiler spec file (cannot read spec file './specs': Is a directory).

For Cosmos-Embed images that ship protobuf==7.x, run a small startup preamble before every action:

bash
python -m pip install "protobuf<7"

wandb==0.21.0 cannot import with protobuf==7.x; the preamble is a no-op where protobuf is already below 7. Keep WANDB_DISABLED=true for smoke or offline runs. The Q-Former path may download the public google-bert/bert-base-uncased even with the model checkpoint disabled, so provide HF_TOKEN through the environment or an --env-file, or mount a persistent HuggingFace cache. Never write the token into specs, logs, or reports.

Train:

bash
docker run "${DOCKER_COMMON[@]}" "$COSMOS_EMBED_IMAGE" \
  bash -lc "python -m pip install 'protobuf<7' && cosmos-embed1 train -e /specs/train.yaml results_dir=/results"

Evaluate:

bash
docker run "${DOCKER_COMMON[@]}" "$COSMOS_EMBED_IMAGE" \
  bash -lc "python -m pip install 'protobuf<7' && cosmos-embed1 evaluate -e /specs/evaluate.yaml results_dir=/results"

Inference:

bash
docker run "${DOCKER_COMMON[@]}" "$COSMOS_EMBED_IMAGE" \
  bash -lc "python -m pip install 'protobuf<7' && cosmos-embed1 inference -e /specs/inference.yaml \
  'inference.query.input_texts=[\"a man is singing on stage\"]' \
  inference.k=5 \
  results_dir=/results"

Export ONNX (one graph per tower, dynamic batch axis; run once with export.mode=video and once with export.mode=text):

bash
docker run "${DOCKER_COMMON[@]}" "$COSMOS_EMBED_IMAGE" \
  bash -lc "python -m pip install 'protobuf<7' && cosmos-embed1 export -e /specs/export_onnx.yaml \
  export.checkpoint=/results/train/checkpoints/iter_000000001.pt \
  export.mode=video export.batch_size=-1 export.on_cpu=true \
  export.onnx_file=/results/export/cosmos_embed1_vision.onnx \
  results_dir=/results"

Export HuggingFace format:

bash
docker run "${DOCKER_COMMON[@]}" "$COSMOS_EMBED_IMAGE" \
  bash -lc "python -m pip install 'protobuf<7' && cosmos-embed1 export -e /specs/export_hf.yaml \
  export.checkpoint=/results/train/checkpoints/iter_000000001.pt \
  export.hf_output_dir=/results/export_hf/cosmos_embed1_hf \
  results_dir=/results"

For a LoRA checkpoint, every downstream spec (evaluate, inference, export) must carry the training spec's model.lora block and list exactly the modules that were trained in target_modules; export merges the adapters into the weights. See references/lora-finetune-physicalai.md.

Smoke Overrides

For a quick functional check of any action, keep the same specs and shrink iterations, batch sizes, and workers with the command-line overrides listed in references/smoke-overrides.md (including the scheduler and no-checkpoint caveats).

Data Format

The MSR-VTT path expects a local video glob and a JSON metadata file:

yaml
dataset:
  train_dataset:
    dataset_type: msrvtt
    mp4_urls: /data/video/*.mp4
    metadata: /data/msrvtt_test_1k.json

List-format metadata rows must include at least video and caption:

json
{"video_id": "video7020", "video": "video7020.mp4", "caption": "a woman creating a fondant baby and flower"}

The dataset loader derives the video id from the local .mp4 filename and filters to videos present in the metadata. If a run finds zero videos, check that mp4_urls points to a container-local glob and that metadata video names match the filenames.

Chunk manifests (dataset_type: vad_r1_chunks, the PhysicalAI-Event-Videos labels.json layout) hold one record per labeled chunk of a parent video, with caption fields that may be lists of strings. caption_field names the fields that feed the caption pool, caption_mode turns the pool into samples, label_mode decides what counts as a negative, and path_prefix_mapping rewrites the manifest's video prefix to the mounted folder. dataset_type: retrieval_benchmark (validation and evaluation only) takes a benchmark release root holding gt/, additional_gt/, clips/. Details and staging layouts: references/lora-finetune-physicalai.md, references/data-staging.md.

Model Weights

  • Local HF directory: mount it under /model and set model.pretrained_model_path=/model/Cosmos-Embed1-224p.
  • HuggingFace repo: set model.pretrained_model_path=nvidia/Cosmos-Embed1-224p (or -336p, -448p) and pass HF_TOKEN if access is gated.
  • Fine-tuned checkpoint: set downstream actions to the resolver-selected /results/train/checkpoints/iter_#########.pt file.

Training writes full checkpoints under results/train/checkpoints/iter_#########.pt, updates results/train/checkpoints/latest_checkpoint.txt, and creates a cosmos_embed1_model_latest.pth symlink. For evaluate.checkpoint, inference.checkpoint, export.checkpoint, and train.resume_training_checkpoint_path, resolve and pass the exact iter_#########.pt file for the intended iteration. The action spec templates intentionally leave these checkpoint fields null so the model-skill runner or the user must provide the resolver-selected checkpoint. Use the latest symlink only when the user explicitly asks for latest. When the retrieval_benchmark callback is enabled, results/train/selection.json names the best-scoring checkpoint; prefer it over the latest one.

For single-GPU resume/retrain from a consolidated checkpoint, set model.fsdp_shard_size: 1. The container default is 8, which sends resumed training through an FSDP apply path that Cosmos-Embed1 does not implement for this model class. Do not resume a LoRA run through train.resume_training_checkpoint_path; export the selected checkpoint to HF format, point model.pretrained_model_path at it, and start a fresh LoRA stage with its own schedule.

Variants:

VariantResolutionFramesEmbedding dim
Cosmos-Embed1-224p224 x 2248256
Cosmos-Embed1-336p336 x 3368768
Cosmos-Embed1-448p448 x 4488768

Keep model.network.embed_dim, model.input_hw, and model.network.spatial_resolution aligned with the selected variant.

Important Parameters

ParameterNotes
train.num_gpus1 for single GPU, >1 auto-launches torchrun, -1 auto-detects visible GPUs.
train.max_iterMain training length in optimizer updates. Use 1 only for smoke testing.
train.grad_accum_iterMicro-steps per optimizer update. max_iter, validation_iter, and checkpoint_iter count updates, not micro-steps.
train.validation_iter / checkpoint_iterKeep equal (about one epoch) so every validated iteration has a checkpoint on disk.
train.optim.optimfused_adamw is faster when available; adamw is safer for smoke and portability.
train.optim.lr1e-5 for full fine-tuning; 1e-4 for LoRA adapters (1e-5 under-fits them).
train.callbacks.retrieval_benchmark{query_domain, selection_metric}. Scores text-to-video retrieval every validation_iter, writes train/retrieval_benchmark.jsonl and train/selection.json. Requires dataset.val_dataset.dataset_type: retrieval_benchmark; raises TypeError otherwise.
dataset.*.caption_fieldString or list of field names (vad_r1_chunks); list-valued field values contribute every string.
dataset.*.caption_modeall (default; one sample per chunk-caption pair), first, or random.
dataset.*.label_modecategory (default; anomaly type) or caption (identical caption strings share a label). Use caption with free-form captions.
model.lora.enabledEnables LoRA. Set model.network.visual_encoder.transformer_engine=false when LoRA is on.
model.lora.lora_rank / lora_alpha / lora_dropoutStart with 8 / 16 / 0.1; sweep rank 4, 8, 16 and dropout 0.0, 0.05, 0.1 for small datasets.
model.lora.biasBias policy: none, all, or lora_only. Keep none unless intentionally training biases.
model.lora.use_rslora / use_doraOptional LoRA variants. Enable one at a time and record the setting with the checkpoint.
model.lora.target_modulesModule names to adapt. The recipe in spec_template_train_lora.yaml adapts attention of the last 20 ViT blocks plus Q-Former and projection heads. Record the list with the checkpoint; downstream specs must repeat it exactly.
model.lora.modules_to_saveOptional modules to keep fully trainable alongside LoRA. Leave empty unless preserving a task-specific head.
model.network.visual_encoder.checkpoint_activationsActivation checkpointing for the ViT; enable when 448p training runs out of memory.
evaluate.load_dataset_pkl / save_dataset_pklCache evaluation embeddings.
inference.load_dataset_pkl / save_dataset_pklCache the search database for repeated retrieval.
export.modevideo, text, combined, or huggingface. Use video + text for TensorRT deployment.
export.batch_size-1 exports a dynamic batch axis; a positive value fixes it.
export.on_cpuRecommended for export to avoid device mismatch issues.

Outputs

text
results/
├── train/
│   ├── checkpoints/iter_#########.pt
│   ├── cosmos_embed1_model_latest.pth
│   ├── retrieval_benchmark.jsonl      # with the retrieval_benchmark callback
│   ├── selection.json                 # best checkpoint by the callback's metric
│   └── experiment.yaml
├── evaluate/
│   ├── metrics.json
│   └── experiment.yaml
├── inference/
│   ├── results.json
│   └── experiment.yaml
├── export/
│   ├── cosmos_embed1_vision.onnx      # + cosmos_embed1_vision.onnx_data (weights above 2 GB)
│   ├── cosmos_embed1_text.onnx
│   └── export_config.yaml
└── export_hf/
    └── cosmos_embed1_hf/

The per-tower ONNX input/output contract and TensorRT notes are in references/lora-finetune-physicalai.md.

Known Pitfalls

SymptomCauseFix
MSRVTTDataset: 0 videos foundmp4_urls is not a local glob or metadata filenames do not match videos.Mount data into the container and set mp4_urls=/data/video/*.mp4.
Chunk manifest loads 0 videos or skips most entriesManifest paths (videos/<file>.mp4) were not rewritten to the mounted folder.Set dataset.*.path_prefix_mapping from the manifest prefix to the container path.
HF download/auth failureMissing or invalid HF_TOKEN, or model agreement not accepted.Accept the model terms and pass -e HF_TOKEN.
cannot import name 'Imports' from 'wandb.proto.wandb_telemetry_pb2'wandb==0.21.0 in the container is incompatible with protobuf==7.x.Run python -m pip install "protobuf<7" in the container before invoking cosmos-embed1.
Resume fails with Model does not implement 'apply_fsdp'Single-GPU resume loaded a consolidated checkpoint while model.fsdp_shard_size stayed at the default 8.Set model.fsdp_shard_size=1 for local single-GPU resume/retrain.
LoRA injection failureTransformer Engine visual encoder is enabled.Set model.network.visual_encoder.transformer_engine=false.
Every visual_encoder.*.lora_B tensor is zero after trainingImage older than the pinned one (reentrant activation checkpointing with a frozen ViT input; attn.qkv bypassed its LoRA wrapper).Use the pinned image and re-run the lora_B check in references/lora-finetune-physicalai.md.
Evaluate/export of a LoRA checkpoint reports missing or unexpected adapter keysThe downstream spec's model.lora.target_modules differs from the trained list (or is empty).Copy the training spec's model.lora block verbatim.
Vision ONNX export exits 1 with Failed to serialize proto after writing filesOlder image checked the above-2 GB graph in memory.Use the pinned image; on older images the files are valid, confirm with onnx.checker.check_model(path).
RetrievalBenchmarkCallback needs dataset.val_dataset.dataset_type=retrieval_benchmarkThe callback is enabled while val_dataset is mock or MSR-VTT.Enable the callback and the benchmark val_dataset together, or comment both out.
EADDRINUSE on port 29500Two cosmos-embed1 runs share a host and the default distributed port.Give each run its own MASTER_PORT / --master_port.
torchrun --standalone hangs at rendezvousThe pod hostname does not resolve for worker ranks.Launch with python -m torch.distributed.run --master_addr 127.0.0.1 ... -m cosmos_embed1.scripts.train --config-path /specs --config-name <spec>.
ONNX/HF export complains about missing componentsExport checkpoint is partial or adapter-only.Use a full checkpoint or configure pretrained visual/text sources before export.
CUDA OOMBatch/resolution too high for the GPU.Enable visual_encoder.checkpoint_activations, reduce batch size, use 224p, enable LoRA, or use more GPUs.

附带文件

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

常见问题

Tao Finetune Cosmos Embed AI 技能有什么作用?

Cosmos-Embed1 视频-文本嵌入,用于文本到视频检索、视频间搜索、语义去重和 LoRA 微调。用户提出“微调 Cosmos-Embed1”“在 PhysicalAI-Event-Videos 上对 Cosmos-Embed1 进行 LoRA 微调”“在 vad_r1_chunks 清单上训练 Cosmos-Embed1”“在训练期间为文本到视频检索基准测试评分”“运行 cosmos-embed 推理”“将 Cosmos-Embed1 导出为 ONNX”“嵌入视频”或“用文本搜索视频”等请求时使用。

为什么在 TypingMind 中使用 Tao Finetune Cosmos Embed?

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

如何在 TypingMind 中安装 Tao Finetune Cosmos Embed?

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

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

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

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

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

Tao Finetune Cosmos Embed AI 技能免费吗?

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

什么是 AI 技能?

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

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

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

查看全部

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

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