Added truncation for long sequences
Browse files- BertForMorphTagging.py +1 -1
BertForMorphTagging.py
CHANGED
@@ -139,7 +139,7 @@ class BertForMorphTagging(BertPreTrainedModel):
|
|
139 |
|
140 |
def predict(self, sentences: List[str], tokenizer: BertTokenizerFast, padding='longest'):
|
141 |
# tokenize the inputs and convert them to relevant device
|
142 |
-
inputs = tokenizer(sentences, padding=padding, return_tensors='pt')
|
143 |
inputs = {k:v.to(self.device) for k,v in inputs.items()}
|
144 |
# calculate the logits
|
145 |
logits = self.forward(**inputs, return_dict=True).logits
|
|
|
139 |
|
140 |
def predict(self, sentences: List[str], tokenizer: BertTokenizerFast, padding='longest'):
|
141 |
# tokenize the inputs and convert them to relevant device
|
142 |
+
inputs = tokenizer(sentences, padding=padding, truncation=True, return_tensors='pt')
|
143 |
inputs = {k:v.to(self.device) for k,v in inputs.items()}
|
144 |
# calculate the logits
|
145 |
logits = self.forward(**inputs, return_dict=True).logits
|