Buckets:
| import"../chunks/DsnmJJEf.js";import{i as Se,h as Qe,C as De,H as a,b as Oe,a as m,D as o,E as Ye,s as He}from"../chunks/CN3cOuQA.js";import{p as Ke,o as $e,s as e,f as p,a as d,b as eo,c as n,d as _,r as s,n as c}from"../chunks/DdiSzEty.js";import{T as z}from"../chunks/Biyddybe.js";import{E as x}from"../chunks/BpTh2jDR.js";import{H as Ie}from"../chunks/CvgQlE2K.js";const oo='{"title":"Ernie 4.5 VL MoE","local":"ernie-45-vl-moe","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage","local":"usage","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeConfig","local":"transformers.Ernie4_5_VLMoeConfig","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeTextConfig","local":"transformers.Ernie4_5_VLMoeTextConfig","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeVisionConfig","local":"transformers.Ernie4_5_VLMoeVisionConfig","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeImageProcessor","local":"transformers.Ernie4_5_VLMoeImageProcessor","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeImageProcessorPil","local":"transformers.Ernie4_5_VLMoeImageProcessorPil","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeVideoProcessor","local":"transformers.Ernie4_5_VLMoeVideoProcessor","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeProcessor","local":"transformers.Ernie4_5_VLMoeProcessor","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeTextModel","local":"transformers.Ernie4_5_VLMoeTextModel","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeVisionTransformerPretrainedModel","local":"transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeVariableResolutionResamplerModel","local":"transformers.Ernie4_5_VLMoeVariableResolutionResamplerModel","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeModel","local":"transformers.Ernie4_5_VLMoeModel","sections":[],"depth":2},{"title":"Ernie4_5_VLMoeForConditionalGeneration","local":"transformers.Ernie4_5_VLMoeForConditionalGeneration","sections":[],"depth":2}],"depth":1}';var no=_('<meta name="hf:doc:metadata"/>'),so=_("<!> <!>",1),C=_("<p>Example:</p> <!>",1),j=_(`<p>Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.</p>`),to=_(`<p></p> <p><em>This model was contributed to Hugging Face Transformers on 2025-12-19.</em></p> <!> <div style="float: right;"><div class="flex flex-wrap space-x-1"><img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"/> <img alt="Tensor parallelism" src="https://img.shields.io/badge/Tensor%20parallelism-06b6d4?style=flat&logoColor=white"/></div></div> <!> <!> <p>The Ernie 4.5 VL MoE model was released in the <a href="https://ernie.baidu.com/blog/posts/ernie4.5/" rel="nofollow">Ernie 4.5 Model Family</a> release by baidu. | |
| This family of models contains multiple different architectures and model sizes. The Vision-Language series in specific is | |
| composed of a novel multimodal heterogeneous structure, sharing parameters across modalities and dedicating parameters | |
| to specific modalities. This becomes especially apparent in the Mixture of Expert (MoE) which is composed of</p> <ul><li>Dedicated Text Experts</li> <li>Dedicated Vision Experts</li> <li>Shared Experts</li></ul> <p>This architecture has the advantage to enhance multimodal understanding without compromising, and even improving, performance on text-related tasks.</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/AntonV/doc-images/resolve/main/Ernie4_5_VL_Moe.png"/></div> <p>Other models from the family can be found at <a href="./ernie4_5">Ernie 4.5</a> and at <a href="./ernie4_5_moe">Ernie 4.5 MoE</a>.</p> <!> <p>The example below demonstrates how to generate text based on an image with <a href="/docs/transformers/pr_51549/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> or the <a href="/docs/transformers/pr_51549/en/model_doc/auto#transformers.AutoModel">AutoModel</a> class.</p> <!> <p>Using Ernie 4.5 VL MoE with video input is similar to using it with image input. | |
| The model can process video data and generate text based on the content of the video.</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a Ernie4_5_VLMoeModel. It is used to instantiate a Ernie4 5 Vl Moe | |
| model according to the specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a similar configuration to that of the <a href="https://huggingface.co/baidu/ERNIE-4.5-VL-28B-A3B-PT" rel="nofollow">baidu/ERNIE-4.5-VL-28B-A3B-PT</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the | |
| documentation from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p> <!></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a Ernie4_5_VLMoeModel. It is used to instantiate a Ernie4 5 Vl Moe | |
| model according to the specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a similar configuration to that of the <a href="https://huggingface.co/baidu/ERNIE-4.5-VL-28B-A3B-PT" rel="nofollow">baidu/ERNIE-4.5-VL-28B-A3B-PT</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the | |
| documentation from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a Ernie4_5_VLMoeModel. It is used to instantiate a Ernie4 5 Vl Moe | |
| model according to the specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a similar configuration to that of the <a href="https://huggingface.co/baidu/ERNIE-4.5-VL-28B-A3B-PT" rel="nofollow">baidu/ERNIE-4.5-VL-28B-A3B-PT</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the | |
| documentation from <a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Constructs a Ernie4_5_VLMoeImageProcessor image processor.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Constructs a Ernie4_5_VLMoeImageProcessor image processor.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Constructs a Ernie4_5_VLMoeVideoProcessor video processor.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Constructs a Ernie4_5_VLMoeProcessor which wraps a image processor, a tokenizer, and a video processor into a single processor.</p> <p><a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeProcessor">Ernie4_5_VLMoeProcessor</a> offers all the functionalities of <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeImageProcessor">Ernie4_5_VLMoeImageProcessor</a>, <code>tokenizer_class</code>, and <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeVideoProcessor">Ernie4_5_VLMoeVideoProcessor</a>. See the <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeImageProcessor">~Ernie4_5_VLMoeImageProcessor</a>, <code>~tokenizer_class</code>, and <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeVideoProcessor">~Ernie4_5_VLMoeVideoProcessor</a> for more information.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Ernie4 5 Vl Moe Text Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the | |
| library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads | |
| etc.)</p> <p>This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeTextModel">Ernie4_5_VLMoeTextModel</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p></li> <li><p><strong>cache</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</p> <p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if <code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>cache</code> input) to speed up sequential decoding.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.Tensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li> <li><p><strong>router_logits</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_router_probs=True</code> and <code>config.add_router_probs=True</code> is passed or when <code>config.output_router_probs=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p> <p>Raw router logits (post-softmax) that are computed by MoE routers, these terms are used to compute the auxiliary | |
| loss for Mixture of Experts models.</p></li></ul></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Ernie4 5 Vl Moe Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the | |
| library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads | |
| etc.)</p> <p>This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>grid_thw (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>): | |
| The temporal, height and width dimensions of feature shape for each image. Each row contains [t, h, w] values.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Ernie4 5 Vl Moe Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the | |
| library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads | |
| etc.)</p> <p>This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeModel">Ernie4_5_VLMoeModel</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the language model backbone. | |
| If <code>cache</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</li> <li><strong>cache</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if <code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>cache</code> input) to speed up sequential decoding.</li> <li><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>. | |
| Hidden-states of the language model backbone at the output of each layer plus the optional initial | |
| embedding outputs.</li> <li><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>. Attention weights of the language model backbone, after the attention softmax.</li> <li><strong>router_logits</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.output_router_logits=True</code>) — Tuple of <code>torch.Tensor</code> (one for each sparse layer) of shape <code>(batch_size * sequence_length, num_experts)</code>. | |
| Raw router logits computed by the MoE routers. They can be used to compute a load-balancing loss or to | |
| inspect how tokens are dispatched to experts.</li> <li><strong>image_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the image encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no images were processed.</li> <li><strong>video_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the video encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no videos were processed.</li> <li><strong>audio_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the audio encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no audio was processed.</li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing | |
| through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns | |
| the classification token after processing through a linear layer and a tanh activation function. The linear | |
| layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.Tensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing | |
| through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns | |
| the classification token after processing through a linear layer and a tanh activation function. The linear | |
| layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.Tensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeForConditionalGeneration">Ernie4_5_VLMoeForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</li> <li><strong>aux_loss</strong> (<code>torch.Tensor</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.output_router_logits=True</code>, and the model trains its router with a load-balancing loss) — Load-balancing auxiliary loss for the sparse modules. Models that balance their experts with a router bias | |
| instead (DeepSeek-V3 and the architectures derived from it) return <code>None</code> here while still returning <code>router_logits</code>.</li> <li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</li> <li><strong>cache</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if <code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>cache</code> input) to speed up sequential decoding.</li> <li><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>. | |
| Hidden-states of the language model backbone at the output of each layer plus the optional initial | |
| embedding outputs.</li> <li><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>. Attention weights of the language model backbone, after the attention softmax.</li> <li><strong>router_logits</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.output_router_logits=True</code>) — Tuple of <code>torch.Tensor</code> (one for each sparse layer) of shape <code>(batch_size * sequence_length, num_experts)</code>. | |
| Raw router logits computed by the MoE routers. They can be used to compute a load-balancing loss or to | |
| inspect how tokens are dispatched to experts.</li> <li><strong>image_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the image encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no images were processed.</li> <li><strong>video_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the video encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no videos were processed.</li> <li><strong>audio_outputs</strong> (<code>BaseModelOutputWithPooling</code>, <em>optional</em>) — Output of the audio encoder: <code>last_hidden_state</code>, <code>pooler_output</code>, <code>hidden_states</code> and <code>attentions</code>. <code>None</code> if no audio was processed.</li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing | |
| through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns | |
| the classification token after processing through a linear layer and a tanh activation function. The linear | |
| layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.Tensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing | |
| through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns | |
| the classification token after processing through a linear layer and a tanh activation function. The linear | |
| layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.Tensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul> <!></div></div> <!> <p></p>`,1);function po(Ve,Je){Ke(Je,!1),$e(()=>{new URLSearchParams(window.location.search).get("fw")}),Se();var P=to();Qe("2xin96",r=>{var i=no();He(i,"content",oo),d(r,i)});var N=e(p(P),4);De(N,{containerStyle:"float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"});var q=e(N,4);a(q,{title:"Ernie 4.5 VL MoE",local:"ernie-45-vl-moe",headingTag:"h1"});var R=e(q,2);a(R,{title:"Overview",local:"overview",headingTag:"h2"});var B=e(R,12);a(B,{title:"Usage",local:"usage",headingTag:"h2"});var W=e(B,4);Oe(W,{id:"usage",options:["Pipeline","AutoModel"],children:(r,i)=>{var t=so(),l=p(t);Ie(l,{id:"usage",option:"Pipeline",children:(L,Xe)=>{m(L,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHRhc2slM0QlMjJpbWFnZS10ZXh0LXRvLXRleHQlMjIlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmJhaWR1JTJGRVJOSUUtNC41LVZMLTI4Qi1BM0ItUFQlMjIlMkMlMEElMjAlMjAlMjAlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldmlzaW9uJTNEJTIycmVmcyUyRnByJTJGMTElMjIlMkMlMEEpJTBBbWVzc2FnZSUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoYXQlMjBraW5kJTIwb2YlMjBkb2clMjBpcyUyMHRoaXMlM0YlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ1cmwlMjIlM0ElMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZwaXBlbGluZS1jYXQtY2hvbmsuanBlZyUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSU1RCUwQXByaW50KHBpcGUodGV4dCUzRG1lc3NhZ2UlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwJTJDJTIwcmV0dXJuX2Z1bGxfdGV4dCUzREZhbHNlKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline | |
| pipe = pipeline( | |
| task=<span class="hljs-string">"image-text-to-text"</span>, | |
| model=<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| revision=<span class="hljs-string">"refs/pr/11"</span>, | |
| ) | |
| message = [ | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-string">"content"</span>: [ | |
| {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"What kind of dog is this?"</span>}, | |
| { | |
| <span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>, | |
| <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"</span>, | |
| }, | |
| ], | |
| } | |
| ] | |
| <span class="hljs-built_in">print</span>(pipe(text=message, max_new_tokens=<span class="hljs-number">20</span>, return_full_text=<span class="hljs-literal">False</span>))`,lang:"python",wrap:!1})},$$slots:{default:!0}});var Fe=e(l,2);Ie(Fe,{id:"usage",option:"AutoModel",children:(L,Xe)=>{m(L,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dCUyQyUyMEF1dG9Qcm9jZXNzb3IlMEElMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyYmFpZHUlMkZFUk5JRS00LjUtVkwtMjhCLUEzQi1QVCUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTIwJTIwJTIzJTIwVXNlJTIwdHBfcGxhbiUzRCUyMmF1dG8lMjIlMjBpbnN0ZWFkJTIwdG8lMjBlbmFibGUlMjBUZW5zb3IlMjBQYXJhbGxlbGlzbSElMEElMjAlMjAlMjAlMjByZXZpc2lvbiUzRCUyMnJlZnMlMkZwciUyRjExJTIyJTJDJTBBKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmJhaWR1JTJGRVJOSUUtNC41LVZMLTI4Qi1BM0ItUFQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjMlMjB1c2VfZmFzdCUzREZhbHNlJTJDJTIwJTIwJTIzJTIwY2xvc2VyJTIwdG8lMjB0aGUlMjBvcmlnaW5hbCUyMGltcGxlbWVudGF0aW9uJTIwZm9yJTIwbGVzcyUyMHNwZWVkJTBBJTIwJTIwJTIwJTIwcmV2aXNpb24lM0QlMjJyZWZzJTJGcHIlMkYxMSUyMiUyQyUwQSklMEFtZXNzYWdlJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJjb250ZW50JTIyJTNBJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyV2hhdCUyMGtpbmQlMjBvZiUyMGRvZyUyMGlzJTIwdGhpcyUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnVybCUyMiUzQSUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnBpcGVsaW5lLWNhdC1jaG9uay5qcGVnJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTVEJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoJTBBJTIwJTIwJTIwJTIwbWVzc2FnZSUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKS50byhtb2RlbC5kZXZpY2UpJTBBJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMjgpJTBBZ2VuZXJhdGVkX2lkc190cmltbWVkJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwb3V0X2lkcyU1Qmxlbihpbl9pZHMpJTIwJTNBJTVEJTIwZm9yJTIwaW5faWRzJTJDJTIwb3V0X2lkcyUyMGluJTIwemlwKGlucHV0cy5pbnB1dF9pZHMlMkMlMjBnZW5lcmF0ZWRfaWRzKSUwQSU1RCUwQW91dHB1dF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZSglMEElMjAlMjAlMjAlMjBnZW5lcmF0ZWRfaWRzX3RyaW1tZWQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSUwQSklMEFwcmludChvdXRwdXRfdGV4dCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageTextToText, AutoProcessor | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| <span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, <span class="hljs-comment"># Use tp_plan="auto" instead to enable Tensor Parallelism!</span> | |
| revision=<span class="hljs-string">"refs/pr/11"</span>, | |
| ) | |
| processor = AutoProcessor.from_pretrained( | |
| <span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>, | |
| <span class="hljs-comment"># use_fast=False, # closer to the original implementation for less speed</span> | |
| revision=<span class="hljs-string">"refs/pr/11"</span>, | |
| ) | |
| message = [ | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-string">"content"</span>: [ | |
| {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"What kind of dog is this?"</span>}, | |
| { | |
| <span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>, | |
| <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"</span>, | |
| }, | |
| ], | |
| } | |
| ] | |
| inputs = processor.apply_chat_template( | |
| message, | |
| add_generation_prompt=<span class="hljs-literal">True</span>, | |
| tokenize=<span class="hljs-literal">True</span>, | |
| return_dict=<span class="hljs-literal">True</span>, | |
| return_tensors=<span class="hljs-string">"pt"</span> | |
| ).to(model.device) | |
| generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">128</span>) | |
| generated_ids_trimmed = [ | |
| out_ids[<span class="hljs-built_in">len</span>(in_ids) :] <span class="hljs-keyword">for</span> in_ids, out_ids <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(inputs.input_ids, generated_ids) | |
| ] | |
| output_text = processor.batch_decode( | |
| generated_ids_trimmed, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span> | |
| ) | |
| <span class="hljs-built_in">print</span>(output_text)`,lang:"python",wrap:!1})},$$slots:{default:!0}}),d(r,t)},$$slots:{default:!0}});var A=e(W,4);m(A,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dCUyQyUyMEF1dG9Qcm9jZXNzb3IlMEElMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyYmFpZHUlMkZFUk5JRS00LjUtVkwtMjhCLUEzQi1QVCUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTIwJTIwJTIzJTIwVXNlJTIwdHBfcGxhbiUzRCUyMmF1dG8lMjIlMjBpbnN0ZWFkJTIwdG8lMjBlbmFibGUlMjBUZW5zb3IlMjBQYXJhbGxlbGlzbSElMEElMjAlMjAlMjAlMjByZXZpc2lvbiUzRCUyMnJlZnMlMkZwciUyRjExJTIyJTJDJTBBKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmJhaWR1JTJGRVJOSUUtNC41LVZMLTI4Qi1BM0ItUFQlMjIlMkMlMjByZXZpc2lvbiUzRCUyMnJlZnMlMkZwciUyRjExJTIyKSUwQW1lc3NhZ2UlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIydGV4dCUyMiUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjJQbGVhc2UlMjBkZXNjcmliZSUyMHdoYXQlMjB5b3UlMjBjYW4lMjBzZWUlMjBkdXJpbmclMjB0aGlzJTIwdmlkZW8uJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydHlwZSUyMiUzQSUyMCUyMnZpZGVvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydXJsJTIyJTNBJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGcmF1c2hhbi10ZXN0aW5nLWhmJTJGdmlkZW9zLXRlc3QlMkZyZXNvbHZlJTJGbWFpbiUyRnRpbnlfdmlkZW8ubXA0JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTVEJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoJTBBJTIwJTIwJTIwJTIwbWVzc2FnZSUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKS50byhtb2RlbC5kZXZpY2UpJTBBJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMjgpJTBBZ2VuZXJhdGVkX2lkc190cmltbWVkJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwb3V0X2lkcyU1Qmxlbihpbl9pZHMpJTIwJTNBJTVEJTIwZm9yJTIwaW5faWRzJTJDJTIwb3V0X2lkcyUyMGluJTIwemlwKGlucHV0cy5pbnB1dF9pZHMlMkMlMjBnZW5lcmF0ZWRfaWRzKSUwQSU1RCUwQW91dHB1dF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZSglMEElMjAlMjAlMjAlMjBnZW5lcmF0ZWRfaWRzX3RyaW1tZWQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSUwQSklMEFwcmludChvdXRwdXRfdGV4dCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageTextToText, AutoProcessor | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| <span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, <span class="hljs-comment"># Use tp_plan="auto" instead to enable Tensor Parallelism!</span> | |
| revision=<span class="hljs-string">"refs/pr/11"</span>, | |
| ) | |
| processor = AutoProcessor.from_pretrained(<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>, revision=<span class="hljs-string">"refs/pr/11"</span>) | |
| message = [ | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-string">"content"</span>: [ | |
| {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Please describe what you can see during this video."</span>}, | |
| { | |
| <span class="hljs-string">"type"</span>: <span class="hljs-string">"video"</span>, | |
| <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://huggingface.co/datasets/raushan-testing-hf/videos-test/resolve/main/tiny_video.mp4"</span>, | |
| }, | |
| ], | |
| } | |
| ] | |
| inputs = processor.apply_chat_template( | |
| message, | |
| add_generation_prompt=<span class="hljs-literal">True</span>, | |
| tokenize=<span class="hljs-literal">True</span>, | |
| return_dict=<span class="hljs-literal">True</span>, | |
| return_tensors=<span class="hljs-string">"pt"</span> | |
| ).to(model.device) | |
| generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">128</span>) | |
| generated_ids_trimmed = [ | |
| out_ids[<span class="hljs-built_in">len</span>(in_ids) :] <span class="hljs-keyword">for</span> in_ids, out_ids <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(inputs.input_ids, generated_ids) | |
| ] | |
| output_text = processor.batch_decode( | |
| generated_ids_trimmed, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span> | |
| ) | |
| <span class="hljs-built_in">print</span>(output_text)`,lang:"python",wrap:!1});var Z=e(A,2);a(Z,{title:"Ernie4_5_VLMoeConfig",local:"transformers.Ernie4_5_VLMoeConfig",headingTag:"h2"});var h=e(Z,2),G=n(h);o(G,{name:"class transformers.Ernie4_5_VLMoeConfig",anchor:"transformers.Ernie4_5_VLMoeConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/configuration_ernie4_5_vl_moe.py#L152",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"text_config",val:": dict | transformers.configuration_utils.PreTrainedConfig | None = None"},{name:"vision_config",val:": dict | transformers.configuration_utils.PreTrainedConfig | None = None"},{name:"image_start_token_id",val:": int = 101304"},{name:"image_end_token_id",val:": int = 101305"},{name:"image_token_id",val:": int = 100295"},{name:"video_start_token_id",val:": int = 101306"},{name:"video_end_token_id",val:": int = 101307"},{name:"video_token_id",val:": int = 103367"},{name:"tie_word_embeddings",val:": bool = True"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeConfig.text_config",description:`<strong>text_config</strong> (<code>Union[dict, ~configuration_utils.PreTrainedConfig]</code>, <em>optional</em>) — | |
| The config object or dictionary of the text backbone.`,name:"text_config"},{anchor:"transformers.Ernie4_5_VLMoeConfig.vision_config",description:`<strong>vision_config</strong> (<code>Union[dict, ~configuration_utils.PreTrainedConfig]</code>, <em>optional</em>) — | |
| The config object or dictionary of the vision backbone.`,name:"vision_config"},{anchor:"transformers.Ernie4_5_VLMoeConfig.image_start_token_id",description:`<strong>image_start_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 101304) — | |
| The image token index to encode the start of image.`,name:"image_start_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.image_end_token_id",description:`<strong>image_end_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 101305) — | |
| The image token index to encode the end of image.`,name:"image_end_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 100295) — | |
| The image token index to encode the image prompt.`,name:"image_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.video_start_token_id",description:`<strong>video_start_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 101306) — | |
| The video token index to encode the start of video.`,name:"video_start_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.video_end_token_id",description:`<strong>video_end_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 101307) — | |
| The video token index to encode the end of video.`,name:"video_end_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.video_token_id",description:`<strong>video_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 103367) — | |
| The video token index to encode the video prompt.`,name:"video_token_id"},{anchor:"transformers.Ernie4_5_VLMoeConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to tie weight embeddings according to model’s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"}]});var Ee=e(G,6);x(Ee,{anchor:"transformers.Ernie4_5_VLMoeConfig.example",children:(r,i)=>{var t=C(),l=e(p(t),2);m(l,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVybmllNF81X1ZMTW9lRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTIwRXJuaWU0XzVfVkxNb2VDb25maWclMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwRXJuaWU0XzVfVkxNb2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwRXJuaWU0XzVfVkxNb2VDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBFcm5pZSUyMDQuNSUyMFZMJTIwMjhCJTIwQTNCJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwRXJuaWU0XzVfVkxNb2VGb3JDb25kaXRpb25hbEdlbmVyYXRpb24oY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Ernie4_5_VLMoeForConditionalGeneration, Ernie4_5_VLMoeConfig | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a Ernie4_5_VLMoe style configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = Ernie4_5_VLMoeConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the Ernie 4.5 VL 28B A3B configuration</span> | |
| <span class="hljs-meta">>>> </span>model = Ernie4_5_VLMoeForConditionalGeneration(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,lang:"python",wrap:!1}),d(r,t)},$$slots:{default:!0}}),s(h);var F=e(h,2);a(F,{title:"Ernie4_5_VLMoeTextConfig",local:"transformers.Ernie4_5_VLMoeTextConfig",headingTag:"h2"});var g=e(F,2),Ue=n(g);o(Ue,{name:"class transformers.Ernie4_5_VLMoeTextConfig",anchor:"transformers.Ernie4_5_VLMoeTextConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/configuration_ernie4_5_vl_moe.py#L65",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"vocab_size",val:": int = 103424"},{name:"pad_token_id",val:": int | None = None"},{name:"bos_token_id",val:": int | None = None"},{name:"eos_token_id",val:": int | list[int] | None = None"},{name:"hidden_size",val:": int = 2560"},{name:"intermediate_size",val:": int = 12288"},{name:"num_hidden_layers",val:": int = 28"},{name:"num_attention_heads",val:": int = 20"},{name:"num_key_value_heads",val:": int | None = 4"},{name:"hidden_act",val:": str = 'silu'"},{name:"max_position_embeddings",val:": int = 131072"},{name:"initializer_range",val:": float = 0.02"},{name:"rms_norm_eps",val:": float = 1e-05"},{name:"use_cache",val:": bool = True"},{name:"tie_word_embeddings",val:": bool = True"},{name:"rope_parameters",val:": transformers.modeling_rope_utils.RopeParameters | dict | None = None"},{name:"use_bias",val:": bool | None = False"},{name:"moe_intermediate_size",val:": list[int] | None = None"},{name:"moe_k",val:": int | None = 6"},{name:"moe_num_experts",val:": int | None = 64"},{name:"moe_num_shared_experts",val:": int | None = 2"},{name:"moe_norm_min",val:": float | None = 1e-12"},{name:"output_router_logits",val:": bool | None = False"},{name:"router_aux_loss_coef",val:": float | None = 0.001"},{name:"mlp_layer_types",val:": list[str] | None = None"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeTextConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>103424</code>) — | |
| Vocabulary size of the model. Defines the number of different tokens that can be represented by the <code>input_ids</code>.`,name:"vocab_size"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>) — | |
| Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2560</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>12288</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>28</code>) — | |
| Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>20</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4</code>) — | |
| This is the number of key_value heads that should be used to implement Grouped Query Attention. If | |
| <code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if | |
| <code>num_key_value_heads=1</code> the model will use Multi Query Attention (MQA) otherwise GQA is used. When | |
| converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed | |
| by meanpooling all the original heads within that group. For more details, check out <a href="https://huggingface.co/papers/2305.13245" rel="nofollow">this | |
| paper</a>. If it is not specified, will default to | |
| <code>num_attention_heads</code>.`,name:"num_key_value_heads"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>silu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>131072</code>) — | |
| The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-05</code>) — | |
| The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not the model should return the last key/values attentions (not used by all models). Only | |
| relevant if <code>config.is_decoder=True</code> or when the model is a decoder-only generative model.`,name:"use_cache"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to tie weight embeddings according to model’s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.rope_parameters",description:`<strong>rope_parameters</strong> (<code>Union[~modeling_rope_utils.RopeParameters, dict]</code>, <em>optional</em>) — | |
| Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain | |
| a value for <code>rope_theta</code> and optionally parameters used for scaling in case you want to use RoPE | |
| with longer <code>max_position_embeddings</code>.`,name:"rope_parameters"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.use_bias",description:`<strong>use_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a bias in any of the projections including mlp and attention for example`,name:"use_bias"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.moe_intermediate_size",description:`<strong>moe_intermediate_size</strong> (<code>list[int]</code>, <em>optional</em>) — | |
| Intermediate size of the routed expert MLPs.`,name:"moe_intermediate_size"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.moe_k",description:`<strong>moe_k</strong> (<code>int</code>, <em>optional</em>, defaults to 6) — | |
| Number of selected experts.`,name:"moe_k"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.moe_num_experts",description:`<strong>moe_num_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 64) — | |
| Number of routed experts.`,name:"moe_num_experts"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.moe_num_shared_experts",description:`<strong>moe_num_shared_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 2) — | |
| The number of experts that are shared for all MoE forwards.`,name:"moe_num_shared_experts"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.moe_norm_min",description:`<strong>moe_norm_min</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) — | |
| Minimum division value during routing normalization.`,name:"moe_norm_min"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the router logits should be returned by the model. Enabling this will also allow the model | |
| to output the auxiliary loss, including load balancing loss and router z-loss.`,name:"output_router_logits"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.router_aux_loss_coef",description:`<strong>router_aux_loss_coef</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.001</code>) — | |
| Auxiliary load balancing loss coefficient. Used to penalize uneven expert routing in MoE models.`,name:"router_aux_loss_coef"},{anchor:"transformers.Ernie4_5_VLMoeTextConfig.mlp_layer_types",description:`<strong>mlp_layer_types</strong> (<code>list</code>, <em>optional</em>) — | |
| MLP (Moe vs Dense) pattern for each layer.`,name:"mlp_layer_types"}]}),c(4),s(g);var X=e(g,2);a(X,{title:"Ernie4_5_VLMoeVisionConfig",local:"transformers.Ernie4_5_VLMoeVisionConfig",headingTag:"h2"});var u=e(X,2),ke=n(u);o(ke,{name:"class transformers.Ernie4_5_VLMoeVisionConfig",anchor:"transformers.Ernie4_5_VLMoeVisionConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/configuration_ernie4_5_vl_moe.py#L32",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"depth",val:": int = 32"},{name:"hidden_size",val:": int = 1280"},{name:"hidden_act",val:": str = 'quick_gelu'"},{name:"num_heads",val:": int = 16"},{name:"in_channels",val:": int = 3"},{name:"patch_size",val:": int | list[int] | tuple[int, int] = 14"},{name:"spatial_merge_size",val:": int = 2"},{name:"initializer_range",val:": float = 0.02"},{name:"rope_parameters",val:": dict | None = None"},{name:"intermediate_size",val:": int = 5120"},{name:"temporal_merge_size",val:": int = 2"},{name:"rms_norm_eps",val:": float = 1e-06"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.depth",description:`<strong>depth</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) — | |
| Number of Transformer layers in the vision encoder.`,name:"depth"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1280</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>quick_gelu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.num_heads",description:`<strong>num_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>16</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_heads"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>3</code>) — | |
| The number of input channels.`,name:"in_channels"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>Union[int, list[int], tuple[int, int]]</code>, <em>optional</em>, defaults to <code>14</code>) — | |
| The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.spatial_merge_size",description:`<strong>spatial_merge_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| The size of the spatial merge window used to reduce the number of visual tokens by merging neighboring patches.`,name:"spatial_merge_size"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.rope_parameters",description:`<strong>rope_parameters</strong> (<code>dict</code>, <em>optional</em>) — | |
| Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain | |
| a value for <code>rope_theta</code> and optionally parameters used for scaling in case you want to use RoPE | |
| with longer <code>max_position_embeddings</code>.`,name:"rope_parameters"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>5120</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.temporal_merge_size",description:`<strong>temporal_merge_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) — | |
| The size used for merge along the temporal dimension.`,name:"temporal_merge_size"},{anchor:"transformers.Ernie4_5_VLMoeVisionConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-06</code>) — | |
| The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"}]}),c(4),s(u);var S=e(u,2);a(S,{title:"Ernie4_5_VLMoeImageProcessor",local:"transformers.Ernie4_5_VLMoeImageProcessor",headingTag:"h2"});var f=e(S,2),Q=n(f);o(Q,{name:"class transformers.Ernie4_5_VLMoeImageProcessor",anchor:"transformers.Ernie4_5_VLMoeImageProcessor",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/image_processing_ernie4_5_vl_moe.py#L82",parameters:[{name:"**kwargs",val:": *<class 'transformers.models.ernie4_5_vl_moe.image_processing_ernie4_5_vl_moe.Ernie4_5_VLMoeImageProcessorKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>, defaults to <code>{'shortest_edge' -- 3136, 'longest_edge': 4842768}</code>): | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>, defaults to <code>3</code>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>0.00392156862745098</code>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.48145466, 0.4578275, 0.40821073]</code>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.26862954, 0.26130258, 0.27577711]</code>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The channel dimension format for the input image. If unset, the channel dimension format is inferred | |
| from the input image. Can be one of: | |
| <ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 14) — | |
| The spatial patch size of the vision encoder.`,name:"patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.temporal_patch_size",description:`<strong>temporal_patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The temporal patch size of the vision encoder. Unused in the image processor, only used for videos.`,name:"temporal_patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.merge_size",description:`<strong>merge_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 2) — | |
| The merge size of the vision encoder to llm encoder.`,name:"merge_size"}]});var D=e(Q,4),Le=n(D);o(Le,{name:"preprocess",anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/image_processing_ernie4_5_vl_moe.py#L101",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"**kwargs",val:": *<class 'transformers.models.ernie4_5_vl_moe.image_processing_ernie4_5_vl_moe.Ernie4_5_VLMoeImageProcessorKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>) — | |
| Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If | |
| passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The channel dimension format for the input image. If unset, the channel dimension format is inferred | |
| from the input image. Can be one of: | |
| <ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 14) — | |
| The spatial patch size of the vision encoder.`,name:"patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.temporal_patch_size",description:`<strong>temporal_patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The temporal patch size of the vision encoder. Unused in the image processor, only used for videos.`,name:"temporal_patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessor.preprocess.merge_size",description:`<strong>merge_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 2) — | |
| The merge size of the vision encoder to llm encoder.`,name:"merge_size"}],returnDescription:` | |
| <ul> | |
| <li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li> | |
| <li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at | |
| initialization.</li> | |
| </ul> | |
| `,returnType:` | |
| <p><code>~image_processing_base.BatchFeature</code></p> | |
| `}),s(D),s(f);var O=e(f,2);a(O,{title:"Ernie4_5_VLMoeImageProcessorPil",local:"transformers.Ernie4_5_VLMoeImageProcessorPil",headingTag:"h2"});var M=e(O,2),Y=n(M);o(Y,{name:"class transformers.Ernie4_5_VLMoeImageProcessorPil",anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/image_processing_pil_ernie4_5_vl_moe.py#L79",parameters:[{name:"**kwargs",val:": *<class 'transformers.models.ernie4_5_vl_moe.image_processing_pil_ernie4_5_vl_moe.Ernie4_5_VLMoeImageProcessorKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>, defaults to <code>{'shortest_edge' -- 3136, 'longest_edge': 4842768}</code>): | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>, defaults to <code>3</code>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>0.00392156862745098</code>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.48145466, 0.4578275, 0.40821073]</code>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.26862954, 0.26130258, 0.27577711]</code>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The channel dimension format for the input image. If unset, the channel dimension format is inferred | |
| from the input image. Can be one of: | |
| <ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 14) — | |
| The spatial patch size of the vision encoder.`,name:"patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.temporal_patch_size",description:`<strong>temporal_patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The temporal patch size of the vision encoder. Unused in the image processor, only used for videos.`,name:"temporal_patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.merge_size",description:`<strong>merge_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 2) — | |
| The merge size of the vision encoder to llm encoder.`,name:"merge_size"}]});var H=e(Y,4),ze=n(H);o(ze,{name:"preprocess",anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/image_processing_pil_ernie4_5_vl_moe.py#L161",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"**kwargs",val:": *<class 'transformers.models.ernie4_5_vl_moe.image_processing_pil_ernie4_5_vl_moe.Ernie4_5_VLMoeImageProcessorKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>) — | |
| Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If | |
| passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The channel dimension format for the input image. If unset, the channel dimension format is inferred | |
| from the input image. Can be one of: | |
| <ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 14) — | |
| The spatial patch size of the vision encoder.`,name:"patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.temporal_patch_size",description:`<strong>temporal_patch_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The temporal patch size of the vision encoder. Unused in the image processor, only used for videos.`,name:"temporal_patch_size"},{anchor:"transformers.Ernie4_5_VLMoeImageProcessorPil.preprocess.merge_size",description:`<strong>merge_size</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>, defaults to 2) — | |
| The merge size of the vision encoder to llm encoder.`,name:"merge_size"}],returnDescription:` | |
| <ul> | |
| <li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li> | |
| <li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at | |
| initialization.</li> | |
| </ul> | |
| `,returnType:` | |
| <p><code>~image_processing_base.BatchFeature</code></p> | |
| `}),s(H),s(M);var K=e(M,2);a(K,{title:"Ernie4_5_VLMoeVideoProcessor",local:"transformers.Ernie4_5_VLMoeVideoProcessor",headingTag:"h2"});var T=e(K,2),$=n(T);o($,{name:"class transformers.Ernie4_5_VLMoeVideoProcessor",anchor:"transformers.Ernie4_5_VLMoeVideoProcessor",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/video_processing_ernie4_5_vl_moe.py#L96",parameters:[{name:"**kwargs",val:": *<class 'transformers.models.ernie4_5_vl_moe.video_processing_ernie4_5_vl_moe.Ernie4_5_VLMoeVideoProcessorInitKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.*kwargs",description:`*<strong>*kwargs</strong> (<code>Ernie4_5_VLMoeVideoProcessorInitKwargs</code>, <em>optional</em>) — | |
| Additional processing options for each modality (text, images, videos, audio). Model-specific parameters | |
| are listed above; see the TypedDict class for the complete list of supported arguments.`,name:"*kwargs"}]});var ee=e($,4),xe=n(ee);o(xe,{name:"preprocess",anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/video_processing_ernie4_5_vl_moe.py#L575",parameters:[{name:"videos",val:": typing.Union[list['PIL.Image.Image'], numpy.ndarray, ForwardRef('torch.Tensor'), list[numpy.ndarray], list['torch.Tensor'], list[list['PIL.Image.Image']], list[list[numpy.ndarray]], list[list['torch.Tensor']], transformers.video_utils.URL, list[transformers.video_utils.URL], list[list[transformers.video_utils.URL]], transformers.video_utils.Path, list[transformers.video_utils.Path], list[list[transformers.video_utils.Path]]]"},{name:"**kwargs",val:": *<class 'transformers.processing_utils.VideosKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.videos",description:`<strong>videos</strong> (<code>Union[list[PIL.Image.Image], numpy.ndarray, torch.Tensor, list[numpy.ndarray], list[torch.Tensor], list[list[PIL.Image.Image]], list[list[numpy.ndarray]], list[list[torch.Tensor]], ~video_utils.URL, list[~video_utils.URL], list[list[~video_utils.URL]], ~video_utils.Path, list[~video_utils.Path], list[list[~video_utils.Path]]]</code>) — | |
| Video to preprocess. Expects a single or batch of videos with pixel values ranging from 0 to 255. If | |
| passing in videos with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"videos"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The channel dimension format for the input image. If unset, the channel dimension format is inferred | |
| from the input image. Can be one of: | |
| <ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.do_sample_frames",description:`<strong>do_sample_frames</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to sample frames from the video before processing or to process the whole video.`,name:"do_sample_frames"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.video_metadata",description:`<strong>video_metadata</strong> (<code>Annotated[~video_utils.VideoMetadata | dict | list[dict | ~video_utils.VideoMetadata] | list[list[dict | ~video_utils.VideoMetadata]] | None, None]</code>, <em>kwargs</em>) — | |
| Metadata of the video containing information about total duration, fps and total number of frames. It will be | |
| used to sample frames from video or compute timestamps. Don’t pass any metadata unless you are trying to decode | |
| the video manually before processing`,name:"video_metadata"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.fps",description:`<strong>fps</strong> (<code>Annotated[int | float | None, None]</code>, <em>kwargs</em>) — | |
| Target frames to sample per second when <code>do_sample_frames=True</code>.`,name:"fps"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.num_frames",description:`<strong>num_frames</strong> (<code>Annotated[int | None, None]</code>, <em>kwargs</em>) — | |
| Maximum number of frames to sample when <code>do_sample_frames=True</code>.`,name:"num_frames"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.return_metadata",description:`<strong>return_metadata</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to return video metadata or not. Video metadats is an object containing info about video duration, fps, | |
| decoding backend, etc.`,name:"return_metadata"},{anchor:"transformers.Ernie4_5_VLMoeVideoProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"}],returnDescription:` | |
| <ul> | |
| <li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li> | |
| <li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at | |
| initialization.</li> | |
| </ul> | |
| `,returnType:` | |
| <p><code>~image_processing_base.BatchFeature</code></p> | |
| `}),s(ee),s(T);var oe=e(T,2);a(oe,{title:"Ernie4_5_VLMoeProcessor",local:"transformers.Ernie4_5_VLMoeProcessor",headingTag:"h2"});var y=e(oe,2),ne=n(y);o(ne,{name:"class transformers.Ernie4_5_VLMoeProcessor",anchor:"transformers.Ernie4_5_VLMoeProcessor",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/processing_ernie4_5_vl_moe.py#L30",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"video_processor",val:" = None"},{name:"chat_template",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeProcessor.image_processor",description:`<strong>image_processor</strong> (<code>Ernie4_5_VLMoeImageProcessor</code>) — | |
| The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.tokenizer",description:`<strong>tokenizer</strong> (<code>tokenizer_class</code>) — | |
| The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.video_processor",description:`<strong>video_processor</strong> (<code>Ernie4_5_VLMoeVideoProcessor</code>) — | |
| The video processor is a required input.`,name:"video_processor"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.chat_template",description:`<strong>chat_template</strong> (<code>str</code>) — | |
| A Jinja template to convert lists of messages in a chat into a tokenizable string.`,name:"chat_template"}]});var se=e(ne,6),Ce=n(se);o(Ce,{name:"__call__",anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/processing_ernie4_5_vl_moe.py#L65",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor'], NoneType] = None"},{name:"text",val:": str | list[str] | None = None"},{name:"videos",val:": typing.Union[list['PIL.Image.Image'], numpy.ndarray, ForwardRef('torch.Tensor'), list[numpy.ndarray], list['torch.Tensor'], list[list['PIL.Image.Image']], list[list[numpy.ndarray]], list[list['torch.Tensor']], transformers.video_utils.URL, list[transformers.video_utils.URL], list[list[transformers.video_utils.URL]], transformers.video_utils.Path, list[transformers.video_utils.Path], list[list[transformers.video_utils.Path]], NoneType] = None"},{name:"**kwargs",val:": *<class 'transformers.processing_utils.ProcessingKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>, <em>optional</em>) — | |
| Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If | |
| passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.text",description:`<strong>text</strong> (<code>Union[str, list[str]]</code>, <em>optional</em>) — | |
| The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings | |
| (pretokenized string). If you pass a pretokenized input, set <code>is_split_into_words=True</code> to avoid ambiguity with batched inputs.`,name:"text"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.videos",description:`<strong>videos</strong> (<code>Union[list[PIL.Image.Image], numpy.ndarray, torch.Tensor, list[numpy.ndarray], list[torch.Tensor], list[list[PIL.Image.Image]], list[list[numpy.ndarray]], list[list[torch.Tensor]], ~video_utils.URL, list[~video_utils.URL], list[list[~video_utils.URL]], ~video_utils.Path, list[~video_utils.Path], list[list[~video_utils.Path]]]</code>, <em>optional</em>) — | |
| Video to preprocess. Expects a single or batch of videos with pixel values ranging from 0 to 255. If | |
| passing in videos with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"videos"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.return_mm_token_type_ids",description:`<strong>return_mm_token_type_ids</strong> (<code>bool</code>, <em>kwargs</em>) — | |
| Whether to return multimodal token type ids indicating multimodal placeholder token positions.`,name:"return_mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.return_text_replacement_offsets",description:`<strong>return_text_replacement_offsets</strong> (<code>bool</code>, <em>kwargs</em>) — | |
| Whether to return character offsets for each multimodal placeholder and its replacement.`,name:"return_text_replacement_offsets"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_51549/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) — | |
| If set, will return tensors of a particular framework. Acceptable values are: | |
| <ul> | |
| <li><code>'pt'</code>: Return PyTorch <code>torch.Tensor</code> objects.</li> | |
| <li><code>'np'</code>: Return NumPy <code>np.ndarray</code> objects.</li> | |
| </ul>`,name:"return_tensors"},{anchor:"transformers.Ernie4_5_VLMoeProcessor.__call__.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_51549/en/main_classes/processors#transformers.ProcessingKwargs">ProcessingKwargs</a>, <em>optional</em>) — | |
| Additional processing options for each modality (text, images, videos, audio). Model-specific parameters | |
| are listed above; see the TypedDict class for the complete list of supported arguments.`,name:"*kwargs"}]}),s(se),s(y);var te=e(y,2);a(te,{title:"Ernie4_5_VLMoeTextModel",local:"transformers.Ernie4_5_VLMoeTextModel",headingTag:"h2"});var b=e(te,2),re=n(b);o(re,{name:"class transformers.Ernie4_5_VLMoeTextModel",anchor:"transformers.Ernie4_5_VLMoeTextModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L706",parameters:[{name:"config",val:": Ernie4_5_VLMoeTextConfig"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeTextModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeTextConfig">Ernie4_5_VLMoeTextConfig</a>) — | |
| Model configuration class with all the parameters of the model. Initializing with a config file does not | |
| load the weights associated with the model, only the configuration. Check out the | |
| <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var ae=e(re,8),ie=n(ae);o(ie,{name:"forward",anchor:"transformers.Ernie4_5_VLMoeTextModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L725",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"moe_mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"use_cache",val:": bool | None = None"},{name:"**kwargs",val:": *<class 'transformers.modeling_flash_attention_utils.FlashAttentionKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default. | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_51549/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a></p>`,name:"input_ids"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>: | |
| <ul> | |
| <li>1 for tokens that are <strong>not masked</strong>,</li> | |
| <li>0 for tokens that are <strong>masked</strong>.</li> | |
| </ul> | |
| <p><a href="../glossary#attention-mask">What are attention masks?</a></p>`,name:"attention_mask"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. | |
| <p><a href="../glossary#position-ids">What are position IDs?</a></p>`,name:"position_ids"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.moe_mm_token_type_ids",description:`<strong>moe_mm_token_type_ids</strong> (<code>torch.IntTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| The same as <code>mm_token_type_ids</code> while additionally considering start/end image/video tokens as respective vision tokens.`,name:"moe_mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.cache",description:`<strong>cache</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) — | |
| Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention | |
| blocks) that can be used to speed up sequential decoding. This typically consists in the <code>cache</code> | |
| returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>. | |
| <p>Only <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>cache</code> are passed, <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>cache</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.</p>`,name:"cache"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This | |
| is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the | |
| model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Ernie4_5_VLMoeTextModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| If set to <code>True</code>, <code>cache</code> key value states are returned and can be used to speed up decoding (see | |
| <code>cache</code>).`,name:"use_cache"}],returnDescription:` | |
| <p>A <code>MoeModelOutputWithPast</code> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>MoeModelOutputWithPast</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var je=e(ie,4);z(je,{children:(r,i)=>{var t=j();d(r,t)},$$slots:{default:!0}}),c(2),s(ae),s(b);var de=e(b,2);a(de,{title:"Ernie4_5_VLMoeVisionTransformerPretrainedModel",local:"transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel",headingTag:"h2"});var v=e(de,2),ce=n(v);o(ce,{name:"class transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel",anchor:"transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L896",parameters:[{name:"config",val:": Ernie4_5_VLMoeVisionConfig"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeVisionConfig">Ernie4_5_VLMoeVisionConfig</a>) — | |
| Model configuration class with all the parameters of the model. Initializing with a config file does not | |
| load the weights associated with the model, only the configuration. Check out the | |
| <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var le=e(ce,8),Pe=n(le);o(Pe,{name:"forward",anchor:"transformers.Ernie4_5_VLMoeVisionTransformerPretrainedModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L925",parameters:[{name:"hidden_states",val:": Tensor"},{name:"grid_thw",val:": Tensor"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}]}),c(2),s(le),s(v);var me=e(v,2);a(me,{title:"Ernie4_5_VLMoeVariableResolutionResamplerModel",local:"transformers.Ernie4_5_VLMoeVariableResolutionResamplerModel",headingTag:"h2"});var w=e(me,2),pe=n(w);o(pe,{name:"class transformers.Ernie4_5_VLMoeVariableResolutionResamplerModel",anchor:"transformers.Ernie4_5_VLMoeVariableResolutionResamplerModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L969",parameters:[{name:"config",val:": Ernie4_5_VLMoeConfig"}]});var _e=e(pe,2),Ne=n(_e);o(Ne,{name:"forward",anchor:"transformers.Ernie4_5_VLMoeVariableResolutionResamplerModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1053",parameters:[{name:"hidden_states",val:""},{name:"grid_thw",val:""}]}),s(_e),s(w);var he=e(w,2);a(he,{title:"Ernie4_5_VLMoeModel",local:"transformers.Ernie4_5_VLMoeModel",headingTag:"h2"});var I=e(he,2),ge=n(I);o(ge,{name:"class transformers.Ernie4_5_VLMoeModel",anchor:"transformers.Ernie4_5_VLMoeModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1071",parameters:[{name:"config",val:": Ernie4_5_VLMoeConfig"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeConfig">Ernie4_5_VLMoeConfig</a>) — | |
| Model configuration class with all the parameters of the model. Initializing with a config file does not | |
| load the weights associated with the model, only the configuration. Check out the | |
| <a href="/docs/transformers/pr_51549/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var V=e(ge,8),ue=n(V);o(ue,{name:"forward",anchor:"transformers.Ernie4_5_VLMoeModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1371",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = None"},{name:"moe_mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"use_cache",val:": bool | None = None"},{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"pixel_values_videos",val:": typing.Optional[torch.Tensor] = None"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"mm_encoder_outputs",val:": dict[str, transformers.modeling_outputs.BaseModelOutputWithPooling] | None = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default. | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_51549/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a></p>`,name:"input_ids"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>: | |
| <ul> | |
| <li>1 for tokens that are <strong>not masked</strong>,</li> | |
| <li>0 for tokens that are <strong>masked</strong>.</li> | |
| </ul> | |
| <p><a href="../glossary#attention-mask">What are attention masks?</a></p>`,name:"attention_mask"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. | |
| <p><a href="../glossary#position-ids">What are position IDs?</a></p>`,name:"position_ids"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.mm_token_type_ids",description:`<strong>mm_token_type_ids</strong> (<code>torch.IntTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Token type ids matching each modality to a different value in the input sequence, i.e. text (0), image (1), video (2).`,name:"mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.moe_mm_token_type_ids",description:`<strong>moe_mm_token_type_ids</strong> (<code>torch.IntTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| The same as <code>mm_token_type_ids</code> while additionally considering start/end image/video tokens as respective vision tokens.`,name:"moe_mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.cache",description:`<strong>cache</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) — | |
| Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention | |
| blocks) that can be used to speed up sequential decoding. This typically consists in the <code>cache</code> | |
| returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>. | |
| <p>Only <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>cache</code> are passed, <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>cache</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.</p>`,name:"cache"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This | |
| is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the | |
| model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| If set to <code>True</code>, <code>cache</code> key value states are returned and can be used to speed up decoding (see | |
| <code>cache</code>).`,name:"use_cache"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>, <em>optional</em>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <code>image_processor_class</code>. See <code>image_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>image_processor_class</code> for processing images).`,name:"pixel_values"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>, <em>optional</em>) — | |
| The tensors corresponding to the input video. Pixel values for videos can be obtained using | |
| <code>video_processor_class</code>. See <code>video_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>video_processor_class</code> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"},{anchor:"transformers.Ernie4_5_VLMoeModel.forward.mm_encoder_outputs",description:`<strong>mm_encoder_outputs</strong> (<code>dict[str, ~modeling_outputs.BaseModelOutputWithPooling]</code>, <em>optional</em>) — | |
| Dict where keys are supported modalities and values are encoded outputs for that modality. Each encoded output is a tuple | |
| that consists of (<code>pooler_output</code>, <em>optional</em>: <code>last_hidden_states</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>) | |
| <code>pooler_output</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) is a sequence of | |
| multimmodal features of the encoder merged into text embeddings.`,name:"mm_encoder_outputs"}],returnDescription:` | |
| <p>A <code>MultimodalMoeBaseModelOutputWithPast</code> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>MultimodalMoeBaseModelOutputWithPast</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var qe=e(ue,4);z(qe,{children:(r,i)=>{var t=j();d(r,t)},$$slots:{default:!0}}),c(2),s(V);var J=e(V,2),Re=n(J);o(Re,{name:"get_video_features",anchor:"transformers.Ernie4_5_VLMoeModel.get_video_features",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1246",parameters:[{name:"pixel_values_videos",val:": Tensor"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeModel.get_video_features.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>) — | |
| The tensors corresponding to the input video. Pixel values for videos can be obtained using | |
| <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeVideoProcessor">Ernie4_5_VLMoeVideoProcessor</a>. See <a href="/docs/transformers/pr_51549/en/model_doc/molmo2#transformers.Molmo2VideoProcessor.__call__">Ernie4_5_VLMoeVideoProcessor.<strong>call</strong>()</a> for details (<a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeProcessor">Ernie4_5_VLMoeProcessor</a> uses | |
| <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeVideoProcessor">Ernie4_5_VLMoeVideoProcessor</a> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Ernie4_5_VLMoeModel.get_video_features.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeConfig" | |
| >Ernie4_5_VLMoeConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or <code>tuple(torch.Tensor)</code></p> | |
| `}),c(2),s(J);var fe=e(J,2),Be=n(fe);o(Be,{name:"get_image_features",anchor:"transformers.Ernie4_5_VLMoeModel.get_image_features",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1265",parameters:[{name:"pixel_values",val:": Tensor"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeModel.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeImageProcessor">Ernie4_5_VLMoeImageProcessor</a>. See <a href="/docs/transformers/pr_51549/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">Ernie4_5_VLMoeImageProcessor.<strong>call</strong>()</a> for details (<a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeProcessor">Ernie4_5_VLMoeProcessor</a> uses | |
| <a href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeImageProcessor">Ernie4_5_VLMoeImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.Ernie4_5_VLMoeModel.get_image_features.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeConfig" | |
| >Ernie4_5_VLMoeConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or <code>tuple(torch.Tensor)</code></p> | |
| `}),c(2),s(fe),s(I);var Me=e(I,2);a(Me,{title:"Ernie4_5_VLMoeForConditionalGeneration",local:"transformers.Ernie4_5_VLMoeForConditionalGeneration",headingTag:"h2"});var E=e(Me,2),Te=n(E);o(Te,{name:"class transformers.Ernie4_5_VLMoeForConditionalGeneration",anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1532",parameters:[{name:"config",val:": Ernie4_5_VLMoeConfig"}]});var U=e(Te,2),ye=n(U);o(ye,{name:"forward",anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1575",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = None"},{name:"moe_mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": bool | None = None"},{name:"output_router_logits",val:": bool | None = None"},{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"pixel_values_videos",val:": typing.Optional[torch.Tensor] = None"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"logits_to_keep",val:": typing.Union[int, torch.Tensor] = 0"},{name:"mm_encoder_outputs",val:": dict[str, transformers.modeling_outputs.BaseModelOutputWithPooling] | None = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default. | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_51549/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_51549/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a></p>`,name:"input_ids"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>: | |
| <ul> | |
| <li>1 for tokens that are <strong>not masked</strong>,</li> | |
| <li>0 for tokens that are <strong>masked</strong>.</li> | |
| </ul> | |
| <p><a href="../glossary#attention-mask">What are attention masks?</a></p>`,name:"attention_mask"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. | |
| <p><a href="../glossary#position-ids">What are position IDs?</a></p>`,name:"position_ids"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.mm_token_type_ids",description:`<strong>mm_token_type_ids</strong> (<code>torch.IntTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Token type ids matching each modality to a different value in the input sequence, i.e. text (0), image (1), video (2).`,name:"mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.moe_mm_token_type_ids",description:`<strong>moe_mm_token_type_ids</strong> (<code>torch.IntTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| The same as <code>mm_token_type_ids</code> while additionally considering start/end image/video tokens as respective vision tokens.`,name:"moe_mm_token_type_ids"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.cache",description:`<strong>cache</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) — | |
| Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention | |
| blocks) that can be used to speed up sequential decoding. This typically consists in the <code>cache</code> | |
| returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>. | |
| <p>Only <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>cache</code> are passed, <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>cache</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.</p>`,name:"cache"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This | |
| is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the | |
| model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored | |
| (masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| If set to <code>True</code>, <code>cache</code> key value states are returned and can be used to speed up decoding (see | |
| <code>cache</code>).`,name:"use_cache"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the logits of all the routers. They are useful for computing the router loss, and | |
| should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>, <em>optional</em>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <code>image_processor_class</code>. See <code>image_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>image_processor_class</code> for processing images).`,name:"pixel_values"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>, <em>optional</em>) — | |
| The tensors corresponding to the input video. Pixel values for videos can be obtained using | |
| <code>video_processor_class</code>. See <code>video_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>video_processor_class</code> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>Union[int, torch.Tensor]</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| If an <code>int</code>, compute logits for the last <code>logits_to_keep</code> tokens. If <code>0</code>, calculate logits for all | |
| <code>input_ids</code> (special case). Only last token logits are needed for generation, and calculating them only for that | |
| token can save memory, which becomes pretty significant for long sequences or large vocabulary size. | |
| If a <code>torch.Tensor</code>, must be 1D corresponding to the indices to keep in the sequence length dimension. | |
| This is useful when using packed tensor format (single dimension for batch and sequence length).`,name:"logits_to_keep"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.forward.mm_encoder_outputs",description:`<strong>mm_encoder_outputs</strong> (<code>dict[str, ~modeling_outputs.BaseModelOutputWithPooling]</code>, <em>optional</em>) — | |
| Dict where keys are supported modalities and values are encoded outputs for that modality. Each encoded output is a tuple | |
| that consists of (<code>pooler_output</code>, <em>optional</em>: <code>last_hidden_states</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>) | |
| <code>pooler_output</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) is a sequence of | |
| multimmodal features of the encoder merged into text embeddings.`,name:"mm_encoder_outputs"}],returnDescription:` | |
| <p>A <code>MultimodalMoeCausalLMOutputWithPast</code> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>MultimodalMoeCausalLMOutputWithPast</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var We=e(ye,4);z(We,{children:(r,i)=>{var t=j();d(r,t)},$$slots:{default:!0}}),c(2),s(U);var k=e(U,2),be=n(k);o(be,{name:"get_video_features",anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_video_features",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1549",parameters:[{name:"pixel_values_videos",val:": Tensor"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_video_features.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input videos.`,name:"pixel_values_videos"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_video_features.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeConfig" | |
| >Ernie4_5_VLMoeConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Ae=e(be,4);x(Ae,{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_video_features.example",children:(r,i)=>{var t=C(),l=e(p(t),2);m(l,{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBFcm5pZTRfNV9WTE1vZUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwRXJuaWU0XzVfVkxNb2VGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJhaWR1JTJGRVJOSUUtNC41LVZMLTI4Qi1BM0ItUFQlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyYmFpZHUlMkZFUk5JRS00LjUtVkwtMjhCLUEzQi1QVCUyMiklMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUyMCUyMnVybCUyMiUzQSUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnBpcGVsaW5lLWNhdC1jaG9uay5qcGVnJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyV2hlcmUlMjBpcyUyMHRoZSUyMGNhdCUyMHN0YW5kaW5nJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTVEJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBJTIwJTIwJTIwJTIwYWRkX2dlbmVyYXRpb25fcHJvbXB0JTNEVHJ1ZSUwQSklMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzKSUwQXByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Ernie4_5_VLMoeForConditionalGeneration | |
| <span class="hljs-meta">>>> </span>model = Ernie4_5_VLMoeForConditionalGeneration.from_pretrained(<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>) | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>) | |
| <span class="hljs-meta">>>> </span>messages = [ | |
| <span class="hljs-meta">... </span> { | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: [ | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>, <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Where is the cat standing?"</span>}, | |
| <span class="hljs-meta">... </span> ] | |
| <span class="hljs-meta">... </span> }, | |
| <span class="hljs-meta">... </span>] | |
| <span class="hljs-meta">>>> </span>inputs = processor.apply_chat_template( | |
| <span class="hljs-meta">... </span> messages, | |
| <span class="hljs-meta">... </span> tokenize=<span class="hljs-literal">True</span>, | |
| <span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">True</span>, | |
| <span class="hljs-meta">... </span> return_tensors=<span class="hljs-string">"pt"</span>, | |
| <span class="hljs-meta">... </span> add_generation_prompt=<span class="hljs-literal">True</span> | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Generate</span> | |
| <span class="hljs-meta">>>> </span>generate_ids = model.generate(**inputs) | |
| <span class="hljs-meta">>>> </span>processor.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1}),d(r,t)},$$slots:{default:!0}}),s(k);var ve=e(k,2),we=n(ve);o(we,{name:"get_image_features",anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_image_features",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/ernie4_5_vl_moe/modeling_ernie4_5_vl_moe.py#L1562",parameters:[{name:"pixel_values",val:": Tensor"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images.`,name:"pixel_values"},{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_image_features.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) — | |
| The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or a tuple of | |
| <code>torch.Tensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_51549/en/model_doc/ernie4_5_vl_moe#transformers.Ernie4_5_VLMoeConfig" | |
| >Ernie4_5_VLMoeConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Ze=e(we,4);x(Ze,{anchor:"transformers.Ernie4_5_VLMoeForConditionalGeneration.get_image_features.example",children:(r,i)=>{var t=C(),l=e(p(t),2);m(l,{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBFcm5pZTRfNV9WTE1vZUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwRXJuaWU0XzVfVkxNb2VGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJhaWR1JTJGRVJOSUUtNC41LVZMLTI4Qi1BM0ItUFQlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyYmFpZHUlMkZFUk5JRS00LjUtVkwtMjhCLUEzQi1QVCUyMiklMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUyMCUyMnVybCUyMiUzQSUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnBpcGVsaW5lLWNhdC1jaG9uay5qcGVnJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyV2hlcmUlMjBpcyUyMHRoZSUyMGNhdCUyMHN0YW5kaW5nJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTVEJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBJTIwJTIwJTIwJTIwYWRkX2dlbmVyYXRpb25fcHJvbXB0JTNEVHJ1ZSUwQSklMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzKSUwQXByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Ernie4_5_VLMoeForConditionalGeneration | |
| <span class="hljs-meta">>>> </span>model = Ernie4_5_VLMoeForConditionalGeneration.from_pretrained(<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>) | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"baidu/ERNIE-4.5-VL-28B-A3B-PT"</span>) | |
| <span class="hljs-meta">>>> </span>messages = [ | |
| <span class="hljs-meta">... </span> { | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: [ | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>, <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Where is the cat standing?"</span>}, | |
| <span class="hljs-meta">... </span> ] | |
| <span class="hljs-meta">... </span> }, | |
| <span class="hljs-meta">... </span>] | |
| <span class="hljs-meta">>>> </span>inputs = processor.apply_chat_template( | |
| <span class="hljs-meta">... </span> messages, | |
| <span class="hljs-meta">... </span> tokenize=<span class="hljs-literal">True</span>, | |
| <span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">True</span>, | |
| <span class="hljs-meta">... </span> return_tensors=<span class="hljs-string">"pt"</span>, | |
| <span class="hljs-meta">... </span> add_generation_prompt=<span class="hljs-literal">True</span> | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Generate</span> | |
| <span class="hljs-meta">>>> </span>generate_ids = model.generate(**inputs) | |
| <span class="hljs-meta">>>> </span>processor.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1}),d(r,t)},$$slots:{default:!0}}),s(ve),s(E);var Ge=e(E,2);Ye(Ge,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/ernie4_5_vl_moe.md"}),c(2),d(Ve,P),eo()}export{po as component}; | |
Xet Storage Details
- Size:
- 168 kB
- Xet hash:
- 0502353ccf77efbde868c6825b0f9721520c0eabf9021f222d597af2057b5e6b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.