# Increasing pretrained CLIP max possible text sequence length

**URL:** <https://discuss.huggingface.co/t/increasing-pretrained-clip-max-possible-text-sequence-length/29885>\
**Category:** 🤗Transformers\
**Created:** [January 17, 2023, 2:13pm UTC](https://discuss.huggingface.co/t/increasing-pretrained-clip-max-possible-text-sequence-length/29885 "2023-01-17T14:13:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![exibings](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/exibings/32/23321_2.png) [@exibings](https://discuss.huggingface.co/u/exibings)\
**Post date:** [January 17, 2023, 2:13pm UTC](https://discuss.huggingface.co/t/increasing-pretrained-clip-max-possible-text-sequence-length/29885/1 "2023-01-17T14:13:56Z")

</div>

Hey! 👋 I’m quite new to this platform and I’ve been using it to work on my Msc Thesis. I’m wondering if it is possible to use a pretrained CLIP model but change how long the max sequence length is. In particular, the pretrained CLIP model I’m using is [CLIP-RSCID](https://huggingface.co/flax-community/clip-rsicd-v2) and I want to increase the maximum sequence length that the model can receive as input - currently it’s 77. Ideally I want to keep the current model weights and simply add random weights for the new columns in the updated weights matrixes. I’ve tried to look around the CLIP documentation and couldn’t find anything that allows to keep the pretrained weights whilst changing the configuration but as I said I’m a beginner. Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![meric](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@meric](https://discuss.huggingface.co/u/meric)\
**Post date:** [April 10, 2023, 10:49pm UTC](https://discuss.huggingface.co/t/increasing-pretrained-clip-max-possible-text-sequence-length/29885/2 "2023-04-10T22:49:53Z")

</div>

Did you ever figure out a solution to this? Running into the same issue for `max_position_embeddings`

---

<div class="post-metadata">

**Author:** ![koringayash](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@koringayash](https://discuss.huggingface.co/u/koringayash)\
**Post date:** [November 7, 2024, 4:17am UTC](https://discuss.huggingface.co/t/increasing-pretrained-clip-max-possible-text-sequence-length/29885/3 "2024-11-07T04:17:43Z")

</div>

We can use Long-clip model to solve this issue.  
In this it will give you max\_position\_embeddings = 256 which is more than 77 provided by clip.  
Following code will may help you.

from transformers import CLIPModel, CLIPProcessor, CLIPConfig

model\_id = (“zer0int/LongCLIP-GmP-ViT-L-14”)  
config = CLIPConfig.from\_pretrained(model\_id)  
config.text\_config.max\_position\_embeddings = 248

model = CLIPModel.from\_pretrained(model\_id,config=config)  
processor = CLIPProcessor.from\_pretrained(model\_id,config=config)

This may help you with problem.
