allenai / longformer

Longformer: The Long-Document Transformer
https://arxiv.org/abs/2004.05150
Apache License 2.0
2.03k stars 271 forks source link

LED models give: `IndexError: index out of range in self` #216

Closed nicola-decao closed 2 years ago

nicola-decao commented 2 years ago

Using a Longformer on more an input with than 1024 tokens doesn't seem to work. But it should as the Longformer was specifically designed to handle up to 16k tokens as input. See the code below.

To reproduce:

from transformers import LEDTokenizer, LEDForConditionalGeneration

tokenizer = LEDTokenizer.from_pretrained("allenai/led-base-16384")
model = LEDForConditionalGeneration.from_pretrained("allenai/led-base-16384")

# this works (tokens < 1024)
model(**tokenizer("hello " * 120, return_tensors="pt"))

# this does not work! (tokens > 1024)
model(**tokenizer("hello " * 1200, return_tensors="pt"))

Versions:

nicola-decao commented 2 years ago

Sorry I realized I should post this in huggingface/transformers