# Token indices sequence length is longer (Python)

**URL:** <https://discuss.huggingface.co/t/token-indices-sequence-length-is-longer-python/36442>\
**Category:** 🤗Transformers\
**Created:** [April 13, 2023, 11:04am UTC](https://discuss.huggingface.co/t/token-indices-sequence-length-is-longer-python/36442 "2023-04-13T11:04:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yugen2](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/yugen2/32/13883_2.png) [@yugen2](https://discuss.huggingface.co/u/yugen2)\
**Post date:** [April 13, 2023, 11:04am UTC](https://discuss.huggingface.co/t/token-indices-sequence-length-is-longer-python/36442/1 "2023-04-13T11:04:17Z")

</div>

Hello,

I am trying to extract GPT2 pretrained vectors for text of arbitrary length. So I tried to set the n\_positions argument in the config of the model to a higher value than the default. But I’m still gettting warnings as if I haven’t set it at all. Any idea what I’m doing wrong?

My code:

from transformers import GPT2Tokenizer, GPT2Model, GPT2Config  
import torch

max\_len = 10000

config = GPT2Config(n\_positions=max\_len,)  
tokenizer = GPT2Tokenizer.from\_pretrained(‘gpt2’,ignore\_mismatched\_sizes=True,config=config)  
model = GPT2Model.from\_pretrained(‘gpt2’,ignore\_mismatched\_sizes=True,config=config)  
text= " ".join([“a”]\*2000)

encoded\_input = tokenizer(text, return\_tensors=‘pt’)  
output = model(\*\*encoded\_input)
