GLiNER icon indicating copy to clipboard operation
GLiNER copied to clipboard

max_length and truncation parameters not working

Open jspablo opened this issue 10 months ago • 3 comments

I am getting the following message using gliner==0.2.17 version:

Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.

When testing the example, the tokenizer and model are loaded at the same time and setting max_length keeps returning the same message

model = GLiNER.from_pretrained("./model")

What is the correct way to set max_length and truncation parameters?

jspablo avatar Mar 29 '25 22:03 jspablo

Facing the same issue

Myselfkc21 avatar Apr 03 '25 10:04 Myselfkc21

Same issue as well.

DrissiReda avatar Jun 16 '25 10:06 DrissiReda

Modify the line no: ~567 in model.py file like below to use truncate and max_length as per your need. The max_len is been specified in the config.yaml file, if not add "max_len: 512/128/256" based on the encoder type.

tokenized_labels = self.data_processor.labels_tokenizer(batch, return_tensors='pt',
                                                                truncation=True, padding="max_length", max_length=self.config.max_len).to(self.device)

PandiRaja18 avatar Aug 13 '25 11:08 PandiRaja18