Files
wehub-resource-sync e06fe8e8c6
Secret Leaks / trufflehog (push) Failing after 1s
Build documentation / build (push) Failing after 1s
Build documentation / build_other_lang (push) Failing after 0s
CodeQL Security Analysis / CodeQL Analysis (push) Failing after 0s
PR CI / pr-ci (push) Failing after 1s
Slow tests on important models (on Push - A10) / Get all modified files (push) Failing after 1s
Slow tests on important models (on Push - A10) / Model CI (push) Has been skipped
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:57:37 +08:00

1.6 KiB

Generation

每个框架都在它们各自的 GenerationMixin 类中实现了文本生成的 generate 方法:

  • PyTorch [~generation.GenerationMixin.generate] 在 [~generation.GenerationMixin] 中实现。

无论您选择哪个框架,都可以使用 [~generation.GenerationConfig] 类实例对 generate 方法进行参数化。有关生成方法的控制参数的完整列表,请参阅此类。

要了解如何检查模型的生成配置、默认值是什么、如何临时更改参数以及如何创建和保存自定义生成配置,请参阅 文本生成策略指南。该指南还解释了如何使用相关功能,如token流。

GenerationConfig

autodoc generation.GenerationConfig - from_pretrained - from_model_config - save_pretrained

GenerationMixin

autodoc generation.GenerationMixin - generate - compute_transition_scores