diff --git a/src/transformers/generation/utils.py b/src/transformers/generation/utils.py index 713d57a8994..9af619c8203 100644 --- a/src/transformers/generation/utils.py +++ b/src/transformers/generation/utils.py @@ -2342,8 +2342,8 @@ class GenerationMixin(ContinuousMixin): - [`~generation.GenerateBeamEncoderDecoderOutput`] """ # 0. If requested, load an arbitrary generation recipe from the Hub and run it instead + trust_remote_code = kwargs.pop("trust_remote_code", None) if custom_generate is not None: - trust_remote_code = kwargs.pop("trust_remote_code", None) # Get all `generate` arguments in a single variable. Custom functions are responsible for handling them: # they receive the same inputs as `generate`, with `model` instead of `self` and excluding the arguments to # trigger the custom generation. They can access to methods from `GenerationMixin` through `model`. @@ -2564,6 +2564,11 @@ class GenerationMixin(ContinuousMixin): **model_kwargs, ) elif generation_mode == GenerationMode.DOLA_GENERATION: + if not trust_remote_code: + logger.warning_once( + "DoLa Decoding is scheduled to be moved to a `custom_generate` repository in v4.55.0. " + "To prevent loss of backward compatibility, add `trust_remote_code=True` to your `generate` call." + ) if self._is_stateful: # DoLa decoding was not designed for stateful models, and would require some changes raise ValueError( @@ -2581,6 +2586,11 @@ class GenerationMixin(ContinuousMixin): ) elif generation_mode == GenerationMode.CONTRASTIVE_SEARCH: + if not trust_remote_code: + logger.warning_once( + "Contrastive Search is scheduled to be moved to a `custom_generate` repository in v4.55.0. " + "To prevent loss of backward compatibility, add `trust_remote_code=True` to your `generate` call." + ) if not model_kwargs["use_cache"]: raise ValueError("Contrastive search requires `use_cache=True`") if self._is_stateful: @@ -2638,6 +2648,10 @@ class GenerationMixin(ContinuousMixin): ) elif generation_mode == GenerationMode.GROUP_BEAM_SEARCH: + logger.warning_once( + "Group Beam Search is scheduled to be moved to a `custom_generate` repository in v4.55.0. " + "To prevent loss of backward compatibility, add `trust_remote_code=True` to your `generate` call." + ) # 11. prepare beam search scorer beam_scorer = BeamSearchScorer( batch_size=batch_size, @@ -2668,6 +2682,10 @@ class GenerationMixin(ContinuousMixin): ) elif generation_mode == GenerationMode.CONSTRAINED_BEAM_SEARCH: + logger.warning_once( + "Constrained Beam Search is scheduled to be moved to a `custom_generate` repository in v4.55.0. " + "To prevent loss of backward compatibility, add `trust_remote_code=True` to your `generate` call." + ) final_constraints = [] if generation_config.constraints is not None: final_constraints = generation_config.constraints