Minor fix

This commit is contained in:
oobabooga 2023-05-29 13:31:17 -03:00
parent 983eef1e29
commit f34d20922c

View File

@ -82,11 +82,12 @@ def calculate_perplexity(models, input_dataset, stride, _max_length):
yield cumulative_log + "Tokenizing the input dataset...\n\n" yield cumulative_log + "Tokenizing the input dataset...\n\n"
encodings = encode(text, add_special_tokens=False) encodings = encode(text, add_special_tokens=False)
seq_len = encodings.shape[1] seq_len = encodings.shape[1]
if not _max_length: if _max_length:
if hasattr(shared.model.config, 'max_position_embeddings'): max_length = _max_length
max_length = shared.model.config.max_position_embeddings elif hasattr(shared.model.config, 'max_position_embeddings'):
else: max_length = shared.model.config.max_position_embeddings
max_length = 2048 else:
max_length = 2048
nlls = [] nlls = []
prev_end_loc = 0 prev_end_loc = 0