diff --git a/bert_score/utils.py b/bert_score/utils.py index 8af24be..f1387e6 100644 --- a/bert_score/utils.py +++ b/bert_score/utils.py @@ -188,6 +188,8 @@ def sent_encode(tokenizer, sent): "Encoding as sentence based on the tokenizer" sent = sent.strip() + if tokenizer.model_max_length > 1e30: + tokenizer.model_max_length = 512 if sent == "": return tokenizer.build_inputs_with_special_tokens([]) elif isinstance(tokenizer, GPT2Tokenizer) or isinstance(tokenizer, RobertaTokenizer):