[GH-ISSUE #150] finetune experience or code #132

Open
opened 2026-10-31 21:11:31 +00:00 by bsakaguchi · 14 comments
Owner

Originally created by @niatzt on GitHub (Sep 5, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/150

I tried to finetune CLIP on my own small dataset. The results are not satisfying (probably overfitting). After checking the issues here, I notice other people also have similar problems. Can someone share his successful finetune experience or code.

Originally created by @niatzt on GitHub (Sep 5, 2021). Original GitHub issue: https://github.com/openai/CLIP/issues/150 I tried to finetune CLIP on my own small dataset. The results are not satisfying (probably overfitting). After checking the issues here, I notice other people also have similar problems. Can someone share his successful finetune experience or code.
Author
Owner

@ABaldrati commented on GitHub (Sep 7, 2021):

Hi @niatzt
In my limited experience of tine-tuning with CLIP I have often noticed how this operation is extremely sensitive to various hyperparameters.
The advice I feel like giving you (which has worked in my case) is:

  • keep CLIP in evaluation mode even during training (i.e. keeping the normalization layers frozen)

  • use very low learning rate (even reaching values like 1e-7 or 1e-8)

  • If you want to fine-tune CLIP together with another network trained from scratch, use different learning rates (lower for CLIP and higher for the other network). You may also consider keeping CLIP frozen a few epochs.

I hope these tips can help you and that your fine-tuning goes successfully.
If you have more questions do not hesitate to ask

<!-- gh-comment-id:914213343 --> @ABaldrati commented on GitHub (Sep 7, 2021): Hi @niatzt In my limited experience of tine-tuning with CLIP I have often noticed how this operation is extremely sensitive to various hyperparameters. The advice I feel like giving you (which has worked in my case) is: - keep CLIP in evaluation mode even during training (i.e. keeping the normalization layers frozen) - use very low learning rate (even reaching values like 1e-7 or 1e-8) - If you want to fine-tune CLIP together with another network trained from scratch, use different learning rates (lower for CLIP and higher for the other network). You may also consider keeping CLIP frozen a few epochs. I hope these tips can help you and that your fine-tuning goes successfully. If you have more questions do not hesitate to ask
Author
Owner

@Sierkinhane commented on GitHub (Nov 23, 2021):

I have finetuned CLIP on PASCAL VOC2012 dataset using this implementation. When I changed the weight decay from 0.2 to 0.001, it works well on my task.

<!-- gh-comment-id:976076317 --> @Sierkinhane commented on GitHub (Nov 23, 2021): I have finetuned CLIP on PASCAL VOC2012 dataset using this [implementation](https://github.com/openai/CLIP/issues/83). When I changed the weight decay from 0.2 to 0.001, it works well on my task.
Author
Owner

@iremonur commented on GitHub (Jan 17, 2022):

Hi, I aim to finetune the clip but I reached %30 of accuracy at max with the learning rate of 5e-6 and weight decay of 0.2, respectively. How is your accuracy in your experiment? What is the size of your data which you use for fine-tuning? I would be glad if you help me with this.

<!-- gh-comment-id:1014164249 --> @iremonur commented on GitHub (Jan 17, 2022): Hi, I aim to finetune the clip but I reached %30 of accuracy at max with the learning rate of 5e-6 and weight decay of 0.2, respectively. How is your accuracy in your experiment? What is the size of your data which you use for fine-tuning? I would be glad if you help me with this.
Author
Owner

@dongyun-kim-arch commented on GitHub (Feb 20, 2022):

@iremonur Hi! I am wondering how you get the accuracy metrics when training since I could only see the loss... Is there any other function or script I can refer to to plot acc metrics? Thanks!

<!-- gh-comment-id:1046322543 --> @dongyun-kim-arch commented on GitHub (Feb 20, 2022): @iremonur Hi! I am wondering how you get the accuracy metrics when training since I could only see the loss... Is there any other function or script I can refer to to plot acc metrics? Thanks!
Author
Owner

@jweihe commented on GitHub (Mar 8, 2022):

I have finetuned CLIP on PASCAL VOC2012 dataset using this implementation. When I changed the weight decay from 0.2 to 0.001, it works well on my task.

Could you provide your fine-tune code?thank you~

<!-- gh-comment-id:1061479661 --> @jweihe commented on GitHub (Mar 8, 2022): > I have finetuned CLIP on PASCAL VOC2012 dataset using this [implementation](https://github.com/openai/CLIP/issues/83). When I changed the weight decay from 0.2 to 0.001, it works well on my task. Could you provide your fine-tune code?thank you~
Author
Owner

@Sierkinhane commented on GitHub (Mar 12, 2022):

My code was same with the implementation

<!-- gh-comment-id:1065871657 --> @Sierkinhane commented on GitHub (Mar 12, 2022): My code was same with [the implementation](https://github.com/openai/CLIP/issues/83)
Author
Owner

@jweihe commented on GitHub (Mar 18, 2022):

My code was same with the implementation

ok, thank u

<!-- gh-comment-id:1072095752 --> @jweihe commented on GitHub (Mar 18, 2022): > My code was same with [the implementation](https://github.com/openai/CLIP/issues/83) ok, thank u
Author
Owner

@ErinZhang1998 commented on GitHub (Apr 6, 2022):

@ABaldrati What do you mean that you freeze the normalization layers?

<!-- gh-comment-id:1090893964 --> @ErinZhang1998 commented on GitHub (Apr 6, 2022): @ABaldrati What do you mean that you freeze the normalization layers?
Author
Owner

@sanjaygunda13 commented on GitHub (Jul 25, 2022):

My code was same with the implementation

I think this helps in training clip from scratch but not finetune. please let me know if i am wrong i am noob :p in all these stuff

<!-- gh-comment-id:1194254839 --> @sanjaygunda13 commented on GitHub (Jul 25, 2022): > My code was same with [the implementation](https://github.com/openai/CLIP/issues/83) I think this helps in training clip from scratch but not finetune. please let me know if i am wrong i am noob :p in all these stuff
Author
Owner

@bwanglzu commented on GitHub (Sep 22, 2022):

in case you're searching for some handy solutions, checkout this page https://finetuner.jina.ai/tasks/text-to-image/

it helps help you get your job done.

<!-- gh-comment-id:1254770331 --> @bwanglzu commented on GitHub (Sep 22, 2022): in case you're searching for some handy solutions, checkout this page https://finetuner.jina.ai/tasks/text-to-image/ it helps help you get your job done.
Author
Owner

@zzxslp commented on GitHub (Dec 20, 2022):

I have finetuned CLIP on PASCAL VOC2012 dataset using this implementation. When I changed the weight decay from 0.2 to 0.001, it works well on my task.

Hi, could you let me know the batch size you are using for fine-tuning CLIP? Thanks!

<!-- gh-comment-id:1358703671 --> @zzxslp commented on GitHub (Dec 20, 2022): > I have finetuned CLIP on PASCAL VOC2012 dataset using this [implementation](https://github.com/openai/CLIP/issues/83). When I changed the weight decay from 0.2 to 0.001, it works well on my task. Hi, could you let me know the batch size you are using for fine-tuning CLIP? Thanks!
Author
Owner

@zzxslp commented on GitHub (Dec 20, 2022):

Hi Alberto, could you share some advice on the batch size for fine-tuning CLIP? For pertaining it is the larger the better in most cases, nor sure if that is the same based on your experience?

<!-- gh-comment-id:1358705020 --> @zzxslp commented on GitHub (Dec 20, 2022): > Hi Alberto, could you share some advice on the batch size for fine-tuning CLIP? For pertaining it is the larger the better in most cases, nor sure if that is the same based on your experience?
Author
Owner

@zhentingqi commented on GitHub (Mar 17, 2024):

Hi, any update in 2024? Is there any method to fine-tune the CLIP model using newest huggingface transformers library (4.35.*)? Thanks!

<!-- gh-comment-id:2002573935 --> @zhentingqi commented on GitHub (Mar 17, 2024): Hi, any update in 2024? Is there any method to fine-tune the CLIP model using newest huggingface transformers library (4.35.*)? Thanks!
Author
Owner

@tengshaofeng commented on GitHub (Feb 18, 2025):

this is my training code, everything gose well. https://github.com/tengshaofeng/finetune-jina-clip-v2

<!-- gh-comment-id:2665384408 --> @tengshaofeng commented on GitHub (Feb 18, 2025): this is my training code, everything gose well. https://github.com/tengshaofeng/finetune-jina-clip-v2
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#132
No description provided.