Buckets:
| import"../chunks/DsnmJJEf.js";import{i as Ke,h as $e,C as eo,H as s,a as m,D as o,E as oo,s as no}from"../chunks/CN3cOuQA.js";import{p as to,o as so,s as e,f,a as c,b as ao,c as n,d as p,n as i,r as t}from"../chunks/DdiSzEty.js";import{T as h}from"../chunks/Biyddybe.js";import{E as g}from"../chunks/BpTh2jDR.js";const ro='{"title":"DiffusionGemma","local":"diffusiongemma","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage examples","local":"usage-examples","sections":[{"title":"Common caveats","local":"common-caveats","sections":[],"depth":3},{"title":"Basic example","local":"basic-example","sections":[],"depth":3},{"title":"Streaming","local":"streaming","sections":[],"depth":3},{"title":"Setting a starting denoising output","local":"setting-a-starting-denoising-output","sections":[],"depth":3}],"depth":2},{"title":"DiffusionGemmaTextConfig","local":"transformers.DiffusionGemmaTextConfig","sections":[],"depth":2},{"title":"DiffusionGemmaConfig","local":"transformers.DiffusionGemmaConfig","sections":[],"depth":2},{"title":"DiffusionGemmaGenerationOutput","local":"transformers.DiffusionGemmaGenerationOutput","sections":[],"depth":2},{"title":"DiffusionGemmaGenerationMixin","local":"transformers.DiffusionGemmaGenerationMixin","sections":[],"depth":2},{"title":"DiffusionGemmaGenerationConfig","local":"transformers.DiffusionGemmaGenerationConfig","sections":[],"depth":2},{"title":"EntropyBoundSamplerConfig","local":"transformers.EntropyBoundSamplerConfig","sections":[],"depth":2},{"title":"EntropyBoundSampler","local":"transformers.EntropyBoundSampler","sections":[],"depth":2},{"title":"StableAndConfidentStoppingCriteria","local":"transformers.StableAndConfidentStoppingCriteria","sections":[],"depth":2},{"title":"LinearTemperatureScheduleLogitsProcessor","local":"transformers.LinearTemperatureScheduleLogitsProcessor","sections":[],"depth":2},{"title":"DiffusionGemmaPreTrainedModel","local":"transformers.DiffusionGemmaPreTrainedModel","sections":[],"depth":2},{"title":"DiffusionGemmaModel","local":"transformers.DiffusionGemmaModel","sections":[],"depth":2},{"title":"DiffusionGemmaEncoderModel","local":"transformers.DiffusionGemmaEncoderModel","sections":[],"depth":2},{"title":"DiffusionGemmaEncoderTextModel","local":"transformers.DiffusionGemmaEncoderTextModel","sections":[],"depth":2},{"title":"DiffusionGemmaDecoderModel","local":"transformers.DiffusionGemmaDecoderModel","sections":[],"depth":2},{"title":"DiffusionGemmaForBlockDiffusion","local":"transformers.DiffusionGemmaForBlockDiffusion","sections":[],"depth":2}],"depth":1}';var io=p('<meta name="hf:doc:metadata"/>'),co=p("<p>Example:</p> <!>",1),lo=p("<p>loop doing diffusion on each canvas. The algorithm works roughly as follows:</p> <!>",1),mo=p("<p>Examples:</p> <!>",1),po=p("<p>Here is a rough sketch of how the sampler loop works:</p> <!>",1),u=p(`<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>`),fo=p(`<p></p> <p><em>This model was contributed to Hugging Face Transformers on 2026-06-10.</em></p> <!> <!> <!> <p>DiffusionGemma is engineered to reduce the sequential bottlenecks of standard causal language models. It employs an encoder-decoder architecture specifically optimized for inference speed.</p> <p>The encoder operates in a prefill capacity, processing the initial prompt and generating the KV cache. The decoder then utilizes bidirectional attention to process an input block (a ‘canvas’) of tokens, accessing the cached context via cross-attention.</p> <p>During inference, DiffusionGemma leverages multi-canvas sampling. Rather than generating one token at a time, the model iteratively denoises a full block of tokens using a diffusion sampler. Once a canvas is fully denoised, it is processed by the encoder and appended to the KV cache, after which the model generates the next canvas. This block-autoregressive approach facilitates text generation at higher speeds.</p> <p>You can find the model card and checkpoint <a href="https://huggingface.co/google/diffusiongemma-26B-A4B-it" rel="nofollow">here</a>. You can find a visual guide to the model <a href="https://newsletter.maartengrootendorst.com/p/a-visual-guide-to-diffusiongemma" rel="nofollow">here</a>.</p> <!> <p>Despite it being a text diffusion model and having a custom generation loop, most of the interface is shared with other models that can generate text with <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaGenerationMixin.generate">DiffusionGemmaGenerationMixin.generate()</a>. If you’re using another <code>transformers</code> model in your app, you should be able to directly replace it with this model.</p> <blockquote class="note"><p>DiffusionGemma is available in both Transformers and Diffusers, but Diffusers is its primary home. Diffusers has the full set of scheduling options, pipeline utilities, and new features (additional schedulers, stopping criteria, sampling strategies) are only added there. See the <a href="https://huggingface.co/docs/diffusers/api/pipelines/diffusion_gemma" rel="nofollow">DiffusionGemma</a> for usage examples, and open an <a href="https://github.com/huggingface/diffusers/issues" rel="nofollow">issue</a> on Diffusers to experiment with different schedulers or request a feature. The Transformers implementation only receives bug fixes but no new features.</p></blockquote> <!> <ul><li>DiffusionGemma doesn’t accept <code>use_cache</code>. It always uses a KV cache;</li> <li>Support for common flags like <code>top_k</code> won’t be available at release day, but will be added over time if they are compatible with text diffusion.</li></ul> <!> <!> <!> <p>Like other models that can generate text, you can set a streamer class to stream text. Unlike other models, DiffusionGemma generates intermediate drafts before the final text. You can visualize them with <code>TextDiffusionStreamer</code></p> <!> <!> <p>The model is trained to iteratively refine blocks of 256 tokens. On some applications, it may be beneficial to provide a starting point for the decoder, rather than starting from random tokens. You can use the <code>decoder_input_ids</code>, available on all model interfaces, to set the starting canvas.</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 DiffusionGemmaModel. It is used to instantiate a Diffusion Gemma | |
| 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/google/diffusiongemma-26B-A4B-it" rel="nofollow">google/diffusiongemma-26B-A4B-it</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 DiffusionGemmaModel. It is used to instantiate a Diffusion Gemma | |
| 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/google/diffusiongemma-26B-A4B-it" rel="nofollow">google/diffusiongemma-26B-A4B-it</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>Output class for DiffusionGemma generation.</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>Mixin class for DiffusionGemma generation. Contains all the model-level methods.</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>Generates text using the diffusion model.</p> <p>It contains an outer loop doing autoregressive generation of canvases (blocks of tokens), and an inner</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"><!> <p>A GenerationConfig class with parameterization customized for <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaGenerationMixin.generate">DiffusionGemmaGenerationMixin.generate()</a>.</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>Configuration class for the entropy bound sampler.</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>Sampler class that initializes a canvas with random tokens, accepts tokens based on token-level entropy, and | |
| renoises non-accepted tokens.</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>Accepts tokens from the denoiser based on an entropy bound. More concretely, sampling proceeds by accepting | |
| k tokens with lowest entropy, such that</p> <p>sum_i^k entropy_i - max(entropy_1, …, entropy_k) <= entropy_bound,</p> <p>where the LHS is the upper bound on the joint mutual information between these tokens, and thus the sampler | |
| chooses k tokens that they are approximately independent.</p> <p>Originally proposed in <a href="https://arxiv.org/pdf/2505.24857" rel="nofollow">https://arxiv.org/pdf/2505.24857</a></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>Initializes and returns a new canvas of <code>canvas_length</code> tokens with random values from the vocabulary.</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>Renoises all non-accepted tokens.</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"><!> <p>Adaptive stopping strategy that stops when the diffusion process is confident and stable. To be more specific:</p> <ul><li>The diffusion process is stable when the accepted canvas are the same across <code>stability_threshold</code> steps.</li> <li>The diffusion process is confident when the mean of the entropy of the processed logits is below <code>confidence_threshold</code>.</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"><!> <p>Logits processor that applies a linear temperature schedule to the logits. This is similar to <code>TemperatureLogitsWarper</code>, except that the temperature is a function of the current step.</p> <p>At step n out of N, the temperature t is given by t = t_min + ((t_max - t_min) * (n/N)).</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 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>A mock value for a dotted path (e.g. <code>torch.float32</code>): attribute access chains, | |
| calls behave as pass-through decorators, <code>repr</code> is the dotted path, and using it | |
| as a base class substitutes a plain-<code>type</code> base (PEP 560 <code>__mro_entries__</code>), so | |
| real subclasses keep a normal metaclass and <code>inspect.signature</code> reads their real <code>__init__</code> instead of a mock’s.</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"><!> <p>The bare Diffusion Gemma 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/diffusion_gemma#transformers.DiffusionGemmaModel">DiffusionGemmaModel</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> <p>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.</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>encoder_last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — Sequence of hidden states at the output of the last layer of the encoder. Only set when <code>input_ids</code> is | |
| provided, e.g. to compute an autoregressive loss on the encoder during training.</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 DiffusionGemma encoder model comprising a vision backbone and a language model, <em>without</em> a language modeling | |
| head. It is very similar to Gemma4Model, except that it doesn’t support audio or video inputs, and always | |
| assumes the MoE code path in the inner layers.</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/diffusion_gemma#transformers.DiffusionGemmaEncoderModel">DiffusionGemmaEncoderModel</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> <p>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.</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></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/diffusion_gemma#transformers.DiffusionGemmaEncoderTextModel">DiffusionGemmaEncoderTextModel</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> <p>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.</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></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>Decoder model for DiffusionGemma.</p> <p>Processes canvas tokens with bidirectional self-attention and cross-attention to the encoder’s KV cache. | |
| The decoder reads but does not update the KV cache. Excluding these differences, it is similar to <code>DiffusionGemmaEncoderTextModel</code>, and they share all weights they have in common.</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/diffusion_gemma#transformers.DiffusionGemmaDecoderModel">DiffusionGemmaDecoderModel</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>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"><!> <p>DiffusionGemma model for block diffusion. It calls <code>DiffusionGemmaModel</code> to obtains the hidden states for | |
| the input canvas, conditioned by a prompt KV cache. Using its LM Head and self-conditioning blocks, it converts | |
| those hidden states into logits to sample the next canvas, as well as the self-conditioning embeddings for the | |
| next block diffusion step.</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/diffusion_gemma#transformers.DiffusionGemmaForBlockDiffusion">DiffusionGemmaForBlockDiffusion</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>loss</strong> (<code>torch.Tensor</code> of shape <code>(1,)</code>, <em>optional</em>) — Language modeling loss.</p></li> <li><p><strong>logits</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, canvas_length, config.text_config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</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) 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>encoder_last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — Sequence of hidden states at the output of the last layer of the encoder. Only set when <code>input_ids</code> is | |
| provided, e.g. to compute an autoregressive loss on the encoder during training.</p></li></ul></div></div> <!> <p></p>`,1);function yo(xe,De){to(De,!1),so(()=>{new URLSearchParams(window.location.search).get("fw")}),Ke();var S=fo();$e("1nxvhxp",r=>{var d=io();no(d,"content",ro),c(r,d)});var B=e(f(S),4);eo(B,{containerStyle:"float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"});var z=e(B,2);s(z,{title:"DiffusionGemma",local:"diffusiongemma",headingTag:"h1"});var N=e(z,2);s(N,{title:"Overview",local:"overview",headingTag:"h2"});var L=e(N,10);s(L,{title:"Usage examples",local:"usage-examples",headingTag:"h2"});var Z=e(L,6);s(Z,{title:"Common caveats",local:"common-caveats",headingTag:"h3"});var W=e(Z,4);s(W,{title:"Basic example",local:"basic-example",headingTag:"h3"});var E=e(W,2);m(E,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpZmZ1c2lvbkdlbW1hRm9yQmxvY2tEaWZmdXNpb24lMkMlMjBBdXRvUHJvY2Vzc29yJTBBJTBBJTBBbW9kZWwlMjAlM0QlMjBEaWZmdXNpb25HZW1tYUZvckJsb2NrRGlmZnVzaW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnb29nbGUlMkZkaWZmdXNpb25nZW1tYS0yNkItQTRCLWl0JTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMEEpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGZGlmZnVzaW9uZ2VtbWEtMjZCLUE0Qi1pdCUyMiklMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUyMCUyMnVybCUyMiUzQSUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnBpcGVsaW5lLWNhdC1jaG9uay5qcGVnJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyV2hhdCUyMGlzJTIwc2hvd24lMjBpbiUyMHRoaXMlMjBpbWFnZSUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSU1RCUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvci5hcHBseV9jaGF0X3RlbXBsYXRlKCUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjMlMjBBZGQlMjB0aGUlMjBmb2xsb3dpbmclMjB0byUyMGVuYWJsZSUyMHRoaW5raW5nJTBBJTIwJTIwJTIwJTIwJTIzJTIwZW5hYmxlX3RoaW5raW5nJTNEVHJ1ZSUyQyUwQSkudG8obW9kZWwuZGV2aWNlKSUwQWlucHV0X2xlbiUyMCUzRCUyMGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RC5zaGFwZSU1Qi0xJTVEJTBBJTBBJTIzJTIwU2V0JTIwJTYwY2FjaGVfaW1wbGVtZW50YXRpb24lM0QlMjJzdGF0aWMlMjIlNjAlMjBpbiUyMCU2MGdlbmVyYXRlJTYwJTIwdG8lMjB0cmlnZ2VyJTIwJTYwdG9yY2guY29tcGlsZSU2MC4lMEElMjMlMjBDb21waWxhdGlvbiUyMGlzJTIwbXVjaCUyMGZhc3RlciUyQyUyMGFmdGVyJTIwd2FybWluZyUyMHVwISUwQW91dHB1dCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QyNTYpJTBBcHJpbnQocHJvY2Vzc29yLmRlY29kZShvdXRwdXQuc2VxdWVuY2VzJTVCMCU1RCU1QmlucHV0X2xlbiUzQSU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DiffusionGemmaForBlockDiffusion, AutoProcessor | |
| model = DiffusionGemmaForBlockDiffusion.from_pretrained( | |
| <span class="hljs-string">"google/diffusiongemma-26B-A4B-it"</span>, device_map=<span class="hljs-string">"auto"</span>, | |
| ) | |
| processor = AutoProcessor.from_pretrained(<span class="hljs-string">"google/diffusiongemma-26B-A4B-it"</span>) | |
| messages = [ | |
| { | |
| <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">"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-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"What is shown in this image?"</span>}, | |
| ] | |
| }, | |
| ] | |
| inputs = processor.apply_chat_template( | |
| messages, | |
| tokenize=<span class="hljs-literal">True</span>, | |
| return_dict=<span class="hljs-literal">True</span>, | |
| return_tensors=<span class="hljs-string">"pt"</span>, | |
| add_generation_prompt=<span class="hljs-literal">True</span>, | |
| <span class="hljs-comment"># Add the following to enable thinking</span> | |
| <span class="hljs-comment"># enable_thinking=True,</span> | |
| ).to(model.device) | |
| input_len = inputs[<span class="hljs-string">"input_ids"</span>].shape[-<span class="hljs-number">1</span>] | |
| <span class="hljs-comment"># Set \`cache_implementation="static"\` in \`generate\` to trigger \`torch.compile\`.</span> | |
| <span class="hljs-comment"># Compilation is much faster, after warming up!</span> | |
| output = model.generate(**inputs, max_new_tokens=<span class="hljs-number">256</span>) | |
| <span class="hljs-built_in">print</span>(processor.decode(output.sequences[<span class="hljs-number">0</span>][input_len:], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1});var q=e(E,2);s(q,{title:"Streaming",local:"streaming",headingTag:"h3"});var V=e(q,4);m(V,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRleHREaWZmdXNpb25TdHJlYW1lciUwQSUwQSUyMyUyMCguLi4lMjBjb3B5JTIwZnJvbSUyMHRoZSUyMGV4YW1wbGUlMjBhYm92ZSUyQyUyMHVwJTIwdG8lMjB0aGUlMjAlNjBnZW5lcmF0ZSU2MCUyMGNhbGwpJTBBc3RyZWFtZXIlMjAlM0QlMjBUZXh0RGlmZnVzaW9uU3RyZWFtZXIodG9rZW5pemVyJTNEcHJvY2Vzc29yLnRva2VuaXplciklMEFtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMjU2JTJDJTIwc3RyZWFtZXIlM0RzdHJlYW1lcik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TextDiffusionStreamer | |
| <span class="hljs-comment"># (... copy from the example above, up to the \`generate\` call)</span> | |
| streamer = TextDiffusionStreamer(tokenizer=processor.tokenizer) | |
| model.generate(**inputs, max_new_tokens=<span class="hljs-number">256</span>, streamer=streamer)`,lang:"python",wrap:!1});var R=e(V,2);s(R,{title:"Setting a starting denoising output",local:"setting-a-starting-denoising-output",headingTag:"h3"});var Q=e(R,4);m(Q,{code:"aW5pdGlhbF9lc3RpbWF0ZSUyMCUzRCUyMC4uLiUyMCUyMyUyMGElMjB0ZW5zb3IlMjB3aXRoJTIwc2hhcGUlMjAoYnN6JTJDJTIwMjU2KSUwQW1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QyNTYlMkMlMjBkZWNvZGVyX2lucHV0X2lkcyUzRGluaXRpYWxfZXN0aW1hdGUp",highlighted:`initial_estimate = ... <span class="hljs-comment"># a tensor with shape (bsz, 256)</span> | |
| model.generate(**inputs, max_new_tokens=<span class="hljs-number">256</span>, decoder_input_ids=initial_estimate)`,lang:"py",wrap:!1});var F=e(Q,2);s(F,{title:"DiffusionGemmaTextConfig",local:"transformers.DiffusionGemmaTextConfig",headingTag:"h2"});var _=e(F,2),Se=n(_);o(Se,{name:"class transformers.DiffusionGemmaTextConfig",anchor:"transformers.DiffusionGemmaTextConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/configuration_diffusion_gemma.py#L35",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 = 262144"},{name:"hidden_size",val:": int = 2304"},{name:"intermediate_size",val:": int = 9216"},{name:"num_hidden_layers",val:": int = 30"},{name:"num_attention_heads",val:": int = 8"},{name:"num_key_value_heads",val:": int = 4"},{name:"head_dim",val:": int = 256"},{name:"hidden_activation",val:": str = 'gelu_pytorch_tanh'"},{name:"max_position_embeddings",val:": int = 131072"},{name:"initializer_range",val:": float = 0.02"},{name:"rms_norm_eps",val:": float = 1e-06"},{name:"pad_token_id",val:": int | None = 0"},{name:"eos_token_id",val:": int | list[int] | None = 1"},{name:"bos_token_id",val:": int | None = 2"},{name:"tie_word_embeddings",val:": bool = True"},{name:"rope_parameters",val:": dict | None = None"},{name:"attention_bias",val:": bool = False"},{name:"attention_dropout",val:": int | float | None = 0.0"},{name:"sliding_window",val:": int = 512"},{name:"layer_types",val:": list[str] | None = None"},{name:"use_bidirectional_attention",val:": typing.Optional[typing.Literal['all', 'vision']] = None"},{name:"num_experts",val:": int | None = None"},{name:"top_k_experts",val:": int | None = None"},{name:"moe_intermediate_size",val:": int | None = None"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaTextConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>262144</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.DiffusionGemmaTextConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2304</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.DiffusionGemmaTextConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>9216</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.DiffusionGemmaTextConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>30</code>) — | |
| Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.DiffusionGemmaTextConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.DiffusionGemmaTextConfig.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.DiffusionGemmaTextConfig.head_dim",description:`<strong>head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) — | |
| The attention head dimension. If None, it will default to hidden_size // num_attention_heads`,name:"head_dim"},{anchor:"transformers.DiffusionGemmaTextConfig.hidden_activation",description:`<strong>hidden_activation</strong> (<code>str</code>, <em>optional</em>, defaults to <code>gelu_pytorch_tanh</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_activation"},{anchor:"transformers.DiffusionGemmaTextConfig.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.DiffusionGemmaTextConfig.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.DiffusionGemmaTextConfig.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"},{anchor:"transformers.DiffusionGemmaTextConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.DiffusionGemmaTextConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.DiffusionGemmaTextConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.DiffusionGemmaTextConfig.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.DiffusionGemmaTextConfig.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.DiffusionGemmaTextConfig.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a bias in the query, key, value and output projection layers during self-attention.`,name:"attention_bias"},{anchor:"transformers.DiffusionGemmaTextConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>Union[int, float]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.DiffusionGemmaTextConfig.sliding_window",description:`<strong>sliding_window</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) — | |
| Sliding window attention window size. If <code>None</code>, no sliding window is applied.`,name:"sliding_window"},{anchor:"transformers.DiffusionGemmaTextConfig.layer_types",description:`<strong>layer_types</strong> (<code>list[str]</code>, <em>optional</em>) — | |
| A list that explicitly maps each layer index with its layer type. If not provided, it will be automatically | |
| generated based on config values.`,name:"layer_types"},{anchor:"transformers.DiffusionGemmaTextConfig.use_bidirectional_attention",description:`<strong>use_bidirectional_attention</strong> (<code>str</code>, <em>optional</em>) — | |
| Controls bidirectional attention behavior. When set to <code>"vision"</code>, vision tokens | |
| attend bidirectionally while text tokens use causal attention. When set to <code>"all"</code>, | |
| all tokens use bidirectional attention.`,name:"use_bidirectional_attention"},{anchor:"transformers.DiffusionGemmaTextConfig.num_experts",description:`<strong>num_experts</strong> (<code>int</code>, <em>optional</em>) — | |
| Number of routed experts in MoE layers.`,name:"num_experts"},{anchor:"transformers.DiffusionGemmaTextConfig.top_k_experts",description:`<strong>top_k_experts</strong> (<code>int</code>, <em>optional</em>) — | |
| Number of experts activated per token in MoE layers.`,name:"top_k_experts"},{anchor:"transformers.DiffusionGemmaTextConfig.moe_intermediate_size",description:`<strong>moe_intermediate_size</strong> (<code>int</code>, <em>optional</em>) — | |
| Intermediate (hidden) size of each expert’s feed-forward network in MoE layers.`,name:"moe_intermediate_size"}]}),i(4),t(_);var P=e(_,2);s(P,{title:"DiffusionGemmaConfig",local:"transformers.DiffusionGemmaConfig",headingTag:"h2"});var M=e(P,2),Y=n(M);o(Y,{name:"class transformers.DiffusionGemmaConfig",anchor:"transformers.DiffusionGemmaConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/configuration_diffusion_gemma.py#L158",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:": transformers.models.diffusion_gemma.configuration_diffusion_gemma.DiffusionGemmaTextConfig | dict[str, typing.Any] | None = None"},{name:"vision_config",val:": transformers.configuration_utils.PreTrainedConfig | dict[str, typing.Any] | None = None"},{name:"boi_token_id",val:": int | None = 255999"},{name:"eoi_token_id",val:": int | None = 258882"},{name:"image_token_id",val:": int | None = 258880"},{name:"initializer_range",val:": float | None = 0.02"},{name:"tie_word_embeddings",val:": bool = True"},{name:"canvas_length",val:": int | None = 256"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaConfig.text_config",description:`<strong>text_config</strong> (<code>Union[~models.diffusion_gemma.configuration_diffusion_gemma.DiffusionGemmaTextConfig, dict[str, Any]]</code>, <em>optional</em>) — | |
| The config object or dictionary of the text backbone.`,name:"text_config"},{anchor:"transformers.DiffusionGemmaConfig.vision_config",description:`<strong>vision_config</strong> (<code>Union[~configuration_utils.PreTrainedConfig, dict[str, Any]]</code>, <em>optional</em>) — | |
| The config object or dictionary of the vision backbone.`,name:"vision_config"},{anchor:"transformers.DiffusionGemmaConfig.boi_token_id",description:`<strong>boi_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 255999) — | |
| The begin-of-image token index to wrap the image prompt.`,name:"boi_token_id"},{anchor:"transformers.DiffusionGemmaConfig.eoi_token_id",description:`<strong>eoi_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 258882) — | |
| The end-of-image token index to wrap the image prompt.`,name:"eoi_token_id"},{anchor:"transformers.DiffusionGemmaConfig.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>258880</code>) — | |
| The image token index used as a placeholder for input images.`,name:"image_token_id"},{anchor:"transformers.DiffusionGemmaConfig.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.DiffusionGemmaConfig.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.DiffusionGemmaConfig.canvas_length",description:`<strong>canvas_length</strong> (<code>int</code>, <em>optional</em>, defaults to 256) — | |
| The size of the canvas or, in other words, the block length in block diffusion. Used to initialize an empty | |
| canvas.`,name:"canvas_length"}]});var Be=e(Y,6);g(Be,{anchor:"transformers.DiffusionGemmaConfig.example",children:(r,d)=>{var a=co(),l=e(f(a),2);m(l,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBEaWZmdXNpb25HZW1tYUNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMERpZmZ1c2lvbkdlbW1hTW9kZWwlMkMlMEElMjAlMjAlMjAlMjBEaWZmdXNpb25HZW1tYVRleHRDb25maWclMkMlMEElMjAlMjAlMjAlMjBHZW1tYTRWaXNpb25Db25maWclMkMlMEEpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMERpZmZ1c2lvbkdlbW1hJTIwVGV4dCUyMGNvbmZpZy4lMEF0ZXh0X2NvbmZpZyUyMCUzRCUyMERpZmZ1c2lvbkdlbW1hVGV4dENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEdlbW1hJTIwNCUyMHZpc2lvbiUyMGNvbmZpZyUyMChEaWZmdXNpb25HZW1tYSUyMHVzZXMlMjBHZW1tYSUyMDQncyUyMHZpc2lvbiUyMGJsb2NrKS4lMEF2aXNpb25fY29uZmlnJTIwJTNEJTIwR2VtbWE0VmlzaW9uQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwRGlmZnVzaW9uR2VtbWElMjB0ZXh0JTIwY29uZmlnJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMERpZmZ1c2lvbkdlbW1hQ29uZmlnKHRleHRfY29uZmlnJTJDJTIwdmlzaW9uX2NvbmZpZyklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwRGlmZnVzaW9uR2VtbWFNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ( | |
| <span class="hljs-meta">>>> </span> DiffusionGemmaConfig, | |
| <span class="hljs-meta">>>> </span> DiffusionGemmaModel, | |
| <span class="hljs-meta">>>> </span> DiffusionGemmaTextConfig, | |
| <span class="hljs-meta">>>> </span> Gemma4VisionConfig, | |
| <span class="hljs-meta">>>> </span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a DiffusionGemma Text config.</span> | |
| <span class="hljs-meta">>>> </span>text_config = DiffusionGemmaTextConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a Gemma 4 vision config (DiffusionGemma uses Gemma 4's vision block).</span> | |
| <span class="hljs-meta">>>> </span>vision_config = Gemma4VisionConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a DiffusionGemma text config</span> | |
| <span class="hljs-meta">>>> </span>configuration = DiffusionGemmaConfig(text_config, vision_config) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the configuration</span> | |
| <span class="hljs-meta">>>> </span>model = DiffusionGemmaModel(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}),c(r,a)},$$slots:{default:!0}}),t(M);var X=e(M,2);s(X,{title:"DiffusionGemmaGenerationOutput",local:"transformers.DiffusionGemmaGenerationOutput",headingTag:"h2"});var y=e(X,2),ze=n(y);o(ze,{name:"class transformers.DiffusionGemmaGenerationOutput",anchor:"transformers.DiffusionGemmaGenerationOutput",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L248",parameters:[{name:"sequences",val:": LongTensor"},{name:"tokens_per_forward",val:": int | None = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"logits",val:": None = None"},{name:"scores",val:": None = None"},{name:"hidden_states",val:": None = None"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationOutput.sequences",description:`<strong>sequences</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| The generated sequences, including the prompt if <code>input_ids</code> was provided to the <code>generate</code> method.`,name:"sequences"},{anchor:"transformers.DiffusionGemmaGenerationOutput.tokens_per_forward",description:`<strong>tokens_per_forward</strong> (<code>torch.LongTensor</code> of shape (<code>batch_size</code>)) — | |
| The number of tokens per forward in this <code>generate</code> call, for each member in the batch. This is often | |
| used as a secondary evaluation metric for text diffusion models.`,name:"tokens_per_forward"},{anchor:"transformers.DiffusionGemmaGenerationOutput.cache",description:`<strong>cache</strong> (<code>Cache</code>) — | |
| The cache used for generation. It can be passed to subsequent calls to <code>generate</code> to speed up generation, | |
| in multi-turn sessions.`,name:"cache"},{anchor:"transformers.DiffusionGemmaGenerationOutput.logits",description:`<strong>logits</strong> (<code>None</code>) — | |
| Unused. Kept in the interface for BC.`,name:"logits"},{anchor:"transformers.DiffusionGemmaGenerationOutput.scores",description:`<strong>scores</strong> (<code>None</code>) — | |
| Unused. Kept in the interface for BC.`,name:"scores"},{anchor:"transformers.DiffusionGemmaGenerationOutput.hidden_states",description:`<strong>hidden_states</strong> (<code>None</code>) — | |
| Unused. Kept in the interface for BC.`,name:"hidden_states"}]}),i(2),t(y);var H=e(y,2);s(H,{title:"DiffusionGemmaGenerationMixin",local:"transformers.DiffusionGemmaGenerationMixin",headingTag:"h2"});var T=e(H,2),O=n(T);o(O,{name:"class transformers.DiffusionGemmaGenerationMixin",anchor:"transformers.DiffusionGemmaGenerationMixin",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L544",parameters:[]});var K=e(O,4),$=n(K);o($,{name:"generate",anchor:"transformers.DiffusionGemmaGenerationMixin.generate",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L549",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"streamer",val:": transformers.generation.streamers.BaseStreamer | None = None"},{name:"generation_config",val:": transformers.models.diffusion_gemma.generation_diffusion_gemma.DiffusionGemmaGenerationConfig | None = None"},{name:"logits_processor",val:": transformers.generation.logits_process.LogitsProcessorList | None = None"},{name:"stopping_criteria",val:": transformers.generation.stopping_criteria.StoppingCriteriaList | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.input_ids",description:`<strong>input_ids</strong> (<em>torch.LongTensor</em> of shape <em>(batch_size, sequence_length)</em>, <em>optional</em>) — | |
| The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.cache",description:`<strong>cache</strong> (<a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.Cache">Cache</a>, <em>optional</em>) — | |
| Cache object containing the past key values and past attention masks for the decoder. If it is set, | |
| <code>input_ids</code> and/or <code>pixel_values</code> must correspond to uncached data only.`,name:"cache"},{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.streamer",description:`<strong>streamer</strong> (<code>BaseStreamer</code>, <em>optional</em>) — | |
| Streamer object that will be used to stream the generated sequences. Generated tokens are passed | |
| through <code>streamer.put(token_ids)</code> and the streamer is responsible for any further processing. If the | |
| streamer object has a <code>put_draft</code> method, tokens from the denoising steps will be sent there.`,name:"streamer"}],returnDescription:` | |
| <ul> | |
| <li><code>torch.LongTensor</code>: the generated text in ids.</li> | |
| <li><a | |
| href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaGenerationOutput" | |
| >DiffusionGemmaGenerationOutput</a>: a <code>ModelOutput</code> instance containing the generated text (<code>sequences</code>), | |
| as well as other optional outputs.</li> | |
| </ul> | |
| `,returnType:` | |
| <p><code>torch.LongTensor</code> or <a | |
| href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaGenerationOutput" | |
| >DiffusionGemmaGenerationOutput</a></p> | |
| `,parameterGroups:[{title:"Additional arguments for power users",parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.generation_config",description:`<strong>generation_config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaGenerationConfig">DiffusionGemmaGenerationConfig</a>, <em>optional</em>) — | |
| The generation configuration to be used as base parametrization for the generation call, overriding | |
| the model defaults. If the model checkpoint has a <code>generation_config.json</code> file, the model default | |
| will be loaded from there. Otherwise, it will be an empty <code>DiffusionGemmaGenerationConfig</code> instance. | |
| As an additional shortcut, <code>**kwargs</code> matching attributes in the <code>generation_config</code> will override them.`,name:"generation_config"},{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.logits_processor",description:`<strong>logits_processor</strong> (<a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>, <em>optional</em>) — | |
| Custom logits processors that complement the default logits processors built from arguments and | |
| generation config, to be applied on the diffusion logits. If provided, these processors will be first | |
| to be applied. This feature is intended for advanced users. You can, for instance, pass here the | |
| logits processors commonly used with AR LLMs.`,name:"logits_processor"},{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.stopping_criteria",description:`<strong>stopping_criteria</strong> (<a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>, <em>optional</em>) — | |
| Custom stopping criteria that complements the default block autoregressive stopping criteria built | |
| from arguments and a generation config. If provided, these criteria will be first to be applied. This | |
| feature is intended for advanced users. You can, for instance, pass here the stopping criteria commonly | |
| used with AR LLMs.`,name:"stopping_criteria"},{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.kwargs",description:`<strong>kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) — | |
| Ad hoc parametrization of <code>generation_config</code> and/or additional model-specific kwargs that will be | |
| forwarded to the <code>forward</code> function of the model. For instance, you can set the starting canvas with | |
| <code>decoder_input_ids</code>.`,name:"kwargs"}]}]});var ee=e($,6);g(ee,{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.example",children:(r,d)=>{var a=lo(),l=e(f(a),2);m(l,{code:"MS4lMjBBdXRvcmVncmVzc2l2ZSUyMGNhbnZhcyUyMGdlbmVyYXRpb24lMjBsb29wJTNBJTBBJTIwJTIwJTIwJTIwYS4lMjBFbmNvZGUlMjBhbGwlMjBwcmV2aW91cyUyMHRva2VucyUyMHVzaW5nJTIwdGhlJTIwZW5jb2RlciUyQyUyMHRvJTIwZ2V0JTIwdGhlJTIwS1YlMjBjYWNoZS4lMEElMjAlMjAlMjAlMjBiLiUyMFByZXBhcmUlMjBkYXRhJTIwZm9yJTIwdGhlJTIwbmV3JTIwZGVub2lzaW5nJTIwbG9vcCUwQSUyMCUyMCUyMCUyMGMuJTIwRm9yJTIwZWFjaCUyMGRlbm9pc2luZyUyMChkaWZmdXNpb24pJTIwc3RlcCUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGkuJTIwJTIwJTIwUnVuJTIwdGhlJTIwZGVjb2RlciUyQyUyMHRha2luZyUyMHRoZSUyMGN1cnJlbnQlMjBjYW52YXMlMkMlMjB0aGUlMjBlbmNvZGVyJTIwS1YlMjBjYWNoZSUyQyUyMGFuZCUyMHRoZSUyMHNlbGYtY29uZGl0aW9uaW5nJTIwbG9naXRzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKGlmJTIwYXZhaWxhYmxlKSUyMGFzJTIwaW5wdXRzLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlpLiUyMCUyMFNlbGVjdCUyMG5ldyUyMGNhbnZhcyUyMHRva2VucyUyMGZyb20lMjB0aGUlMjBvdXRwdXQlMjBsb2dpdHMuJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWlpLiUyMEFwcGx5JTIwdGhlJTIwc2FtcGxlciUyMGFjY2VwdGFuY2UlMjBhbmQlMjByZW5vaXNpbmclMjBsb2dpYy4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpdi4lMjAlMjBVcGRhdGUlMjB0aGUlMjBkaWZmdXNpb24lMjBzdG9wcGluZyUyMGNyaXRlcmlhLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHYuJTIwJTIwJTIwVXNlJTIwdGhlJTIwb3V0cHV0JTIwbG9naXRzJTIwYXMlMjBzZWxmLWNvbmRpdGlvbmluZyUyMGxvZ2l0cyUyMGZvciUyMHRoZSUyMG5leHQlMjBzdGVwLiUwQSUyMCUyMCUyMCUyMGQuJTIwQXBwZW5kJTIwdGhlJTIwbmV3JTIwZGVub2lzZWQlMjBjYW52YXMlMjB0byUyMHRoZSUyMHNlcXVlbmNlJTIwb2YlMjBnZW5lcmF0ZWQlMjB0b2tlbnMuJTBBJTIwJTIwJTIwJTIwZS4lMjBDaGVjayUyMGlmJTIwYW55JTIwYXV0b3JlZ3Jlc3NpdmUlMjBzdG9wcGluZyUyMGNyaXRlcmlhJTIwYXJlJTIwbWV0JTJDJTIwYW5kJTIwYnJlYWslMjB0aGUlMjBvdXRlciUyMGxvb3AlMjBpZiUyMGFsbCUyMHNlcXVlbmNlcyUyMGhhdmUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXQlMjB0aGVtLiUyMFJlcGxhY2VzJTIwZ2VuZXJhdGVkJTIwdG9rZW5zJTIwaW4lMjBmaW5pc2hlZCUyMHNlcXVlbmNlcyUyMGJ5JTIwcGFkLiUwQSUyMCUyMCUyMCUyMGYuJTIwUHJlcGFyZSUyMHRlbnNvcnMlMjBmb3IlMjB0aGUlMjBuZXh0JTIwYmxvY2s=",highlighted:`<span class="hljs-number">1</span>. Autoregressive canvas generation <span class="hljs-keyword">loop</span>: | |
| a. Encode all previous tokens <span class="hljs-keyword">using</span> the encoder, <span class="hljs-keyword">to</span> get the KV cache. | |
| b. Prepare data <span class="hljs-keyword">for</span> the <span class="hljs-keyword">new</span> denoising <span class="hljs-keyword">loop</span> | |
| c. <span class="hljs-keyword">For</span> <span class="hljs-keyword">each</span> denoising (diffusion) <span class="hljs-keyword">step</span>: | |
| i. Run the decoder, taking the current canvas, the encoder KV cache, <span class="hljs-keyword">and</span> the <span class="hljs-keyword">self</span>-conditioning logits | |
| (<span class="hljs-keyword">if</span> available) <span class="hljs-keyword">as</span> inputs. | |
| ii. <span class="hljs-keyword">Select</span> <span class="hljs-keyword">new</span> canvas tokens <span class="hljs-keyword">from</span> the output logits. | |
| iii. Apply the sampler acceptance <span class="hljs-keyword">and</span> renoising logic. | |
| iv. Update the diffusion stopping criteria. | |
| v. Use the output logits <span class="hljs-keyword">as</span> <span class="hljs-keyword">self</span>-conditioning logits <span class="hljs-keyword">for</span> the next <span class="hljs-keyword">step</span>. | |
| d. Append the <span class="hljs-keyword">new</span> denoised canvas <span class="hljs-keyword">to</span> the <span class="hljs-keyword">sequence</span> <span class="hljs-keyword">of</span> generated tokens. | |
| e. Check <span class="hljs-keyword">if</span> any autoregressive stopping criteria are met, <span class="hljs-keyword">and</span> <span class="hljs-keyword">break</span> the outer <span class="hljs-keyword">loop</span> <span class="hljs-keyword">if</span> all sequences have | |
| met them. Replaces generated tokens <span class="hljs-keyword">in</span> finished sequences <span class="hljs-keyword">by</span> pad. | |
| f. Prepare tensors <span class="hljs-keyword">for</span> the next <span class="hljs-keyword">block</span>`,lang:"",wrap:!1}),c(r,a)},$$slots:{default:!0}});var Ne=e(ee,2);g(Ne,{anchor:"transformers.DiffusionGemmaGenerationMixin.generate.example-2",children:(r,d)=>{var a=mo(),l=e(f(a),2);m(l,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpZmZ1c2lvbkdlbW1hRm9yQmxvY2tEaWZmdXNpb24lMkMlMjBBdXRvUHJvY2Vzc29yJTJDJTIwVGV4dERpZmZ1c2lvblN0cmVhbWVyJTBBJTBBbW9kZWwlMjAlM0QlMjBEaWZmdXNpb25HZW1tYUZvckJsb2NrRGlmZnVzaW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnb29nbGUlMkZkaWZmdXNpb25nZW1tYS0yNkItQTRCLWl0JTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMEEpJTBBJTBBY2hhdCUyMCUzRCUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoeSUyMGlzJTIwdGhlJTIwc2t5JTIwYmx1ZSUzRiUyMiU3RCUyQyU1RCUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRmRpZmZ1c2lvbmdlbW1hLTI2Qi1BNEItaXQlMjIpJTBBaW5wdXRfaWRzJTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoY2hhdCUyQyUyMHRva2VuaXplJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBc3RyZWFtZXIlMjAlM0QlMjBUZXh0RGlmZnVzaW9uU3RyZWFtZXIodG9rZW5pemVyJTNEcHJvY2Vzc29yLnRva2VuaXplciklMEFtb2RlbC5nZW5lcmF0ZShpbnB1dF9pZHMudG8obW9kZWwuZGV2aWNlKSUyQyUyMG1heF9uZXdfdG9rZW5zJTNENTEyJTJDJTIwc3RyZWFtZXIlM0RzdHJlYW1lcik=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DiffusionGemmaForBlockDiffusion, AutoProcessor, TextDiffusionStreamer | |
| <span class="hljs-meta">>>> </span>model = DiffusionGemmaForBlockDiffusion.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"google/diffusiongemma-26B-A4B-it"</span>, device_map=<span class="hljs-string">"auto"</span>, | |
| <span class="hljs-meta">>>> </span>) | |
| <span class="hljs-meta">>>> </span>chat = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"Why is the sky blue?"</span>},] | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"google/diffusiongemma-26B-A4B-it"</span>) | |
| <span class="hljs-meta">>>> </span>input_ids = processor.apply_chat_template(chat, tokenize=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span>streamer = TextDiffusionStreamer(tokenizer=processor.tokenizer) | |
| <span class="hljs-meta">>>> </span>model.generate(input_ids.to(model.device), max_new_tokens=<span class="hljs-number">512</span>, streamer=streamer)`,lang:"python",wrap:!1}),c(r,a)},$$slots:{default:!0}}),t(K),t(T);var oe=e(T,2);s(oe,{title:"DiffusionGemmaGenerationConfig",local:"transformers.DiffusionGemmaGenerationConfig",headingTag:"h2"});var b=e(oe,2),Le=n(b);o(Le,{name:"class transformers.DiffusionGemmaGenerationConfig",anchor:"transformers.DiffusionGemmaGenerationConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L56",parameters:[{name:"**kwargs",val:""}],parameterGroups:[{title:"Parameters that control the length of the output",parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationConfig.max_new_tokens",description:`<strong>max_new_tokens</strong> (<code>int</code>, <em>optional</em>) — | |
| The maximum number of tokens to generate, ignoring the number of tokens in the prompt.`,name:"max_new_tokens"},{anchor:"transformers.DiffusionGemmaGenerationConfig.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) — | |
| The maximum length of the output sequence. <code>max_new_tokens</code> is recommended for controlling how many tokens | |
| the model generates.`,name:"max_length"}]},{title:"Diffusion parameters",parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationConfig.max_denoising_steps",description:`<strong>max_denoising_steps</strong> (<code>int</code>) — | |
| The maximum number of denoising steps to perform.`,name:"max_denoising_steps"},{anchor:"transformers.DiffusionGemmaGenerationConfig.sampler_config",description:`<strong>sampler_config</strong> (<code>EntropyBoundSamplerConfig</code>) — | |
| The configuration for the sampler. See <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.EntropyBoundSampler">EntropyBoundSampler</a> to learn how a sampler operates in a | |
| text diffusion model.`,name:"sampler_config"},{anchor:"transformers.DiffusionGemmaGenerationConfig.t_min",description:`<strong>t_min</strong> (<code>float</code>) — | |
| The final temperature in the schedule, i.e. at the last denoising step. See | |
| <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.LinearTemperatureScheduleLogitsProcessor">LinearTemperatureScheduleLogitsProcessor</a> for more details.`,name:"t_min"},{anchor:"transformers.DiffusionGemmaGenerationConfig.t_max",description:`<strong>t_max</strong> (<code>float</code>) — | |
| The initial temperature in the schedule, i.e. at the first denoising step. See | |
| <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.LinearTemperatureScheduleLogitsProcessor">LinearTemperatureScheduleLogitsProcessor</a> for more details.`,name:"t_max"},{anchor:"transformers.DiffusionGemmaGenerationConfig.stability_threshold",description:`<strong>stability_threshold</strong> (<code>int</code>) — | |
| The number of steps for which the accepted canvas must be the same to trigger the stopping criteria. | |
| See <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.StableAndConfidentStoppingCriteria">StableAndConfidentStoppingCriteria</a> for more details.`,name:"stability_threshold"},{anchor:"transformers.DiffusionGemmaGenerationConfig.confidence_threshold",description:`<strong>confidence_threshold</strong> (<code>float</code>) — | |
| The threshold for the mean of the entropy of temperature-scaled logits to trigger the stopping criteria. | |
| See <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.StableAndConfidentStoppingCriteria">StableAndConfidentStoppingCriteria</a> for more details.`,name:"confidence_threshold"}]},{title:"Parameters that control the cache",parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationConfig.cache_implementation",description:`<strong>cache_implementation</strong> (<code>str</code>, <em>optional</em>) — | |
| Name of the cache class that will be instantiated in <code>generate</code>, for faster decoding. Possible values are: | |
| <ul> | |
| <li><code>"dynamic"</code>: <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a></li> | |
| <li><code>"static"</code>: <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.StaticCache">StaticCache</a></li> | |
| <li><code>"offloaded"</code>: <code>DynamicCache(offloaded=True)</code></li> | |
| <li><code>"offloaded_static"</code>: <code>StaticCache(offloaded=True)</code></li> | |
| <li><code>"quantized"</code>: <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.QuantizedCache">QuantizedCache</a></li> | |
| </ul> | |
| <p>If none is specified, we will use the default cache for the model (which is often <a href="/docs/transformers/pr_51549/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a>). See | |
| our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">cache documentation</a> for further information.</p>`,name:"cache_implementation"},{anchor:"transformers.DiffusionGemmaGenerationConfig.cache_config",description:`<strong>cache_config</strong> (<code>dict</code>, <em>optional</em>, default to <code>None</code>) — | |
| Arguments used in the key-value cache class can be passed in <code>cache_config</code>.`,name:"cache_config"}]},{title:"Special tokens that can be used at generation time",parametersDescription:[{anchor:"transformers.DiffusionGemmaGenerationConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| The id of the <em>beginning-of-sequence</em> token.`,name:"bos_token_id"},{anchor:"transformers.DiffusionGemmaGenerationConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.DiffusionGemmaGenerationConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>) — | |
| The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"}]}]}),i(2),t(b);var ne=e(b,2);s(ne,{title:"EntropyBoundSamplerConfig",local:"transformers.EntropyBoundSamplerConfig",headingTag:"h2"});var w=e(ne,2),Ze=n(w);o(Ze,{name:"class transformers.EntropyBoundSamplerConfig",anchor:"transformers.EntropyBoundSamplerConfig",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L321",parameters:[{name:"entropy_bound",val:": float"}],parametersDescription:[{anchor:"transformers.EntropyBoundSamplerConfig.entropy_bound",description:`<strong>entropy_bound</strong> (<code>float</code>) — | |
| The entropy bound. The higher this value is, the more tokens will be accepted. See the docstring of | |
| <a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.EntropyBoundSampler.accept_canvas">EntropyBoundSampler.accept_canvas()</a> for more details on how it is applied.`,name:"entropy_bound"}]}),i(2),t(w);var te=e(w,2);s(te,{title:"EntropyBoundSampler",local:"transformers.EntropyBoundSampler",headingTag:"h2"});var v=e(te,2),se=n(v);o(se,{name:"class transformers.EntropyBoundSampler",anchor:"transformers.EntropyBoundSampler",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L344",parameters:[{name:"config",val:": EntropyBoundSamplerConfig"},{name:"canvas_length",val:": int"},{name:"vocab_size",val:": int"},{name:"max_denoising_steps",val:": int"}],parametersDescription:[{anchor:"transformers.EntropyBoundSampler.config",description:`<strong>config</strong> (<code>EntropyBoundSamplerConfig</code>) — | |
| The configuration of the sampler.`,name:"config"},{anchor:"transformers.EntropyBoundSampler.canvas_length",description:`<strong>canvas_length</strong> (<code>int</code>) — | |
| The length of the canvas.`,name:"canvas_length"},{anchor:"transformers.EntropyBoundSampler.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>) — | |
| The size of the vocabulary.`,name:"vocab_size"},{anchor:"transformers.EntropyBoundSampler.max_denoising_steps",description:`<strong>max_denoising_steps</strong> (<code>int</code>) — | |
| The maximum number of denoising steps. (Unused in this sampler)`,name:"max_denoising_steps"}]});var ae=e(se,4);g(ae,{anchor:"transformers.EntropyBoundSampler.example",children:(r,d)=>{var a=po(),l=e(f(a),2);m(l,{code:"JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjBDYW52YXMlMjBpbml0aWFsaXphdGlvbiUyMCU3QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyMHhfVCUyMCVFMiU4OCU4OCUyMFUoViklMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLSUyQi0tLS0tLS0tLS0tJTJCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0lMkItLS0tLS0tLS0lMkIlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMkItLS0tLS0tLS0lM0UlN0MlMjBDdXJyZW50JTIwY2FudmFzJTIweF90JTIwJTdDLS0tLS0tJTNFJTdDJTIwRGVub2lzZXIlMjBjYW52YXMlMjB4X0QlMjAlN0MlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tJTJCLS0tLS0tLS0tJTJCJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLSUyQi0tLS0tLS0tLS0lMkIlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkYlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkYlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUMlMjAlMjAlMjBBY2NlcHRhbmNlJTIwbG9naWMlMjAlMjAlMjAlMkYlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdiUwQSU3QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElN0MlMjBTdG9wJTIwaWYlMjBtYXglMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjBBY2NlcHRlZCUyMGNhbnZhcyUyMHhfJTdCdC0xJTdEJTIwJTdDJTBBJTdDJTIwZGVub3NpbmclMjBzdGVwcyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLSUyQi0tLS0tLS0tLS0tLSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElN0MlMjByZWFjaGVkJTIwb3IlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjBOZXclMjBjYW52YXMlMjAlRTIlODglODglMjBVKFYpJTIwJTdDJTBBJTdDJTIwYWRhcHRpdmUlMjBzdG9wcGluZyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLSUyQi0tLS0tLS0tLSUyQiUwQSU3QyUyMHRyaWdnZXJzJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVDJTIwJTIwJTIwJTIwUmVub2lzaW5nJTIwbG9naWMlMjAlMjAlMjAlMjAlMjAlMjAlMkYlMEElN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdiUwQSU3QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lN0MlMjBOZXh0JTIwY2FudmFzJTIweF8lN0J0LTElN0QlMjAlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tJTJC",highlighted:` +-----------------------+ | |
| |<span class="hljs-string"> Canvas initialization </span>| | |
| |<span class="hljs-string"> x_T ∈ U(V) </span>| | |
| +-----------+-----------+ | |
| |<span class="hljs-string"> | |
| v | |
| +----------+---------+ +---------------------+ | |
| +---------></span>|<span class="hljs-string"> Current canvas x_t </span>|<span class="hljs-string">------></span>|<span class="hljs-string"> Denoiser canvas x_D </span>| | |
| |<span class="hljs-string"> +----------+---------+ +----------+----------+ | |
| </span>|<span class="hljs-string"> \\ / | |
| </span>|<span class="hljs-string"> \\ / | |
| </span>|<span class="hljs-string"> \\ Acceptance logic / | |
| </span>|<span class="hljs-string"> v v | |
| </span>|<span class="hljs-string"> +-------------------------+ | |
| </span>|<span class="hljs-string"> Stop if max </span>|<span class="hljs-string"> Accepted canvas x_{t-1} </span>| | |
| |<span class="hljs-string"> denosing steps +------------+------------+ +-------------------+ | |
| </span>|<span class="hljs-string"> reached or \\ </span>|<span class="hljs-string"> New canvas ∈ U(V) </span>| | |
| |<span class="hljs-string"> adaptive stopping \\ +---------+---------+ | |
| </span>|<span class="hljs-string"> triggers \\ Renoising logic / | |
| </span>|<span class="hljs-string"> v v | |
| </span>|<span class="hljs-string"> +-------------------------+ | |
| +---------------------------------------</span>|<span class="hljs-string"> Next canvas x_{t-1} </span>| | |
| +-------------------------+`,lang:"",wrap:!1}),c(r,a)},$$slots:{default:!0}});var j=e(ae,2),We=n(j);o(We,{name:"accept_canvas",anchor:"transformers.EntropyBoundSampler.accept_canvas",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L407",parameters:[{name:"current_canvas",val:": LongTensor"},{name:"denoiser_canvas",val:": LongTensor"},{name:"logits",val:": Tensor"},{name:"cur_step",val:": int"}],parametersDescription:[{anchor:"transformers.EntropyBoundSampler.accept_canvas.current_canvas",description:`<strong>current_canvas</strong> (<code>torch.LongTensor</code>) — | |
| The current canvas.`,name:"current_canvas"},{anchor:"transformers.EntropyBoundSampler.accept_canvas.denoiser_canvas",description:`<strong>denoiser_canvas</strong> (<code>torch.LongTensor</code>) — | |
| The canvas sampled from the denoiser predictions.`,name:"denoiser_canvas"},{anchor:"transformers.EntropyBoundSampler.accept_canvas.logits",description:`<strong>logits</strong> (<code>torch.Tensor</code>) — | |
| The logits from the denoiser.`,name:"logits"},{anchor:"transformers.EntropyBoundSampler.accept_canvas.cur_step",description:`<strong>cur_step</strong> (<code>int</code>) — | |
| The current step.`,name:"cur_step"}],returnDescription:` | |
| <p>The accepted canvas.</p> | |
| `,returnType:` | |
| <p>torch.LongTensor</p> | |
| `}),i(8),t(j);var U=e(j,2),Ee=n(U);o(Ee,{name:"initialize_canvas",anchor:"transformers.EntropyBoundSampler.initialize_canvas",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L395",parameters:[{name:"batch_size",val:": int"},{name:"device",val:": device"}]}),i(2),t(U);var re=e(U,2),qe=n(re);o(qe,{name:"renoise_canvas",anchor:"transformers.EntropyBoundSampler.renoise_canvas",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L451",parameters:[{name:"accepted_canvas",val:": LongTensor"},{name:"cur_step",val:": int"}],parametersDescription:[{anchor:"transformers.EntropyBoundSampler.renoise_canvas.accepted_canvas",description:`<strong>accepted_canvas</strong> (<code>torch.LongTensor</code>) — | |
| The accepted canvas.`,name:"accepted_canvas"},{anchor:"transformers.EntropyBoundSampler.renoise_canvas.cur_step",description:`<strong>cur_step</strong> (<code>int</code>) — | |
| The current step. (Unused in this sampler)`,name:"cur_step"}],returnDescription:` | |
| <p>The renoised canvas.</p> | |
| `,returnType:` | |
| <p>torch.LongTensor</p> | |
| `}),i(2),t(re),t(v);var ie=e(v,2);s(ie,{title:"StableAndConfidentStoppingCriteria",local:"transformers.StableAndConfidentStoppingCriteria",headingTag:"h2"});var C=e(ie,2),Ve=n(C);o(Ve,{name:"class transformers.StableAndConfidentStoppingCriteria",anchor:"transformers.StableAndConfidentStoppingCriteria",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L485",parameters:[{name:"stability_threshold",val:": int"},{name:"confidence_threshold",val:": float"}],parametersDescription:[{anchor:"transformers.StableAndConfidentStoppingCriteria.stability_threshold",description:`<strong>stability_threshold</strong> (<code>int</code>) — | |
| The number of steps for which the accepted canvas must be the same to trigger the stopping criteria.`,name:"stability_threshold"},{anchor:"transformers.StableAndConfidentStoppingCriteria.confidence_threshold",description:`<strong>confidence_threshold</strong> (<code>float</code>) — | |
| The threshold for the mean of the entropy of temperature-scaled logits to trigger the stopping criteria.`,name:"confidence_threshold"}]}),i(4),t(C);var de=e(C,2);s(de,{title:"LinearTemperatureScheduleLogitsProcessor",local:"transformers.LinearTemperatureScheduleLogitsProcessor",headingTag:"h2"});var G=e(de,2),Re=n(G);o(Re,{name:"class transformers.LinearTemperatureScheduleLogitsProcessor",anchor:"transformers.LinearTemperatureScheduleLogitsProcessor",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/generation_diffusion_gemma.py#L277",parameters:[{name:"t_min",val:": float"},{name:"t_max",val:": float"},{name:"max_denoising_steps",val:": int"}],parametersDescription:[{anchor:"transformers.LinearTemperatureScheduleLogitsProcessor.t_min",description:`<strong>t_min</strong> (<code>float</code>) — | |
| The final temperature in the schedule, i.e. at the last denoising step.`,name:"t_min"},{anchor:"transformers.LinearTemperatureScheduleLogitsProcessor.t_max",description:`<strong>t_max</strong> (<code>float</code>) — | |
| The initial temperature in the schedule, i.e. at the first denoising step.`,name:"t_max"},{anchor:"transformers.LinearTemperatureScheduleLogitsProcessor.max_denoising_steps",description:`<strong>max_denoising_steps</strong> (<code>int</code>) — | |
| The maximum number of denoising steps.`,name:"max_denoising_steps"}]}),i(4),t(G);var ce=e(G,2);s(ce,{title:"DiffusionGemmaPreTrainedModel",local:"transformers.DiffusionGemmaPreTrainedModel",headingTag:"h2"});var J=e(ce,2),le=n(J);o(le,{name:"class transformers.DiffusionGemmaPreTrainedModel",anchor:"transformers.DiffusionGemmaPreTrainedModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L821",parameters:[{name:"config",val:": PreTrainedConfig"},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DiffusionGemmaPreTrainedModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</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 me=e(le,6),Qe=n(me);o(Qe,{name:"forward",anchor:"transformers.DiffusionGemmaPreTrainedModel.forward",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}),i(2),t(me),t(J);var pe=e(J,2);s(pe,{title:"DiffusionGemmaModel",local:"transformers.DiffusionGemmaModel",headingTag:"h2"});var k=e(pe,2),fe=n(k);o(fe,{name:"class transformers.DiffusionGemmaModel",anchor:"transformers.DiffusionGemmaModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1458",parameters:[{name:"config",val:": DiffusionGemmaConfig"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaConfig">DiffusionGemmaConfig</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 he=e(fe,8),ue=n(he);o(ue,{name:"forward",anchor:"transformers.DiffusionGemmaModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1500",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"self_conditioning_logits",val:": typing.Optional[torch.Tensor] = None"},{name:"self_conditioning_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"decoder_attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"decoder_position_ids",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.DiffusionGemmaModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Uncached token IDs for the prompt to be encoded as context for the canvas.`,name:"input_ids"},{anchor:"transformers.DiffusionGemmaModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>dict</code>, <em>optional</em>) — | |
| Mask for the input tokens.`,name:"attention_mask"},{anchor:"transformers.DiffusionGemmaModel.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.DiffusionGemmaModel.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.DiffusionGemmaModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>, <em>optional</em>) — | |
| Token IDs for the canvas to be refined.`,name:"decoder_input_ids"},{anchor:"transformers.DiffusionGemmaModel.forward.self_conditioning_logits",description:`<strong>self_conditioning_logits</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, canvas_length, vocab_size)</code>, <em>optional</em>) — | |
| Self-conditioning logits from the previous denoising step, used to compute the | |
| self-conditioning embeddings.`,name:"self_conditioning_logits"},{anchor:"transformers.DiffusionGemmaModel.forward.self_conditioning_mask",description:`<strong>self_conditioning_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Per-example mask over <code>self_conditioning_logits</code>: examples set to <code>False</code> get a zeroed self-conditioning | |
| signal, as if no logits were passed for them. Useful for training, where self-conditioning is enabled per | |
| example with some probability.`,name:"self_conditioning_mask"},{anchor:"transformers.DiffusionGemmaModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length+canvas_length)</code> or <code>dict</code>, <em>optional</em>) — | |
| Attention mask for the decoder KV cache. Used to specify padded/unpopulated encoder KV cached entries.`,name:"decoder_attention_mask"},{anchor:"transformers.DiffusionGemmaModel.forward.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>, <em>optional</em>) — | |
| The position IDs for the tokens in the canvas.`,name:"decoder_position_ids"},{anchor:"transformers.DiffusionGemmaModel.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>DiffusionGemmaModelOutputWithPast</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>DiffusionGemmaModelOutputWithPast</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Fe=e(ue,4);h(Fe,{children:(r,d)=>{var a=u();c(r,a)},$$slots:{default:!0}}),i(2),t(he),t(k);var ge=e(k,2);s(ge,{title:"DiffusionGemmaEncoderModel",local:"transformers.DiffusionGemmaEncoderModel",headingTag:"h2"});var A=e(ge,2),_e=n(A);o(_e,{name:"class transformers.DiffusionGemmaEncoderModel",anchor:"transformers.DiffusionGemmaEncoderModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L998",parameters:[{name:"config",val:": DiffusionGemmaConfig"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaEncoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_51549/en/model_doc/diffusion_gemma#transformers.DiffusionGemmaConfig">DiffusionGemmaConfig</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 Me=e(_e,8),ye=n(Me);o(ye,{name:"forward",anchor:"transformers.DiffusionGemmaEncoderModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1064",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"mm_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"image_position_ids",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.DiffusionGemmaEncoderModel.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.DiffusionGemmaEncoderModel.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.DiffusionGemmaEncoderModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>Union[torch.Tensor, dict]</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.DiffusionGemmaEncoderModel.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.DiffusionGemmaEncoderModel.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.DiffusionGemmaEncoderModel.forward.mm_token_type_ids",description:`<strong>mm_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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_51549/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a>. See <a href="/docs/transformers/pr_51549/en/main_classes/processors#transformers.ProcessorMixin.__call__">ProcessorMixin.<strong>call</strong>()</a> for details.`,name:"mm_token_type_ids"},{anchor:"transformers.DiffusionGemmaEncoderModel.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.DiffusionGemmaEncoderModel.forward.image_position_ids",description:`<strong>image_position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, max_patches, 2)</code>, <em>optional</em>) — | |
| 2D patch position coordinates from the image processor, with <code>(-1, -1)</code> indicating padding. | |
| Passed through to the vision encoder for positional embedding computation.`,name:"image_position_ids"},{anchor:"transformers.DiffusionGemmaEncoderModel.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 <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</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 (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Pe=e(ye,4);h(Pe,{children:(r,d)=>{var a=u();c(r,a)},$$slots:{default:!0}}),i(2),t(Me),t(A);var Te=e(A,2);s(Te,{title:"DiffusionGemmaEncoderTextModel",local:"transformers.DiffusionGemmaEncoderTextModel",headingTag:"h2"});var I=e(Te,2),be=n(I);o(be,{name:"class transformers.DiffusionGemmaEncoderTextModel",anchor:"transformers.DiffusionGemmaEncoderTextModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L883",parameters:[{name:"config",val:": DiffusionGemmaTextConfig"}]});var we=e(be,2),ve=n(we);o(ve,{name:"forward",anchor:"transformers.DiffusionGemmaEncoderTextModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L911",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaEncoderTextModel.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.DiffusionGemmaEncoderTextModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>Union[torch.Tensor, dict]</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.DiffusionGemmaEncoderTextModel.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.DiffusionGemmaEncoderTextModel.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.DiffusionGemmaEncoderTextModel.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"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</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 (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Ye=e(ve,4);h(Ye,{children:(r,d)=>{var a=u();c(r,a)},$$slots:{default:!0}}),i(2),t(we),t(I);var je=e(I,2);s(je,{title:"DiffusionGemmaDecoderModel",local:"transformers.DiffusionGemmaDecoderModel",headingTag:"h2"});var x=e(je,2),Ue=n(x);o(Ue,{name:"class transformers.DiffusionGemmaDecoderModel",anchor:"transformers.DiffusionGemmaDecoderModel",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1182",parameters:[{name:"config",val:": DiffusionGemmaConfig"}]});var Ce=e(Ue,6),Ge=n(Ce);o(Ge,{name:"forward",anchor:"transformers.DiffusionGemmaDecoderModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1224",parameters:[{name:"decoder_input_ids",val:": LongTensor"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"self_conditioning_logits",val:": typing.Optional[torch.Tensor] = None"},{name:"self_conditioning_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"decoder_attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"decoder_position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.DiffusionGemmaDecoderModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>) — | |
| Token IDs for the canvas to be refined.`,name:"decoder_input_ids"},{anchor:"transformers.DiffusionGemmaDecoderModel.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.DiffusionGemmaDecoderModel.forward.self_conditioning_logits",description:`<strong>self_conditioning_logits</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, canvas_length, vocab_size)</code>, <em>optional</em>) — | |
| Self-conditioning logits from the previous denoising step, used to compute the | |
| self-conditioning embeddings.`,name:"self_conditioning_logits"},{anchor:"transformers.DiffusionGemmaDecoderModel.forward.self_conditioning_mask",description:`<strong>self_conditioning_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Per-example mask over <code>self_conditioning_logits</code>: examples set to <code>False</code> get a zeroed self-conditioning | |
| signal, as if no logits were passed for them. Useful for training, where self-conditioning is enabled per | |
| example with some probability.`,name:"self_conditioning_mask"},{anchor:"transformers.DiffusionGemmaDecoderModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length+canvas_length)</code> or <code>dict</code>, <em>optional</em>) — | |
| Attention mask for the decoder KV cache. Used to specify padded/unpopulated encoder KV cached entries.`,name:"decoder_attention_mask"},{anchor:"transformers.DiffusionGemmaDecoderModel.forward.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>, <em>optional</em>) — | |
| The position IDs for the tokens in the canvas.`,name:"decoder_position_ids"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput" | |
| >BaseModelOutput</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 (<code>None</code>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_51549/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput" | |
| >BaseModelOutput</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var Xe=e(Ge,4);h(Xe,{children:(r,d)=>{var a=u();c(r,a)},$$slots:{default:!0}}),i(2),t(Ce),t(x);var Je=e(x,2);s(Je,{title:"DiffusionGemmaForBlockDiffusion",local:"transformers.DiffusionGemmaForBlockDiffusion",headingTag:"h2"});var D=e(Je,2),ke=n(D);o(ke,{name:"class transformers.DiffusionGemmaForBlockDiffusion",anchor:"transformers.DiffusionGemmaForBlockDiffusion",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1586",parameters:[{name:"config",val:": DiffusionGemmaConfig"}]});var Ae=e(ke,4),Ie=n(Ae);o(Ie,{name:"forward",anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward",source:"https://github.com/huggingface/transformers/blob/vr_51549/src/transformers/models/diffusion_gemma/modeling_diffusion_gemma.py#L1608",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"cache",val:": transformers.cache_utils.Cache | None = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"self_conditioning_logits",val:": typing.Optional[torch.Tensor] = None"},{name:"self_conditioning_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"decoder_attention_mask",val:": typing.Union[torch.Tensor, dict, NoneType] = None"},{name:"decoder_position_ids",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.DiffusionGemmaForBlockDiffusion.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Uncached token IDs for the prompt to be encoded as context for the canvas.`,name:"input_ids"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>dict</code>, <em>optional</em>) — | |
| Mask for the input tokens.`,name:"attention_mask"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.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.DiffusionGemmaForBlockDiffusion.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.DiffusionGemmaForBlockDiffusion.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>, <em>optional</em>) — | |
| Token IDs for the canvas to be refined.`,name:"decoder_input_ids"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward.self_conditioning_logits",description:`<strong>self_conditioning_logits</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, canvas_length, vocab_size)</code>, <em>optional</em>) — | |
| Self-conditioning logits from the previous denoising step, used to compute the self-conditioning | |
| embeddings.`,name:"self_conditioning_logits"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward.self_conditioning_mask",description:`<strong>self_conditioning_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Per-example mask over <code>self_conditioning_logits</code>: examples set to <code>False</code> get a zeroed self-conditioning | |
| signal, as if no logits were passed for them. Useful for training, where self-conditioning is enabled per | |
| example with some probability.`,name:"self_conditioning_mask"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length+canvas_length)</code> or <code>dict</code>, <em>optional</em>) — | |
| Attention mask for the decoder KV cache. Used to specify padded/unpopulated encoder KV cached entries.`,name:"decoder_attention_mask"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.forward.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, canvas_length)</code>, <em>optional</em>) — | |
| The position IDs for the tokens in the canvas.`,name:"decoder_position_ids"},{anchor:"transformers.DiffusionGemmaForBlockDiffusion.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>DiffusionGemmaBlockDiffusionOutputWithPast</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>DiffusionGemmaBlockDiffusionOutputWithPast</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var He=e(Ie,4);h(He,{children:(r,d)=>{var a=u();c(r,a)},$$slots:{default:!0}}),i(2),t(Ae),t(D);var Oe=e(D,2);oo(Oe,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/diffusion_gemma.md"}),i(2),c(xe,S),ao()}export{yo as component}; | |
Xet Storage Details
- Size:
- 122 kB
- Xet hash:
- 9b81954921a904b22e0b1d1fba4ac22f76bc2af4f87f97cdecd169536e2c81e2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.