KEMBAR78
🚨 Remove Contrastive Search decoding strategy by manueldeprada · Pull Request #40428 · huggingface/transformers · GitHub
Skip to content

Conversation

@manueldeprada
Copy link
Contributor

@manueldeprada manueldeprada commented Aug 25, 2025

Removes Contrastive Search generation strategy from the codebase. Directs users to the transformers-community/contrastive-search repository.

It has been a warning for a few releases, but now trust_remote_code=True is required to run contrastive search.

@manueldeprada manueldeprada requested a review from gante August 25, 2025 12:56
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@manueldeprada manueldeprada changed the title Remove contrastive search decoding strategy 🚨 Remove Contrastive Search decoding strategy Aug 25, 2025
Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me, added a few minor nits :D

)
generation_config.cache_implementation = None

# assisted decoding and contrastive search need to roll-back the Cache, which is not supported if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. related to our conversation today, here we force non-sliding windows for speculative decoding
  2. Contrastive search should pass cache_implementation="dynamic_full", and we should create another if below. Otherwise, when we remove GenerationMode.CONTRASTIVE_SEARCH, we won't be able to instantiate the right type of cache.

Copy link
Contributor Author

@manueldeprada manueldeprada Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added dynamic_full as suggested and a warning on the hub code: https://huggingface.co/transformers-community/contrastive-search/commit/1e37df04e0e3f4c0a36cadeb09b65eef59d884f1

Since dynamic_full is quite niche, we probably don't want to document it further for now right?

cc @Cyrilvallez as well as this is related to cache refactors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since dynamic_full is quite niche, we probably don't want to document it further for now right?

Yeah, I'm okay with it being an internal option for now 👍

@manueldeprada
Copy link
Contributor Author

build-doc

@github-actions
Copy link
Contributor

@manueldeprada manueldeprada requested a review from gante August 26, 2025 08:45
@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: bart, csm, gemma, gpt2, gpt_bigcode, gptj, idefics, idefics2, idefics3, kosmos2_5, lfm2, llama, mistral, opt, paligemma2, smolvlm

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@manueldeprada manueldeprada merged commit 49e168f into huggingface:main Aug 26, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants