better error message (#5497)

This commit is contained in:
Patrick von Platen
2020-07-03 19:25:25 +02:00
committed by GitHub
parent b58a15a31e
commit 991172922f
2 changed files with 8 additions and 0 deletions

View File

@@ -428,6 +428,10 @@ class GenerationMixin:
encoder_outputs = None
cur_len = input_ids.shape[-1]
assert (
cur_len < max_length
), f"The context has {cur_len} number of tokens, but `max_length` is only {max_length}. Please make sure that `max_length` is bigger than the number of tokens, by setting either `generate(max_length=...,...)` or `config.max_length = ...`"
if num_beams > 1:
output = self._generate_beam_search(
input_ids,