Aller au contenu
Skillpedia
Agents41k · #6737

vision-sft

Ce qu’il fait

Cet outil apprend à un modèle d'IA à comprendre à la fois les images et le texte. Il affine le modèle pour qu'il puisse accomplir des tâches précises combinant les deux, comme décrire une image ou répondre à des questions à son sujet.

Quand l’utiliser

  • ✓Lorsque vous voulez que l'IA décrive les images de manière plus détaillée.
  • ✓Lorsque vous voulez que l'IA réponde à des questions sur le contenu d'une image.
  • ✓Lorsque vous voulez adapter l'IA à un type d'image particulier (par exemple, des examens médicaux ou des schémas).

Lien du skill

https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/vision-sft/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/vision-sft/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Affine ce modèle pour qu'il comprenne les radiographies et réponde aux questions à leur sujet.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'outil ajuste certaines parties du modèle d'IA qui traitent les images et le texte. Il utilise une méthode appelée LoRA pour effectuer ces modifications de manière efficace, en conservant la majeure partie du modèle d'origine.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

Vision-Language SFT

This skill assumes finetuning-method-selection already routed here: the data shape is image+text demonstrations, not preference pairs or a verifiable reward signal, and the base is a vision-language model rather than a text-only one. lora-qlora-recipes covers the text-only LoRA/QLoRA recipe this skill specializes for the vision tower and projector; read that skill first if the LoRA fundamentals (rank, alpha, target modules) aren't already familiar.

Input: an image+text dataset and a VLM base model already picked from the model catalog. Output format: a validated adapter config — which components are frozen, LoRA target modules, and a min_pixels/max_pixels budget — that llm-finetuning-training-engineer consumes directly when it generates a runnable script.

Quick Reference

Situation Default
Adapting behavior on familiar images Frozen tower+projector, LoRA r=8–16, α=16–32
Visual domain shift Unfreeze last-6 ViT layers, vision LR 5–10x lower
Doesn't fit in bf16 at target rank QLoRA — frozen vision tower only
fast_inference=True finetune_vision_layers=False
Loss normal, eval not improving Check the Two Silent Killers below first

The Consensus Recipe

Freeze the vision tower and the projector. Put LoRA on the LLM only, all-linear (the same attention + MLP target list as text-only SFT — see lora-qlora-recipes), at r=8–16, α=16–32. This is the settled default for adapting a VLM's behavior without disturbing how it sees.

  • The vision tower and projector stay frozen by default. They already encode a general visual representation; retraining them is rarely necessary and adds risk without adding capability for most tasks.
  • LoRA rank runs lower than the text-only general default (r=8–16 here vs r=16–32 for text-only SFT) because the LLM-only adapter is adapting behavior, not injecting new visual knowledge.
  • QLoRA is permitted only with a frozen vision tower. Quantizing the base while also unfreezing and training vision layers is unsupported and unstable — treat this as a hard pairing rule, not a tunable. If the vision tower needs to unfreeze, drop QLoRA and use bf16 LoRA instead.
# freeze tower + projector; LoRA on LLM only
for name, param in model.named_parameters():
    if "vision_tower" in name or "projector" in name:
        param.requires_grad = False

target_modules = [
    "q_proj", "k_proj", "v_proj", "o_proj",
    "gate_proj", "up_proj", "down_proj",
]  # LLM-only, all-linear — r=8-16, alpha=16-32

When to Unfreeze

Unfreezing vision layers is a deliberate escalation, not a default decision — reach for it only when the domain shift is visual, not textual.

  • Unfreeze only for visual domain shift. If the task is teaching new behavior on images the tower already understands (charts, everyday photos), the frozen-tower recipe above is sufficient. Unfreeze when the visual domain itself is unfamiliar to the tower — satellite imagery, medical scans, dense technical diagrams — and the frozen-tower recipe plateaus.
  • Last-6 ViT layers is the sweet spot. Unfreezing the final six vision-transformer layers (not the whole tower) measured +1.7pt DocVQA at ~1.75x training cost over the frozen baseline. Treat six layers as the ceiling worth paying for; going further spends compute without a matched result.
  • Vision LR must run 5–10x lower than the LLM LR when unfrozen. The vision tower's pretrained representation is more fragile than the LLM's adapter; the same LR for both risks overwriting the visual representation faster than the LLM adapter can compensate.
  • High LoRA rank on the patch- embedding layer risks NaN. If patch embedding is in the unfrozen set, keep its rank low and watch early-step loss closely — one of the most fragile places to apply LoRA in a VLM.

The Two Silent Killers

Both produce a run that trains without error and without learning: the loss curve looks normal, the model doesn't improve, and neither throws an exception — both need an explicit pre-training check, not just a clean training log.

  • Image-tag/count mismatch. Every image placeholder token in the templated text must map 1:1 to a media item actually passed to the collator. A mismatch (one placeholder, zero or two images attached; or an image with no placeholder) doesn't error in most collators —

…

Questions fréquentes

Que signifie « geler » des parties du modèle ?

Geler signifie que ces parties du modèle ne seront pas modifiées pendant l'entraînement. C'est comme conserver intact le savoir-faire de l'IA en matière de vision.

Qu'est-ce que LoRA ?

LoRA est une technique qui permet d'affiner un modèle d'IA sans le réentraîner entièrement. Elle est plus rapide et consomme moins de ressources, car elle se concentre sur de petites « adaptations ».

Pourquoi la taille des images (min_pixels/max_pixels) est-elle importante ?

Elle définit la résolution des images que le modèle peut traiter. Bien la régler est essentiel pour que le modèle voie les détails importants sans consommer trop de mémoire ni échouer.

Détails

Description originale de l’auteur

Fine-tune vision-language models (VLMs) with supervised learning on image+text data. Use when adapting a VLM to a visual domain or task, configuring frozen-vision-tower LoRA, or debugging a VLM fine-tune that trains without learning.

repo: wshobson/agents

Popularité

Étoiles GitHub
41k
Position au classement
#6737
Licence
MIT
Mis à jour
15/10/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires