Buckets:

download
raw
71 kB
import"../chunks/DsnmJJEf.js";import{i as $,h as ee,C as oe,H as d,a as c,D as n,E as se,s as ne}from"../chunks/D6eQvJIN.js";import{p as te,o as ae,s as e,f as p,a as i,b as re,c as t,d as g,r as a,n as m}from"../chunks/D9TCMYxZ.js";import{T as A}from"../chunks/eoUhp3Ag.js";import{E as h}from"../chunks/D8azpo8f.js";const ie='{"title":"Cosmos3 Omni","local":"cosmos3-omni","sections":[{"title":"Usage","local":"usage","sections":[],"depth":2},{"title":"Cosmos3OmniConfig","local":"transformers.Cosmos3OmniConfig","sections":[],"depth":2},{"title":"Cosmos3OmniModel","local":"transformers.Cosmos3OmniModel","sections":[],"depth":2},{"title":"Cosmos3OmniForConditionalGeneration","local":"transformers.Cosmos3OmniForConditionalGeneration","sections":[],"depth":2}],"depth":1}';var le=g('<meta name="hf:doc:metadata"/>'),u=g("<p>Example:</p> <!>",1),O=g(`<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>`),de=g(`<p></p> <p><em>This model was contributed to Hugging Face Transformers on 2026-06-04.</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&amp;logo=pytorch&amp;logoColor=white"/></div></div> <!> <p><a href="https://huggingface.co/nvidia/Cosmos3-Nano" rel="nofollow">Cosmos3</a> is a mixture-of-transformers (MoT) Vision Foundation Model from NVIDIA, composed of a <em>Reasoner</em> tower and a <em>Generator</em> tower. The two towers share the same input embedding and visual encoder but use disjoint MoT experts for understanding vs. generation, plus cross-modal adapters (<code>proj_out</code>, <code>audio_proj_out</code>, <code>action_proj_out</code>, etc.) that connect the language model to image / audio / action heads.</p> <p>The transformers integration loads <strong>only the Reasoner tower</strong> from a unified Cosmos3 checkpoint. The Reasoner is architecturally identical to <a href="./qwen3_vl">Qwen3-VL</a> — <code>Cosmos3OmniForConditionalGeneration</code> is a thin subclass of <code>Qwen3VLForConditionalGeneration</code>.</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 Cosmos3OmniModel. It is used to instantiate a Cosmos3 Omni
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/nvidia/Cosmos3-Nano" rel="nofollow">nvidia/Cosmos3-Nano</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_36708/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_36708/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>The bare Cosmos3 Omni Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_36708/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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniModel">Cosmos3OmniModel</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><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 model.</p> <p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p></li> <li><p><strong>past_key_values</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_36708/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>past_key_values</code> input) to speed up sequential decoding.</p></li> <li><p><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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>rope_deltas</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>) — The rope index difference between sequence length and multimodal rope.
The attribute is deprecated and will be removed in v5.20, use <code>model.base_model.rope_deltas</code> instead.</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.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 model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.FloatTensor</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.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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>deepstack_features</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>) — List of hidden-states (feature maps) from deepstack layers.</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.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 model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.FloatTensor</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.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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>deepstack_features</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>) — List of hidden-states (feature maps) from deepstack layers.</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniForConditionalGeneration">Cosmos3OmniForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><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).</p></li> <li><p><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).</p></li> <li><p><strong>past_key_values</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_36708/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) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p></li> <li><p><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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>rope_deltas</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>) — The rope index difference between sequence length and multimodal rope.
The attribute is deprecated and will be removed in v5.20, use <code>model.base_model.rope_deltas</code> instead.</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.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 model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.FloatTensor</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.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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>deepstack_features</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>) — List of hidden-states (feature maps) from deepstack layers.</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.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 model.</p></li> <li><p><strong>pooler_output</strong> (<code>torch.FloatTensor</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.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>.</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.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>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p></li> <li><p><strong>deepstack_features</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>) — List of hidden-states (feature maps) from deepstack layers.</p></li></ul> <!></div></div> <!> <p></p>`,1);function ge(R,X){te(X,!1),ae(()=>{new URLSearchParams(window.location.search).get("fw")}),$();var w=de();ee("86l2zz",s=>{var r=le();ne(r,"content",ie),i(s,r)});var j=e(p(w),4);oe(j,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var C=e(j,4);d(C,{title:"Cosmos3 Omni",local:"cosmos3-omni",headingTag:"h1"});var U=e(C,6);d(U,{title:"Usage",local:"usage",headingTag:"h2"});var k=e(U,2);c(k,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMENvc21vczNPbW5pRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBDb3Ntb3MzT21uaUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGQ29zbW9zMy1OYW5vJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGQ29zbW9zMy1OYW5vJTIyKSUwQSUwQWNvbnZlcnNhdGlvbiUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUyMCUyMmltYWdlJTIyJTNBJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGcGlwZWxpbmUtY2F0LWNob25rLmpwZWclMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIydGV4dCUyMiUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjJDYXB0aW9uJTIwdGhlJTIwaW1hZ2UlMjBpbiUyMGRldGFpbC4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElNUQlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZSglMEElMjAlMjAlMjAlMjBjb252ZXJzYXRpb24lMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSkudG8obW9kZWwuZGV2aWNlKSUwQSUwQWdlbmVyYXRlZF9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENTEyKSUwQW91dHB1dCUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoJTBBJTIwJTIwJTIwJTIwJTVCb3V0JTVCbGVuKGlucCklM0ElNUQlMjBmb3IlMjBpbnAlMkMlMjBvdXQlMjBpbiUyMHppcChpbnB1dHMuaW5wdXRfaWRzJTJDJTIwZ2VuZXJhdGVkX2lkcyklNUQlMkMlMEElMjAlMjAlMjAlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSUyQyUwQSklMEFwcmludChvdXRwdXQlNUIwJTVEKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Cosmos3OmniForConditionalGeneration
model = Cosmos3OmniForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>)
conversation = [
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: [
{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;image&quot;</span>: <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>},
{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Caption the image in detail.&quot;</span>},
],
},
]
inputs = processor.apply_chat_template(
conversation,
tokenize=<span class="hljs-literal">True</span>,
add_generation_prompt=<span class="hljs-literal">True</span>,
return_dict=<span class="hljs-literal">True</span>,
return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
).to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">512</span>)
output = processor.batch_decode(
[out[<span class="hljs-built_in">len</span>(inp):] <span class="hljs-keyword">for</span> inp, out <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(inputs.input_ids, generated_ids)],
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[<span class="hljs-number">0</span>])`,lang:"python",wrap:!1});var J=e(k,2);d(J,{title:"Cosmos3OmniConfig",local:"transformers.Cosmos3OmniConfig",headingTag:"h2"});var _=e(J,2),F=t(_);n(F,{name:"class transformers.Cosmos3OmniConfig",anchor:"transformers.Cosmos3OmniConfig",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/configuration_cosmos3_omni.py#L30",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_token_id",val:": int = 151655"},{name:"video_token_id",val:": int = 151656"},{name:"vision_start_token_id",val:": int = 151652"},{name:"vision_end_token_id",val:": int = 151653"},{name:"tie_word_embeddings",val:": bool = False"}],parametersDescription:[{anchor:"transformers.Cosmos3OmniConfig.text_config",description:`<strong>text_config</strong> (<code>Union[dict, ~configuration_utils.PreTrainedConfig]</code>, <em>optional</em>) &#x2014;
The config object or dictionary of the text backbone.`,name:"text_config"},{anchor:"transformers.Cosmos3OmniConfig.vision_config",description:`<strong>vision_config</strong> (<code>Union[dict, ~configuration_utils.PreTrainedConfig]</code>, <em>optional</em>) &#x2014;
The config object or dictionary of the vision backbone.`,name:"vision_config"},{anchor:"transformers.Cosmos3OmniConfig.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>151655</code>) &#x2014;
The image token index used as a placeholder for input images.`,name:"image_token_id"},{anchor:"transformers.Cosmos3OmniConfig.video_token_id",description:`<strong>video_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>151656</code>) &#x2014;
The video token index used as a placeholder for input videos.`,name:"video_token_id"},{anchor:"transformers.Cosmos3OmniConfig.vision_start_token_id",description:`<strong>vision_start_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>151652</code>) &#x2014;
Token ID that marks the start of a visual segment in the multimodal input sequence.`,name:"vision_start_token_id"},{anchor:"transformers.Cosmos3OmniConfig.vision_end_token_id",description:`<strong>vision_end_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>151653</code>) &#x2014;
Token ID that marks the end of a visual segment in the multimodal input sequence.`,name:"vision_end_token_id"},{anchor:"transformers.Cosmos3OmniConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to tie weight embeddings according to model&#x2019;s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"}]});var L=e(F,6);h(L,{anchor:"transformers.Cosmos3OmniConfig.example",children:(s,r)=>{var o=u(),l=e(p(o),2);c(l,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENvc21vczNPbW5pRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTIwQ29zbW9zM09tbmlDb25maWclMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQ29zbW9zMyUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBDb3Ntb3MzT21uaUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwZnJvbSUyMHRoZSUyMENvc21vczMlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMENvc21vczNPbW5pRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Cosmos3OmniForConditionalGeneration, Cosmos3OmniConfig
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Cosmos3 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Cosmos3OmniConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the Cosmos3 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Cosmos3OmniForConditionalGeneration(configuration)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,lang:"python",wrap:!1}),i(s,o)},$$slots:{default:!0}}),a(_);var z=e(_,2);d(z,{title:"Cosmos3OmniModel",local:"transformers.Cosmos3OmniModel",headingTag:"h2"});var f=e(z,2),I=t(f);n(I,{name:"class transformers.Cosmos3OmniModel",anchor:"transformers.Cosmos3OmniModel",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L109",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Cosmos3OmniModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniModel">Cosmos3OmniModel</a>) &#x2014;
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_36708/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var M=e(I,8),q=t(M);n(q,{name:"forward",anchor:"transformers.Cosmos3OmniModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L391",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:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"pixel_values_videos",val:": typing.Optional[torch.FloatTensor] = None"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = 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.Cosmos3OmniModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36708/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_36708/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>`,name:"input_ids"},{anchor:"transformers.Cosmos3OmniModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<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>`,name:"attention_mask"},{anchor:"transformers.Cosmos3OmniModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Cosmos3OmniModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) &#x2014;
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>past_key_values</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>
<p>Only <a href="/docs/transformers/pr_36708/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>past_key_values</code> are passed, <a href="/docs/transformers/pr_36708/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>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don&#x2019;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>.`,name:"past_key_values"},{anchor:"transformers.Cosmos3OmniModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
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&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Cosmos3OmniModel.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>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">Qwen2VLImageProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.Cosmos3OmniModel.forward.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>, <em>optional</em>) &#x2014;
The tensors corresponding to the input video. Pixel values for videos can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2VideoProcessor.__call__">Qwen3VLVideoProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Cosmos3OmniModel.forward.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) &#x2014;
The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"},{anchor:"transformers.Cosmos3OmniModel.forward.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) &#x2014;
The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"},{anchor:"transformers.Cosmos3OmniModel.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>) &#x2014;
Indices of input sequence tokens matching each modality. For example text (0), image (1), video (2).
Multimodal token type ids can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a>. See <a href="/docs/transformers/pr_36708/en/main_classes/processors#transformers.ProcessorMixin.__call__">ProcessorMixin.<strong>call</strong>()</a> for details.`,name:"mm_token_type_ids"},{anchor:"transformers.Cosmos3OmniModel.forward.mm_encoder_outputs",description:`<strong>mm_encoder_outputs</strong> (<code>dict[str, ~modeling_outputs.BaseModelOutputWithPooling]</code>, <em>optional</em>) &#x2014;
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:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>Cosmos3OmniModelOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>Cosmos3OmniModelOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`});var E=e(q,4);A(E,{children:(s,r)=>{var o=O();i(s,o)},$$slots:{default:!0}}),m(2),a(M);var y=e(M,2),P=t(y);n(P,{name:"get_video_features",anchor:"transformers.Cosmos3OmniModel.get_video_features",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L268",parameters:[{name:"pixel_values_videos",val:": FloatTensor"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Cosmos3OmniModel.get_video_features.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>) &#x2014;
The tensors corresponding to the input video. Pixel values for videos can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2VideoProcessor.__call__">Qwen3VLVideoProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Cosmos3OmniModel.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>) &#x2014;
The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>BaseModelOutputWithDeepstackFeatures</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>BaseModelOutputWithDeepstackFeatures</code> or <code>tuple(torch.FloatTensor)</code></p>
`}),m(2),a(y);var Z=e(y,2),S=t(Z);n(S,{name:"get_image_features",anchor:"transformers.Cosmos3OmniModel.get_image_features",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L280",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Cosmos3OmniModel.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">Qwen2VLImageProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.Cosmos3OmniModel.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>) &#x2014;
The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>BaseModelOutputWithDeepstackFeatures</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>BaseModelOutputWithDeepstackFeatures</code> or <code>tuple(torch.FloatTensor)</code></p>
`}),m(2),a(Z),a(f);var x=e(f,2);d(x,{title:"Cosmos3OmniForConditionalGeneration",local:"transformers.Cosmos3OmniForConditionalGeneration",headingTag:"h2"});var b=e(x,2),N=t(b);n(N,{name:"class transformers.Cosmos3OmniForConditionalGeneration",anchor:"transformers.Cosmos3OmniForConditionalGeneration",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L518",parameters:[{name:"config",val:""}]});var v=e(N,2),W=t(v);n(W,{name:"forward",anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L557",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:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"pixel_values_videos",val:": typing.Optional[torch.FloatTensor] = None"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"mm_token_type_ids",val:": typing.Optional[torch.IntTensor] = 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.Cosmos3OmniForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36708/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_36708/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>`,name:"input_ids"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<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>`,name:"attention_mask"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) &#x2014;
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>past_key_values</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>
<p>Only <a href="/docs/transformers/pr_36708/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>past_key_values</code> are passed, <a href="/docs/transformers/pr_36708/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>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don&#x2019;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>.`,name:"past_key_values"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
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&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
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.Cosmos3OmniForConditionalGeneration.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>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">Qwen2VLImageProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen2_vl#transformers.Qwen2VLImageProcessor">Qwen2VLImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, frame_size, frame_size)</code>, <em>optional</em>) &#x2014;
The tensors corresponding to the input video. Pixel values for videos can be obtained using
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a>. See <a href="/docs/transformers/pr_36708/en/model_doc/molmo2#transformers.Molmo2VideoProcessor.__call__">Qwen3VLVideoProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses
<a href="/docs/transformers/pr_36708/en/model_doc/qwen3_vl#transformers.Qwen3VLVideoProcessor">Qwen3VLVideoProcessor</a> for processing videos).`,name:"pixel_values_videos"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.image_grid_thw",description:`<strong>image_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_images, 3)</code>, <em>optional</em>) &#x2014;
The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.video_grid_thw",description:`<strong>video_grid_thw</strong> (<code>torch.LongTensor</code> of shape <code>(num_videos, 3)</code>, <em>optional</em>) &#x2014;
The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.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>) &#x2014;
Indices of input sequence tokens matching each modality. For example text (0), image (1), video (2).
Multimodal token type ids can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a>. See <a href="/docs/transformers/pr_36708/en/main_classes/processors#transformers.ProcessorMixin.__call__">ProcessorMixin.<strong>call</strong>()</a> for details.`,name:"mm_token_type_ids"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>Union[int, torch.Tensor]</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
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.Cosmos3OmniForConditionalGeneration.forward.mm_encoder_outputs",description:`<strong>mm_encoder_outputs</strong> (<code>dict[str, ~modeling_outputs.BaseModelOutputWithPooling]</code>, <em>optional</em>) &#x2014;
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:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>Cosmos3OmniCausalLMOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>Cosmos3OmniCausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`});var Q=e(W,4);A(Q,{children:(s,r)=>{var o=O();i(s,o)},$$slots:{default:!0}});var Y=e(Q,4);h(Y,{anchor:"transformers.Cosmos3OmniForConditionalGeneration.forward.example",children:(s,r)=>{var o=u(),l=e(p(o),2);c(l,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBDb3Ntb3MzT21uaUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwQ29zbW9zM09tbmlGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMlF3ZW4lMkZRd2VuMy1WTC04Qi1JbnN0cnVjdCUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJRd2VuJTJGUXdlbjMtVkwtOEItSW5zdHJ1Y3QlMjIpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZSglMEElMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlZF9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTAyNCklMEFnZW5lcmF0ZWRfaWRzX3RyaW1tZWQlMjAlM0QlMjAlNUJvdXRfaWRzJTVCbGVuKGluX2lkcyklMjAlM0ElNUQlMjBmb3IlMjBpbl9pZHMlMkMlMjBvdXRfaWRzJTIwaW4lMjB6aXAoaW5wdXRzLmlucHV0X2lkcyUyQyUyMGdlbmVyYXRlZF9pZHMpJTVEJTBBb3V0cHV0X3RleHQlMjAlM0QlMjBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlZF9pZHNfdHJpbW1lZCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlJTJDJTIwY2xlYW5fdXBfdG9rZW5pemF0aW9uX3NwYWNlcyUzREZhbHNlKSU1QjAlNUQlMEFwcmludChvdXRwdXRfdGV4dCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Cosmos3OmniForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Cosmos3OmniForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen3-VL-8B-Instruct&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen3-VL-8B-Instruct&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: [
{
<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>,
<span class="hljs-string">&quot;image&quot;</span>: <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>,
},
{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Describe the image.&quot;</span>},
],
}
]
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor.apply_chat_template(
messages,
tokenize=<span class="hljs-literal">True</span>,
add_generation_prompt=<span class="hljs-literal">True</span>,
return_dict=<span class="hljs-literal">True</span>,
return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">1024</span>)
<span class="hljs-meta">&gt;&gt;&gt; </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)]
<span class="hljs-meta">&gt;&gt;&gt; </span>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-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(output_text)`,lang:"python",wrap:!1}),i(s,o)},$$slots:{default:!0}}),a(v);var T=e(v,2),G=t(T);n(G,{name:"get_video_features",anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_video_features",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L531",parameters:[{name:"pixel_values_videos",val:": FloatTensor"},{name:"video_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_video_features.pixel_values_videos",description:`<strong>pixel_values_videos</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input videos.`,name:"pixel_values_videos"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.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>) &#x2014;
The temporal, height and width of feature shape of each video in LLM.`,name:"video_grid_thw"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>BaseModelOutputWithDeepstackFeatures</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>BaseModelOutputWithDeepstackFeatures</code> or <code>tuple(torch.FloatTensor)</code></p>
`});var H=e(G,4);h(H,{anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_video_features.example",children:(s,r)=>{var o=u(),l=e(p(o),2);c(l,{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBDb3Ntb3MzT21uaUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwQ29zbW9zM09tbmlGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRkNvc21vczMtTmFubyUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZDb3Ntb3MzLU5hbm8lMjIpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlMkMlMjAlMjJ1cmwlMjIlM0ElMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZwaXBlbGluZS1jYXQtY2hvbmsuanBlZyUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoZXJlJTIwaXMlMjB0aGUlMjBjYXQlMjBzdGFuZGluZyUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSU1RCUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvci5hcHBseV9jaGF0X3RlbXBsYXRlKCUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMEEpJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Cosmos3OmniForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Cosmos3OmniForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [
<span class="hljs-meta">... </span> {
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>},
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Where is the cat standing?&quot;</span>},
<span class="hljs-meta">... </span> ]
<span class="hljs-meta">... </span> },
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </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">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span> add_generation_prompt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </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}),i(s,o)},$$slots:{default:!0}}),a(T);var B=e(T,2),V=t(B);n(V,{name:"get_image_features",anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_image_features",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/cosmos3_omni/modeling_cosmos3_omni.py#L544",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"image_grid_thw",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input images.`,name:"pixel_values"},{anchor:"transformers.Cosmos3OmniForConditionalGeneration.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>) &#x2014;
The temporal, height and width of feature shape of each image in LLM.`,name:"image_grid_thw"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <code>BaseModelOutputWithDeepstackFeatures</code> or a tuple of
<code>torch.FloatTensor</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_36708/en/model_doc/cosmos3_omni#transformers.Cosmos3OmniConfig"
>Cosmos3OmniConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>BaseModelOutputWithDeepstackFeatures</code> or <code>tuple(torch.FloatTensor)</code></p>
`});var D=e(V,4);h(D,{anchor:"transformers.Cosmos3OmniForConditionalGeneration.get_image_features.example",children:(s,r)=>{var o=u(),l=e(p(o),2);c(l,{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBDb3Ntb3MzT21uaUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwQ29zbW9zM09tbmlGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRkNvc21vczMtTmFubyUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZDb3Ntb3MzLU5hbm8lMjIpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlMkMlMjAlMjJ1cmwlMjIlM0ElMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZwaXBlbGluZS1jYXQtY2hvbmsuanBlZyUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoZXJlJTIwaXMlMjB0aGUlMjBjYXQlMjBzdGFuZGluZyUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSU1RCUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvci5hcHBseV9jaGF0X3RlbXBsYXRlKCUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMEEpJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Cosmos3OmniForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Cosmos3OmniForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos3-Nano&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [
<span class="hljs-meta">... </span> {
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>},
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Where is the cat standing?&quot;</span>},
<span class="hljs-meta">... </span> ]
<span class="hljs-meta">... </span> },
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </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">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span> add_generation_prompt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </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}),i(s,o)},$$slots:{default:!0}}),a(B),a(b);var K=e(b,2);se(K,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/cosmos3_omni.md"}),m(2),i(R,w),re()}export{ge as component};

Xet Storage Details

Size:
71 kB
·
Xet hash:
1baaddaf8b09367aed3620a9f92abf68fc5e3af23f5b06d3d6da8a9c2644ec46

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.