Skip to content

Grouped beam search from config params#42472

Merged
zucchini-nlp merged 7 commits intohuggingface:mainfrom
zucchini-nlp:custom-generation-from-config
Jan 12, 2026
Merged

Grouped beam search from config params#42472
zucchini-nlp merged 7 commits intohuggingface:mainfrom
zucchini-nlp:custom-generation-from-config

Conversation

@zucchini-nlp
Copy link
Copy Markdown
Member

What does this PR do?

Ensures that we can fallback to hub-based group generation from generation args, even if the custom generate is not passed. And, I updated the version in deprecation cycle. I don't think we will break it for v5 yet

from transformers import BartForConditionalGeneration, GenerationConfig
import torch

model_id = "hf-internal-testing/tiny-random-bart"
model = BartForConditionalGeneration.from_pretrained(model_id)
gen_config = GenerationConfig(
    num_beams=4,
    do_sample=False,
    max_new_tokens=10,
    min_new_tokens=10,
    num_beam_groups=2,
    diversity_penalty=0.0001,
    use_cache=True,
)

input_ids = torch.tensor([[model.config.bos_token_id]])
out = model.generate(input_ids, generation_config=gen_config, trust_remote_code=True)

@zucchini-nlp zucchini-nlp added the for patch Tag issues / labels that should be included in the next patch label Dec 1, 2025
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

@zucchini-nlp
Copy link
Copy Markdown
Member Author

Test failures not related

Comment thread src/transformers/generation/utils.py Outdated
@zucchini-nlp zucchini-nlp enabled auto-merge (squash) December 10, 2025 12:41
@zucchini-nlp zucchini-nlp merged commit 2664ae7 into huggingface:main Jan 12, 2026
25 checks passed
vasqu pushed a commit that referenced this pull request Jan 13, 2026
* fix

* lets give users more time to adapt

* we don't patch updates to deprecation end cycle
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
* fix

* lets give users more time to adapt

* we don't patch updates to deprecation end cycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants