From 607dcce27903b8282a92bec0c0d79aac16fb8182 Mon Sep 17 00:00:00 2001 From: Richa Singh Date: Sun, 17 Aug 2025 11:14:09 +0545 Subject: [PATCH] docs(models): clarify decoder_input_ids vs decoder_inputs_embeds usage (#39542) --- docs/source/en/main_classes/model.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/en/main_classes/model.md b/docs/source/en/main_classes/model.md index 15345a7b2af3..04313c1a3c4f 100644 --- a/docs/source/en/main_classes/model.md +++ b/docs/source/en/main_classes/model.md @@ -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