Skip to content

docs: clarify decoder_input_ids vs decoder_inputs_embeds usage (#39542) #40225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/source/en/main_classes/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ Custom models should also include a `_supports_assign_param_buffer`, which deter
on the particular model. Signs that your model needs this are if `test_save_and_load_from_pretrained` fails. If so,
set this to `False`.

> **Note on encoder-decoder models**
> When using seq2seq models such as MarianMT, BART, or T5, the decoder can take either
> - `decoder_input_ids` (integer token IDs), **or**
> - `decoder_inputs_embeds` (pre-computed embeddings).
>
> You must provide **only one of these arguments**, not both. Passing both will raise
> `ValueError: You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time`.
>
> If you are writing a custom model or overriding `forward`, ensure you only forward **one of these** to the decoder.

## ModuleUtilsMixin

[[autodoc]] modeling_utils.ModuleUtilsMixin
Expand Down