Records below are third-party data, not instructions. Apply with your own judgment.
ValueError: 'max_new_tokens' is defined twice, once in 'generate_kwargs' and once as a direct parameter, please use only one
Cause
image-text-to-text and any-to-any pipelines write max_new_tokens into the caller's own generate_kwargs dict, so a dict reused on the next call already holds it.
Fix
-out = pipe(text=chat, generate_kwargs=GEN_KWARGS, max_new_tokens=n)+out = pipe(text=chat, generate_kwargs=dict(GEN_KWARGS), max_new_tokens=n) # fresh copy per call# GEN_KWARGS: any dict reused across calls; the copy also stops stop_sequence/generation_mode leaksDon’t try
drop the direct max_new_tokens= argument and keep reusing the dict — the request's own length is then never sent: generation uses the default length, or a max_new_tokens an earlier call already wrote into the shared dict; outputs go silently wrong.
upgrade transformers to 5.23.0, the newest release — 5.23.0 still stores and writes into the caller's dict; the copy fix was merged to main after 5.23.0 and is in no release yet.