mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-04 05:10:06 +06:00
Minor error condition bug fix (#33781)
* Error condition bug fix * Update error message * Update src/transformers/models/qwen2_vl/modeling_qwen2_vl.py Co-authored-by: Pavel Iakubovskii <qubvel@gmail.com> * Making change in the rest of the repo * Formatting * Formatting with ruff --------- Co-authored-by: Pavel Iakubovskii <qubvel@gmail.com>
This commit is contained in:
parent
550673a70c
commit
2bd4d5897d
@ -882,7 +882,7 @@ class DummyModel(DummyPreTrainedModel):
|
|||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
"You must specify exactly one of input_ids or inputs_embeds"
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
|
@ -759,7 +759,7 @@ class MyNewModel2Model(MyNewModel2PreTrainedModel):
|
|||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
"You must specify exactly one of input_ids or inputs_embeds"
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
|
@ -620,9 +620,7 @@ class BloomModel(BloomPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -1278,9 +1278,7 @@ class ChameleonModel(ChameleonPreTrainedModel):
|
|||||||
use_cache = False
|
use_cache = False
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -459,9 +459,7 @@ class CodeGenModel(CodeGenPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -842,9 +842,7 @@ class CohereModel(CoherePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -991,9 +991,7 @@ class DbrxModel(DbrxPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -964,9 +964,7 @@ class FalconModel(FalconPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -650,9 +650,7 @@ class FalconMambaModel(FalconMambaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if inputs_embeds is None:
|
if inputs_embeds is None:
|
||||||
inputs_embeds = self.embeddings(input_ids)
|
inputs_embeds = self.embeddings(input_ids)
|
||||||
|
@ -754,9 +754,7 @@ class GemmaModel(GemmaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -667,9 +667,7 @@ class GemmaModel(LlamaModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -768,9 +768,7 @@ class Gemma2Model(Gemma2PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -605,9 +605,7 @@ class Gemma2Model(GemmaModel, Gemma2PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -674,9 +674,7 @@ class GPTNeoModel(GPTNeoPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -876,9 +876,7 @@ class GPTNeoXModel(GPTNeoXPreTrainedModel):
|
|||||||
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -603,9 +603,7 @@ class GPTNeoXJapaneseModel(GPTNeoXJapanesePreTrainedModel):
|
|||||||
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if inputs_embeds is None:
|
if inputs_embeds is None:
|
||||||
inputs_embeds = self.embed_in(input_ids)
|
inputs_embeds = self.embed_in(input_ids)
|
||||||
|
@ -746,9 +746,7 @@ class GPTJModel(GPTJPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -766,9 +766,7 @@ class GraniteModel(GranitePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -997,9 +997,7 @@ class GraniteMoeModel(GraniteMoePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -1172,9 +1172,7 @@ class IdeficsModel(IdeficsPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -1282,9 +1282,7 @@ class JambaModel(JambaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -972,9 +972,7 @@ class JetMoeModel(JetMoePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -878,9 +878,7 @@ class LlamaModel(LlamaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -444,9 +444,7 @@ class LlavaForConditionalGeneration(LlavaPreTrainedModel, GenerationMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -786,9 +786,7 @@ class LlavaNextForConditionalGeneration(LlavaNextPreTrainedModel, GenerationMixi
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -875,9 +875,7 @@ class LlavaNextVideoForConditionalGeneration(LlavaNextVideoPreTrainedModel, Gene
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -380,9 +380,7 @@ class LlavaNextVideoForConditionalGeneration(LlavaNextForConditionalGeneration):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -572,9 +572,7 @@ class LlavaOnevisionForConditionalGeneration(LlavaOnevisionPreTrainedModel, Gene
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
if (pixel_values is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -590,9 +590,7 @@ class MambaModel(MambaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if inputs_embeds is None:
|
if inputs_embeds is None:
|
||||||
inputs_embeds = self.embeddings(input_ids)
|
inputs_embeds = self.embeddings(input_ids)
|
||||||
|
@ -862,9 +862,7 @@ class Mamba2Model(Mamba2PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if inputs_embeds is None:
|
if inputs_embeds is None:
|
||||||
inputs_embeds = self.embeddings(input_ids)
|
inputs_embeds = self.embeddings(input_ids)
|
||||||
|
@ -749,9 +749,7 @@ class MistralModel(MistralPreTrainedModel):
|
|||||||
|
|
||||||
# retrieve input_ids and inputs_embeds
|
# retrieve input_ids and inputs_embeds
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -959,9 +959,7 @@ class MixtralModel(MixtralPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -1606,9 +1606,7 @@ class MllamaTextModel(MllamaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
@ -2145,9 +2143,7 @@ class MllamaForConditionalGeneration(MllamaPreTrainedModel, GenerationMixin):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -771,9 +771,7 @@ class NemotronModel(NemotronPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -799,9 +799,7 @@ class OlmoModel(OlmoPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -947,9 +947,7 @@ class OlmoeModel(OlmoePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -453,9 +453,7 @@ class PaliGemmaForConditionalGeneration(PaliGemmaPreTrainedModel, GenerationMixi
|
|||||||
```"""
|
```"""
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -621,9 +621,7 @@ class PersimmonModel(PersimmonPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -911,9 +911,7 @@ class PhiModel(PhiPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -938,9 +938,7 @@ class Phi3Model(Phi3PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -851,9 +851,7 @@ class Qwen2Model(Qwen2PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -1021,9 +1021,7 @@ class Qwen2MoeModel(Qwen2MoePreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -1126,9 +1126,7 @@ class Qwen2VLModel(Qwen2VLPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -695,9 +695,7 @@ class RecurrentGemmaModel(RecurrentGemmaPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training and use_cache:
|
if self.gradient_checkpointing and self.training and use_cache:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
|
@ -896,9 +896,7 @@ class StableLmModel(StableLmPreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -824,9 +824,7 @@ class Starcoder2Model(Starcoder2PreTrainedModel):
|
|||||||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.gradient_checkpointing and self.training:
|
if self.gradient_checkpointing and self.training:
|
||||||
if use_cache:
|
if use_cache:
|
||||||
|
@ -516,9 +516,7 @@ class VideoLlavaForConditionalGeneration(VideoLlavaPreTrainedModel, GenerationMi
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (pixel_values_images is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
if (pixel_values_images is not None or pixel_values_videos is not None) and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -441,9 +441,7 @@ class VipLlavaForConditionalGeneration(VipLlavaPreTrainedModel, GenerationMixin)
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (input_ids is None) ^ (inputs_embeds is not None):
|
if (input_ids is None) ^ (inputs_embeds is not None):
|
||||||
raise ValueError(
|
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
||||||
"You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pixel_values is not None and inputs_embeds is not None:
|
if pixel_values is not None and inputs_embeds is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
Reference in New Issue
Block a user