Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG_FIX] RobertaTokenizerFast object has no attributes max_len #84

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bert_score/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,20 @@ def sent_encode(tokenizer, sent):

if LooseVersion(transformers.__version__) >= LooseVersion("3.0.0"):
return tokenizer.encode(
sent, add_special_tokens=True, add_prefix_space=True, max_length=tokenizer.max_len, truncation=True
sent, add_special_tokens=True, add_prefix_space=True, max_length=tokenizer.model_max_length,
truncation=True
)
else:
return tokenizer.encode(sent, add_special_tokens=True, add_prefix_space=True, max_length=tokenizer.max_len)
return tokenizer.encode(sent, add_special_tokens=True, add_prefix_space=True,
max_length=tokenizer.model_max_length)
else:
import transformers

if LooseVersion(transformers.__version__) >= LooseVersion("3.0.0"):
return tokenizer.encode(sent, add_special_tokens=True, max_length=tokenizer.max_len, truncation=True)
return tokenizer.encode(sent, add_special_tokens=True, max_length=tokenizer.model_max_length,
truncation=True)
else:
return tokenizer.encode(sent, add_special_tokens=True, max_length=tokenizer.max_len)
return tokenizer.encode(sent, add_special_tokens=True, max_length=tokenizer.model_max_length)


def get_model(model_type, num_layers, all_layers=None):
Expand Down