task-vectors

Edit CLIP model weights using task vector arithmetic on fine-tuned checkpoints.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill task-vectors-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: task-vectors
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/mechanism-skills/representation-and-parameter-analysis/parameter-space-task-vectors
Command: npx skills add https://github.com/zjunlp/Mechanist --skill task-vectors-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, torchvision, and includes scripts (resource) and references (resource) components.

What problem does it solve? Editing neural network behavior normally requires retraining, but this Skill lets you modify pre-trained CLIP models directly in weight space by computing task vectors from pre-trained and fine-tuned checkpoints and combining them with arithmetic operations. ## Core Features & Use Cases - Task Vector Creation: Compute weight-space directions as the difference between fine-tuned and pre-trained CLIP checkpoints (ViT-B/32, ViT-B/16, ViT-L/14). - Arithmetic Model Editing: Negate vectors to suppress unwanted capabilities, add vectors to build multi-task models, and compose analogies (C + B - A) to transfer behaviors without training data. - Evaluation Workflow: Apply edited vectors to a pre-trained encoder with a scaling coefficient and evaluate on datasets like MNIST, EuroSAT, RESISC45, and ImageNet. - Use Case: Combine fine-tuned checkpoints for eight image classification tasks into a single multi-task CLIP model by summing their task vectors and applying the result at scaling coefficient 0.8. ## Quick Start Ask the assistant to create a task vector from a pre-trained CLIP checkpoint and a fine-tuned checkpoint, then negate or sum vectors and evaluate the edited model on a chosen dataset.

Frequently Asked Questions about task-vectors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a task vector from CLIP checkpoints?

Instantiate TaskVector with the paths to a pre-trained zero-shot checkpoint and a fine-tuned checkpoint of the same CLIP model. The class computes the element-wise weight difference, which you can then negate, add, or apply to a model.

How to merge multiple fine-tuned models into one multi-task model?

Create a TaskVector for each fine-tuned checkpoint against the same pre-trained base, then combine them with sum() and call apply_to with a scaling coefficient around 0.8. The resulting encoder performs well on all included tasks simultaneously.

Which CLIP models does task vector arithmetic support?

The workflow supports CLIP ViT-B/32, ViT-B/16, and ViT-L/14 checkpoints. Both the pre-trained and fine-tuned checkpoints must share the identical architecture for the weight-space arithmetic to be valid.

What does negating a task vector do to a model?

Negating a task vector and applying it to the pre-trained model degrades performance on the target task while having minimal effect on control tasks. A scaling coefficient around 0.5 controls the strength of the suppression.

What are the limitations of task vector model editing?

Task vectors require fine-tuned checkpoints derived from the same pre-trained base and architecture, so they cannot merge models trained from different initializations. Results also depend on tuning the scaling coefficient, typically in the 0.3 to 1.0 range.