Shaltiel commited on
Commit
07f6795
1 Parent(s): c8e7a7f

Added truncation for long sequences

Browse files
Files changed (1) hide show
  1. 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