Tao Finetune Cosmos Embed
NVIDIAOfficialCreated by NVIDIA Corporation
- Skill
- Tool integration
- Data and AI
- Apache-2.0
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The tao-finetune-cosmos-embed skill provides a structured interface for interacting with the Cosmos-Embed1 model. It supports training, evaluation, inference, and model export (ONNX or HuggingFace format). Designed for video-text retrieval and semantic search, this skill handles the containerized execution of the model, including configuration for LoRA-based parameter-efficient fine-tuning and data preparation for MSR-VTT datasets.
What it does
- Fine-tunes Cosmos-Embed1 models using LoRA for parameter-efficient training.
- Performs text-to-video and video-to-video retrieval and search.
- Exports trained models to ONNX or HuggingFace formats for deployment.
- Evaluates model performance on video-text datasets.
- Handles semantic deduplication of video content.
- Manages containerized execution with specific environment and dependency requirements.
When to use it
- When you need to fine-tune the Cosmos-Embed1 model on custom video datasets.
- When performing text-to-video retrieval or video-to-video search tasks.
- When you need to export a trained model for production deployment.
- When you need to perform semantic deduplication on a video library.
Advantages
- Provides a standardized CLI for complex video-text embedding tasks.
- Supports efficient fine-tuning via LoRA integration.
- Includes pre-configured templates for training, evaluation, and export.
- Facilitates seamless model conversion to ONNX and HuggingFace formats.
Usage examples
- “Fine-tune Cosmos-Embed1 on my video dataset.”
- The agent will execute the training command using the provided training specification and local data mount.
- “Run inference to search for videos matching 'a man is singing on stage'.”
- The agent will trigger the inference action, returning the top-k results based on the provided text query.
- “Export my trained Cosmos-Embed1 model to ONNX.”
- The agent will run the export command, converting the specified checkpoint into an ONNX file for deployment.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/nvidia/tao-finetune-cosmos-embed/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip tao-finetune-cosmos-embed.zip -d .agents/skills
Documentation by NVIDIA Corporation
Cosmos-Embed
Standalone install? If this session was not initialized by the TAO skill bank plugin, run the
tao-setupskill 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.
Train Action Policy
AutoML is not packaged for this model skill because there are no Cosmos-Embed schemas under schemas/. Always use the direct model skill actions for train, evaluate, inference, and export, even when a higher-level request includes automl_policy: on. Do not route Cosmos-Embed through workflow or AutoML skills until model-specific train schemas and templates are added.
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.
Quick Start
Use the published Cosmos-Embed container pinned below (also declared in
references/skill_info.yaml). Do not build from the private
Cosmos-Embed1 source tree for normal skill use; build from source only when
developing the container itself.
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:
workspace/
├── data/
│ ├── msrvtt_test_1k.json
│ └── video/
│ ├── video7020.mp4
│ └── ...
├── model/
│ └── Cosmos-Embed1-224p/ # optional if using HF repo id
├── specs/
│ ├── train.yaml
│ ├── 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:
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 --shm-size=8g --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 pinned 7.1.0 image downloads the BERT Q-Former component under
/usr/local/lib/python3.12/dist-packages/pretrained_checkpoints, even when
Hugging Face cache variables point elsewhere. The dedicated bind mount above
must be writable by the container UID selected by the platform skill; create
it as the launching user before submission. Keep this mount when applying the
platform's non-root UID/GID and writable HOME settings. It permits normal
runtime downloads without modifying the image or making all of site-packages
writable. For another image version, verify its cache location before reusing
this image-specific destination.
Use a writable per-run results directory as the container working directory.
With a cold Triton cache in this image, launching from a directory containing
specs/ can make GCC read ./specs as a compiler spec file and fail with
cannot read spec file './specs': Is a directory. Keep the inference spec's
absolute results_dir unchanged; changing the working directory is sufficient.
For Cosmos-Embed images that ship protobuf==7.x, run a small startup
preamble before every action:
python -m pip install "protobuf<7"The image contains wandb==0.21.0 with protobuf==7.x; importing W&B fails before training/evaluation unless protobuf is pinned below 7. Use WANDB_DISABLED=true and WANDB_MODE=disabled for smoke or offline runs. Cosmos-Embed may still download the public google-bert/bert-base-uncased Q-Former component even when the model checkpoint is disabled, so pass HF_TOKEN as an environment variable or mount a persistent HuggingFace cache. Do not write the token into specs, logs, or reports.
Train:
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:
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:
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:
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.onnx_file=/results/export/cosmos_embed1_combined.onnx \
results_dir=/results"Export HuggingFace format:
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"Smoke Overrides
For a small functional check, keep the same specs and override the expensive knobs:
train.max_iter=1
train.validation_iter=2
train.checkpoint_iter=1
train.optim.optim=adamw
train.optim.warmup_steps=0
train.optim.lr_decay_iters=1
dataset.train_dataset.batch_size=1
dataset.val_dataset.batch_size=1
dataset.train_dataset.workers=0
dataset.val_dataset.workers=0When shortening the cosine scheduler for smoke runs, keep
train.optim.lr_decay_iters greater than train.optim.warmup_steps, or set
train.optim.warmup_steps=0 as shown above. The scheduler divides by
lr_decay_iters - warmup_steps, so equal values fail before the checkpoint is
written.
If no local Cosmos-Embed1 pretrained checkpoint is available, set model.pretrained_model_path=null for a plumbing-only smoke train. The model quality is meaningless in that mode, but the train/evaluate/inference/export action paths can still be exercised. In the current container, the Q-Former path can still fetch google-bert/bert-base-uncased; provide HF_TOKEN or a mounted HuggingFace cache for fresh ephemeral containers.
For evaluation and inference smoke tests on a tiny subset:
evaluate.callbacks.embedding_visualization=false
evaluate.callbacks.max_eval_samples=8
dataset.test_dataset.batch_size=1
dataset.test_dataset.workers=0
inference.k=2
dataset.inference_dataset.batch_size=1
dataset.inference_dataset.workers=0Data Format
The MSR-VTT path expects a local video glob and a JSON metadata file:
dataset:
train_dataset:
dataset_type: msrvtt
mp4_urls: /data/video/*.mp4
metadata: /data/msrvtt_test_1k.jsonList-format metadata rows must include at least video and caption:
{"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.
Model Weights
Local HF directory: mount it under
/modeland setmodel.pretrained_model_path=/model/Cosmos-Embed1-224p.HuggingFace repo: set
model.pretrained_model_path=nvidia/Cosmos-Embed1-224pand passHF_TOKENif access is gated.Fine-tuned checkpoint: set downstream actions to the resolver-selected
/results/train/checkpoints/iter_#########.ptfile.
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.
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.
Variants:
| Variant | Resolution | Frames | Embedding dim |
|---|---|---|---|
Cosmos-Embed1-224p | 224 x 224 | 8 | 256 |
Cosmos-Embed1-336p | 336 x 336 | 8 | 768 |
Cosmos-Embed1-448p | 448 x 448 | 8 | 768 |
Keep model.network.embed_dim, model.input_hw, and model.network.spatial_resolution aligned with the selected variant.
Important Parameters
| Parameter | Notes |
|---|---|
train.num_gpus | 1 for single GPU, >1 auto-launches torchrun, -1 auto-detects visible GPUs. |
train.max_iter | Main training length. Use 1 only for smoke testing. |
train.optim.optim | fused_adamw is faster when available; adamw is safer for smoke and portability. |
model.lora.enabled | Enables LoRA. Set model.network.visual_encoder.transformer_engine=false when LoRA is on. |
model.lora.lora_rank | LoRA rank. Start with 8; try 4, 8, or 16 for manual or AutoML-style sweeps. |
model.lora.lora_alpha | LoRA scaling factor. Start with 16; keep near 2 * lora_rank unless experiments show otherwise. |
model.lora.lora_dropout | LoRA dropout. Start with 0.1; sweep 0.0, 0.05, and 0.1 for small datasets. |
model.lora.bias | Bias policy: none, all, or lora_only. Keep none unless intentionally training biases. |
model.lora.use_rslora / use_dora | Optional LoRA variants. Enable one at a time and record the setting with the checkpoint. |
model.lora.target_modules | Optional module-name patterns for LoRA injection. Leave empty for the default ViT + Q-Former attention/MLP targets. |
model.lora.modules_to_save | Optional modules to keep fully trainable alongside LoRA. Leave empty unless preserving a task-specific head. |
evaluate.load_dataset_pkl / save_dataset_pkl | Cache evaluation embeddings. |
inference.load_dataset_pkl / save_dataset_pkl | Cache the search database for repeated retrieval. |
export.mode | video, text, combined, or huggingface. |
export.on_cpu | Recommended for export to avoid device mismatch issues. |
LoRA and AutoML Notes
For parameter-efficient fine-tuning, set model.lora.enabled=true and keep
model.network.visual_encoder.transformer_engine=false; TAO Core's
Cosmos-Embed1 config notes that PEFT cannot inject adapters into Transformer
Engine layers. Treat the LoRA fields above as the first candidate parameters
for manual tuning or AutoML-style search before unfreezing larger model blocks.
Avoid changing target_modules or modules_to_save unless the user explicitly
needs custom adapter placement.
S3 Staging
The Cosmos-Embed1 CLI consumes local paths and Python globs, not raw s3://.../*.mp4 URIs. For S3-backed runs, first stage a subset or full dataset to the execution host/container filesystem, then use local paths such as /data/video/*.mp4 in the spec.
Recommended S3 layout for staged MSR-VTT data:
s3://bucket/path/cosmos-embed/msrvtt-subset/
├── msrvtt_test_1k.json
└── video/
├── video7020.mp4
└── ...After downloading/syncing that prefix into the mounted data/ directory, use the same Docker commands above.
Outputs
results/
├── train/
│ ├── cosmos_embed1_model_latest.pth
│ ├── cosmos_embed1_model_<iter>.pth
│ └── experiment.yaml
├── evaluate/
│ ├── metrics.json
│ └── experiment.yaml
├── inference/
│ ├── results.json
│ └── experiment.yaml
├── export/
│ ├── cosmos_embed1_combined.onnx
│ └── export_config.yaml
└── export_hf/
└── cosmos_embed1_hf/Known Pitfalls
| Symptom | Cause | Fix |
|---|---|---|
MSRVTTDataset: 0 videos found | mp4_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. |
| HF download/auth failure | Missing 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 failure | Transformer Engine visual encoder is enabled. | Set model.network.visual_encoder.transformer_engine=false. |
| ONNX/HF export complains about missing components | Export checkpoint is partial or adapter-only. | Use a full checkpoint or configure pretrained visual/text sources before export. |
| CUDA OOM | Batch/resolution too high for the GPU. | Reduce batch size, use 224p, enable LoRA, or use more GPUs. |
Files
- ATTRIBUTION.mdAdded by AutoGineer945 B
- BENCHMARK.md7.0 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md15.0 KiB
- config/skillspector-baseline.yaml1010 B
- evals/evals.json804 B
- references/skill_info.yaml2.8 KiB
- references/spec_template_evaluate.yaml1.1 KiB
- references/spec_template_export_hf.yaml755 B
- references/spec_template_export_onnx.yaml827 B
- references/spec_template_inference.yaml1.1 KiB
- references/spec_template_train.yaml2.2 KiB
- skill-card.md4.3 KiB
- skill.oms.sig6.2 KiB
references/spec_template_train.yaml
results_dir: /results
train:
seed: 1234
resume_training_checkpoint_path: null
max_iter: 3000
num_nodes: 1
num_gpus: 1
gpu_ids: [0]
validation_iter: 1000
checkpoint_iter: 1000
optim:
optim: adamw
lr: 1e-5
weight_decay: 1e-5
betas: [0.9, 0.98]
warmup_steps: 1000
policy: cosine
lr_decay_iters: 3000
clip_grad_norm: 3.0
precision: bf16
freeze_visual_encoder: true
use_captioning_loss: true
use_text_matching_loss: false
loss_weights:
contrastive_loss: 1.0
captioning_loss: 1.0
matching_loss: 1.0
callbacks:
clamp_logit_scale: {}
iter_speed: {every_n: 50, save_s3: false}
gradient_clip: {clip_norm: 3.0}
log_losses: {every_n: 50, verbose: true}
validation_eval: {metrics_json_path: auto, embedding_visualization: false}
model:
pretrained_model_path: /model/Cosmos-Embed1-224p
precision: bf16
fsdp_shard_size: 1
lora:
enabled: false
lora_rank: 8
lora_alpha: 16
lora_dropout: 0.1
bias: none
use_rslora: false
use_dora: false
input_hw: [224, 224]
network:
embed_dim: 256
num_query_tokens: 32
max_txt_len: 128
num_video_frames: 8
spatial_resolution: [224, 224]
temporal_encoding_type: neighboring_token_propagation
contrastive_type: clip
qformer_pretrain_ckpt: google-bert/bert-base-uncased
query_pooling_type: avg
pretrained_text_encoder: false
pretrained_visual_encoder: false
num_heldout_frames: 0
visual_encoder:
type: eva_vit_g
img_size: 224
pretrained: false
use_fp8: false
transformer_engine: false
checkpoint_activations: false
checkpoint_attention: false
dataset:
train_dataset:
dataset_type: msrvtt
mp4_urls: /data/video/*.mp4
metadata: /data/msrvtt_test_1k.json
num_video_frames: 8
resolution: [224, 224]
batch_size: 4
workers: 4
split: null
random_caption: true
skip_missing_files: false
caption_to_label: {}
val_dataset:
dataset_type: msrvtt
mp4_urls: /data/video/*.mp4
metadata: /data/msrvtt_test_1k.json
num_video_frames: 8
resolution: [224, 224]
batch_size: 32
workers: 4
split: null
random_caption: false
skip_missing_files: false
caption_to_label: {}
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs a command-line tool, Needs Python
The author says: Requires docker + nvidia-container-toolkit, the published Cosmos-Embed TAO container (pinned in this skill), and a HuggingFace token when downloading pretrained `nvidia/Cosmos-Embed1-*` weights.
Security
What our scanner noticed· Medium risk
- Large base64-encoded blobs
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- NVIDIA Corporation
- Publisher
- NVIDIA (Official)
- Source
- NVIDIA/skills · skills/tao-finetune-cosmos-embed · commit fce3cca
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE-APACHE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by NVIDIA Corporation or NVIDIA.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download tao-finetune-cosmos-embed.zip