hi @infinitejoy
As @lewtun  said, MBart needs the data in a special format. You should pass the src_lang when initializing the tokenizer or set the tokenizer.src_lang attribute, so the tokenizer will add the correct language token to encoded text. Also MBart expects the target language id as the decoder_start_token_id , so you need to pass that argument to generate. Here’s a simple code snippet
tokenizer = MBartTokenizer(..., src_lang="es_XX")
model.generate(..., decoder_start_token_id=tokenizer.get_lang_code_to_id["en_XX"]

also I’m not sure what you mean by

max_length cannot be set to a number greater than 32 which is the batch len

you can set max_length to any value you want.
also there are other models on the hub that can do es to en translation like mbart50 6 or m2m100 2