AFAIK, the generation should stop once it generates an end-of-sentence token, if you don’t specify max_length. You can use StoppingCriteria 21 (which you implicitly do by setting max_length) to construct arbitrary constraints on when to stop your generation.