How to do I control the length of the generated outputs

I know I can limit the max sequence length, but how to make sure the model produces shorter sequences on its own? Meaning that it needs to learn it is supposed to produce shorter sequences.