Solved by nielsr in post #2 
              
              
                Hi, 
You can adjust the maximum number of tokens by specifying the max_length parameter of the generate method: 
outputs = model.generate(pixel_values, output_scores=True, return_dict_in_generate=True, max_length=10)

Note that this is explained in the docs.