import{s as ot,o as rt,n as $e}from"../chunks/scheduler.9bc65507.js";import{S as at,i as st,g as c,s as a,r as h,A as it,h as l,f as o,c as s,j as Q,u as g,x as f,k as K,y as d,a as i,v as _,d as b,t as v,w as M}from"../chunks/index.707bf1b6.js";import{T as et}from"../chunks/Tip.c2ecdbf4.js";import{D as ce}from"../chunks/Docstring.17db21ae.js";import{C as nt}from"../chunks/CodeBlock.54a9f38d.js";import{E as tt}from"../chunks/ExampleCodeBlock.4f515aa9.js";import{H as le}from"../chunks/Heading.342b1fa6.js";function dt(C){let n,u;return n=new nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJlY3VycmVudEdlbW1hTW9kZWwlMkMlMjBSZWN1cnJlbnRHZW1tYUNvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBSZWN1cnJlbnRHZW1tYSUyMHJlY3VycmVudGdlbW1hLTJiJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFJlY3VycmVudEdlbW1hQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwcmVjdXJyZW50Z2VtbWEtMmIlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFJlY3VycmVudEdlbW1hTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RecurrentGemmaModel, RecurrentGemmaConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a RecurrentGemma recurrentgemma-2b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = RecurrentGemmaConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the recurrentgemma-2b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RecurrentGemmaModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){h(n.$$.fragment)},l(r){g(n.$$.fragment,r)},m(r,p){_(n,r,p),u=!0},p:$e,i(r){u||(b(n.$$.fragment,r),u=!0)},o(r){v(n.$$.fragment,r),u=!1},d(r){M(n,r)}}}function ct(C){let n,u=`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.`;return{c(){n=c("p"),n.innerHTML=u},l(r){n=l(r,"P",{"data-svelte-h":!0}),f(n)!=="svelte-fincs2"&&(n.innerHTML=u)},m(r,p){i(r,n,p)},p:$e,d(r){r&&o(n)}}}function lt(C){let n,u=`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.`;return{c(){n=c("p"),n.innerHTML=u},l(r){n=l(r,"P",{"data-svelte-h":!0}),f(n)!=="svelte-fincs2"&&(n.innerHTML=u)},m(r,p){i(r,n,p)},p:$e,d(r){r&&o(n)}}}function mt(C){let n,u="Example:",r,p,$;return p=new nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSZWN1cnJlbnRHZW1tYUZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBSZWN1cnJlbnRHZW1tYUZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZyZWN1cnJlbnRnZW1tYS0yYiUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZyZWN1cnJlbnRnZW1tYS0yYiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJXaGF0JTIwaXMlMjB5b3VyJTIwZmF2b3JpdGUlMjBjb25kaW1lbnQlM0YlMjIlMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cy5pbnB1dF9pZHMlMkMlMjBtYXhfbGVuZ3RoJTNEMzApJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZV9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSklNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RecurrentGemmaForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = RecurrentGemmaForCausalLM.from_pretrained(<span class="hljs-string">&quot;google/recurrentgemma-2b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/recurrentgemma-2b&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;What is your favorite condiment?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(inputs.input_ids, max_length=<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>]
<span class="hljs-string">&quot;What is your favorite condiment?&quot;</span>`,wrap:!1}}),{c(){n=c("p"),n.textContent=u,r=a(),h(p.$$.fragment)},l(m){n=l(m,"P",{"data-svelte-h":!0}),f(n)!=="svelte-11lpom8"&&(n.textContent=u),r=s(m),g(p.$$.fragment,m)},m(m,R){i(m,n,R),i(m,r,R),_(p,m,R),$=!0},p:$e,i(m){$||(b(p.$$.fragment,m),$=!0)},o(m){v(p.$$.fragment,m),$=!1},d(m){m&&(o(n),o(r)),M(p,m)}}}function ut(C){let n,u,r,p,$,m,R,me,H,Be='The Recurrent Gemma model was proposed in <a href="https://storage.googleapis.com/deepmind-media/gemma/recurrentgemma-report.pdf" rel="nofollow">RecurrentGemma: Moving Past Transformers for Efficient Open Language Models</a> by the Griffin, RLHF and Gemma Teams of Google.',ue,J,Ne="The abstract from the paper is the following:",pe,E,Ie="<em>We introduce RecurrentGemma, an open language model which uses Google’s novel Griffin architecture. Griffin combines linear recurrences with local attention to achieve excellent performance on language. It has a fixed-sized state, which reduces memory use and enables efficient inference on long sequences. We provide a pre-trained model with 2B non-embedding parameters, and an instruction tuned variant. Both models achieve comparable performance to Gemma-2B despite being trained on fewer tokens.</em>",fe,B,qe="Tips:",he,N,Ue='<li>The original checkpoints can be converted using the conversion script <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/convert_recurrent_gemma_to_hf.py" rel="nofollow"><code>src/transformers/models/recurrent_gemma/convert_recurrent_gemma_weights_to_hf.py</code></a>.</li>',ge,I,Ve='This model was contributed by <a href="https://huggingface.co/ArthurZ" rel="nofollow">Arthur Zucker</a>. The original code can be found <a href="https://github.com/google-deepmind/recurrentgemma" rel="nofollow">here</a>.',_e,q,be,k,U,Ge,ee,Oe=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaModel">RecurrentGemmaModel</a>. It is used to instantiate a RecurrentGemma
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 RecurrentGemma-7B.`,Re,te,Ae='e.g. <a href="https://huggingface.co/google/recurrentgemma-2b" rel="nofollow">google/recurrentgemma-2b</a>',Ce,ne,Se=`Configuration objects inherit from <a href="/docs/transformers/main/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/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,ze,j,ve,V,Me,y,O,xe,oe,Xe=`The bare RecurrentGemma Model outputting raw hidden-states without any specific head on top.
This model inherits from <a href="/docs/transformers/main/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.)`,Le,re,Ye=`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.`,je,ae,De="Transformer decoder consisting of <em>config.num_hidden_layers</em> layers. Each layer is a <code>RecurrentGemmaDecoderLayer</code>",We,z,A,Ze,se,Qe='The <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaModel">RecurrentGemmaModel</a> forward method, overrides the <code>__call__</code> special method.',Pe,W,ke,S,ye,x,X,Fe,G,Y,He,ie,Ke='The <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaForCausalLM">RecurrentGemmaForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',Je,Z,Ee,P,Te,de,we;return $=new le({props:{title:"RecurrentGemma",local:"recurrentgemma",headingTag:"h1"}}),R=new le({props:{title:"Overview",local:"overview",headingTag:"h2"}}),q=new le({props:{title:"RecurrentGemmaConfig",local:"transformers.RecurrentGemmaConfig",headingTag:"h2"}}),U=new ce({props:{name:"class transformers.RecurrentGemmaConfig",anchor:"transformers.RecurrentGemmaConfig",parameters:[{name:"num_hidden_layers",val:" = 26"},{name:"vocab_size",val:" = 256000"},{name:"hidden_size",val:" = 2560"},{name:"intermediate_size",val:" = 7680"},{name:"num_attention_heads",val:" = 10"},{name:"lru_width",val:" = None"},{name:"attention_window_size",val:" = 2048"},{name:"conv1d_width",val:" = 4"},{name:"logits_soft_cap",val:" = 30.0"},{name:"rms_norm_eps",val:" = 1e-06"},{name:"use_cache",val:" = True"},{name:"pad_token_id",val:" = 0"},{name:"eos_token_id",val:" = 1"},{name:"bos_token_id",val:" = 2"},{name:"hidden_activation",val:" = 'gelu_pytorch_tanh'"},{name:"partial_rotary_factor",val:" = 0.5"},{name:"rope_theta",val:" = 10000.0"},{name:"block_types",val:" = ('recurrent', 'recurrent', 'attention')"},{name:"attention_dropout",val:" = 0.0"},{name:"num_key_value_heads",val:" = None"},{name:"attention_bias",val:" = False"},{name:"w_init_variance_scale",val:" = 0.01"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RecurrentGemmaConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 26) &#x2014;
The number of hidden layers in the model.`,name:"num_hidden_layers"},{anchor:"transformers.RecurrentGemmaConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256000) &#x2014;
Vocabulary size of the RecurrentGemma model. Defines the number of
different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaModel">RecurrentGemmaModel</a>`,name:"vocab_size"},{anchor:"transformers.RecurrentGemmaConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2560) &#x2014;
Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.RecurrentGemmaConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 7680) &#x2014;
Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.RecurrentGemmaConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
The number of heads for the attention block and the number of
heads/blocks for the block-diagonal layers used in the RG-LRU gates.
This number must divide <code>hidden_size</code> and <code>lru_width</code>.`,name:"num_attention_heads"},{anchor:"transformers.RecurrentGemmaConfig.lru_width",description:`<strong>lru_width</strong> (<code>int</code> or <code>None</code>, <em>optional</em>) &#x2014;
Dimension of the hidden representations of the RG-LRU. If <code>None</code>
this will be set to <code>hidden_size</code>.
Whether to scale the output of the embeddings by <code>sqrt(hidden_size)</code>.`,name:"lru_width"},{anchor:"transformers.RecurrentGemmaConfig.attention_window_size",description:`<strong>attention_window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The size of the attention window used in the attention block.`,name:"attention_window_size"},{anchor:"transformers.RecurrentGemmaConfig.conv1d_width",description:`<strong>conv1d_width</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The kernel size of conv1d layers used in the recurrent blocks.`,name:"conv1d_width"},{anchor:"transformers.RecurrentGemmaConfig.logits_soft_cap",description:`<strong>logits_soft_cap</strong> (<code>float</code>, <em>optional</em>, defaults to 30.0) &#x2014;
The value at which the logits should be soft-capped to after the transformer and LM-head computation in the Causal LM architecture.`,name:"logits_soft_cap"},{anchor:"transformers.RecurrentGemmaConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-06) &#x2014;
The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.RecurrentGemmaConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the model should return the last key/values
attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.RecurrentGemmaConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Padding token id.`,name:"pad_token_id"},{anchor:"transformers.RecurrentGemmaConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
End of stream token id.`,name:"eos_token_id"},{anchor:"transformers.RecurrentGemmaConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Beginning of stream token id.`,name:"bos_token_id"},{anchor:"transformers.RecurrentGemmaConfig.hidden_activation",description:"<strong>hidden_activation</strong> (<code>str` or `function</code>, <em>optional</em>, defaults to <code>&quot;gelu_pytorch_tanh&quot;</code>) &#x2014;\nThe hidden activation used in the recurrent block as well as the MLP layer of the decoder layers.",name:"hidden_activation"},{anchor:"transformers.RecurrentGemmaConfig.partial_rotary_factor",description:`<strong>partial_rotary_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.5) &#x2014;
The partial rotary factor used in the initialization of the rotary embeddings.`,name:"partial_rotary_factor"},{anchor:"transformers.RecurrentGemmaConfig.rope_theta",description:`<strong>rope_theta</strong> (<code>float</code>, <em>optional</em>, defaults to 10000.0) &#x2014;
The base period of the RoPE embeddings.`,name:"rope_theta"},{anchor:"transformers.RecurrentGemmaConfig.block_types",description:`<strong>block_types</strong> (<code>List[str]</code>, <em>optional</em>, defaults to <code>(&apos;recurrent&apos;, &apos;recurrent&apos;, &apos;attention&apos;)</code>) &#x2014;
List of aleternating blocks that will be repeated to initialize the <code>temporal_block</code> layer.`,name:"block_types"},{anchor:"transformers.RecurrentGemmaConfig.attention_dropout",description:"<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014; dropout value to use after the attention softmax.",name:"attention_dropout"},{anchor:"transformers.RecurrentGemmaConfig.num_key_value_heads",description:"<strong>num_key_value_heads</strong> (<code>16</code>, <em>optional</em>, defaults to 16) &#x2014; Number of key value heads to use GQA.",name:"num_key_value_heads"},{anchor:"transformers.RecurrentGemmaConfig.attention_bias",description:"<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014; whether or not the linear q,k,v of the Attention layer should have bias",name:"attention_bias"},{anchor:"transformers.RecurrentGemmaConfig.w_init_variance_scale",description:"<strong>w_init_variance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.01) &#x2014; weight initialization variance.",name:"w_init_variance_scale"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/configuration_recurrent_gemma.py#L24"}}),j=new tt({props:{anchor:"transformers.RecurrentGemmaConfig.example",$$slots:{default:[dt]},$$scope:{ctx:C}}}),V=new le({props:{title:"RecurrentGemmaModel",local:"transformers.RecurrentGemmaModel",headingTag:"h2"}}),O=new ce({props:{name:"class transformers.RecurrentGemmaModel",anchor:"transformers.RecurrentGemmaModel",parameters:[{name:"config",val:": RecurrentGemmaConfig"}],parametersDescription:[{anchor:"transformers.RecurrentGemmaModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaConfig">RecurrentGemmaConfig</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.
config &#x2014; RecurrentGemmaConfig`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/modeling_recurrent_gemma.py#L639"}}),A=new ce({props:{name:"forward",anchor:"transformers.RecurrentGemmaModel.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"position_ids",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"cache_position",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RecurrentGemmaModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.RecurrentGemmaModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.`,name:"attention_mask"},{anchor:"transformers.RecurrentGemmaModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.RecurrentGemmaModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.RecurrentGemmaModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.RecurrentGemmaModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all  See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.RecurrentGemmaModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.RecurrentGemmaModel.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) &#x2014;
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to <code>position_ids</code>,
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
the complete sequence length.`,name:"cache_position"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/modeling_recurrent_gemma.py#L677"}}),W=new et({props:{$$slots:{default:[ct]},$$scope:{ctx:C}}}),S=new le({props:{title:"RecurrentGemmaForCausalLM",local:"transformers.RecurrentGemmaForCausalLM",headingTag:"h2"}}),X=new ce({props:{name:"class transformers.RecurrentGemmaForCausalLM",anchor:"transformers.RecurrentGemmaForCausalLM",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/modeling_recurrent_gemma.py#L784"}}),Y=new ce({props:{name:"forward",anchor:"transformers.RecurrentGemmaForCausalLM.forward",parameters:[{name:"input_ids",val:": Optional = None"},{name:"cache_position",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RecurrentGemmaForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.`,name:"attention_mask"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all  See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.RecurrentGemmaForCausalLM.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) &#x2014;
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to <code>position_ids</code>,
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
the complete sequence length.</p>
<p>Args &#x2014;
labels (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>):
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"cache_position"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/recurrent_gemma/modeling_recurrent_gemma.py#L815",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutput"
>transformers.modeling_outputs.CausalLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaConfig"
>RecurrentGemmaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutput"
>transformers.modeling_outputs.CausalLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Z=new et({props:{$$slots:{default:[lt]},$$scope:{ctx:C}}}),P=new tt({props:{anchor:"transformers.RecurrentGemmaForCausalLM.forward.example",$$slots:{default:[mt]},$$scope:{ctx:C}}}),{c(){n=c("meta"),u=a(),r=c("p"),p=a(),h($.$$.fragment),m=a(),h(R.$$.fragment),me=a(),H=c("p"),H.innerHTML=Be,ue=a(),J=c("p"),J.textContent=Ne,pe=a(),E=c("p"),E.innerHTML=Ie,fe=a(),B=c("p"),B.textContent=qe,he=a(),N=c("ul"),N.innerHTML=Ue,ge=a(),I=c("p"),I.innerHTML=Ve,_e=a(),h(q.$$.fragment),be=a(),k=c("div"),h(U.$$.fragment),Ge=a(),ee=c("p"),ee.innerHTML=Oe,Re=a(),te=c("p"),te.innerHTML=Ae,Ce=a(),ne=c("p"),ne.innerHTML=Se,ze=a(),h(j.$$.fragment),ve=a(),h(V.$$.fragment),Me=a(),y=c("div"),h(O.$$.fragment),xe=a(),oe=c("p"),oe.innerHTML=Xe,Le=a(),re=c("p"),re.innerHTML=Ye,je=a(),ae=c("p"),ae.innerHTML=De,We=a(),z=c("div"),h(A.$$.fragment),Ze=a(),se=c("p"),se.innerHTML=Qe,Pe=a(),h(W.$$.fragment),ke=a(),h(S.$$.fragment),ye=a(),x=c("div"),h(X.$$.fragment),Fe=a(),G=c("div"),h(Y.$$.fragment),He=a(),ie=c("p"),ie.innerHTML=Ke,Je=a(),h(Z.$$.fragment),Ee=a(),h(P.$$.fragment),Te=a(),de=c("p"),this.h()},l(e){const t=it("svelte-u9bgzb",document.head);n=l(t,"META",{name:!0,content:!0}),t.forEach(o),u=s(e),r=l(e,"P",{}),Q(r).forEach(o),p=s(e),g($.$$.fragment,e),m=s(e),g(R.$$.fragment,e),me=s(e),H=l(e,"P",{"data-svelte-h":!0}),f(H)!=="svelte-6oz2cq"&&(H.innerHTML=Be),ue=s(e),J=l(e,"P",{"data-svelte-h":!0}),f(J)!=="svelte-vfdo9a"&&(J.textContent=Ne),pe=s(e),E=l(e,"P",{"data-svelte-h":!0}),f(E)!=="svelte-1d1khq2"&&(E.innerHTML=Ie),fe=s(e),B=l(e,"P",{"data-svelte-h":!0}),f(B)!=="svelte-axv494"&&(B.textContent=qe),he=s(e),N=l(e,"UL",{"data-svelte-h":!0}),f(N)!=="svelte-eiq2pr"&&(N.innerHTML=Ue),ge=s(e),I=l(e,"P",{"data-svelte-h":!0}),f(I)!=="svelte-17fjyye"&&(I.innerHTML=Ve),_e=s(e),g(q.$$.fragment,e),be=s(e),k=l(e,"DIV",{class:!0});var T=Q(k);g(U.$$.fragment,T),Ge=s(T),ee=l(T,"P",{"data-svelte-h":!0}),f(ee)!=="svelte-1k05zil"&&(ee.innerHTML=Oe),Re=s(T),te=l(T,"P",{"data-svelte-h":!0}),f(te)!=="svelte-qt1jrx"&&(te.innerHTML=Ae),Ce=s(T),ne=l(T,"P",{"data-svelte-h":!0}),f(ne)!=="svelte-o55m63"&&(ne.innerHTML=Se),ze=s(T),g(j.$$.fragment,T),T.forEach(o),ve=s(e),g(V.$$.fragment,e),Me=s(e),y=l(e,"DIV",{class:!0});var w=Q(y);g(O.$$.fragment,w),xe=s(w),oe=l(w,"P",{"data-svelte-h":!0}),f(oe)!=="svelte-194hf7h"&&(oe.innerHTML=Xe),Le=s(w),re=l(w,"P",{"data-svelte-h":!0}),f(re)!=="svelte-hswkmf"&&(re.innerHTML=Ye),je=s(w),ae=l(w,"P",{"data-svelte-h":!0}),f(ae)!=="svelte-18fy42y"&&(ae.innerHTML=De),We=s(w),z=l(w,"DIV",{class:!0});var L=Q(z);g(A.$$.fragment,L),Ze=s(L),se=l(L,"P",{"data-svelte-h":!0}),f(se)!=="svelte-953scn"&&(se.innerHTML=Qe),Pe=s(L),g(W.$$.fragment,L),L.forEach(o),w.forEach(o),ke=s(e),g(S.$$.fragment,e),ye=s(e),x=l(e,"DIV",{class:!0});var D=Q(x);g(X.$$.fragment,D),Fe=s(D),G=l(D,"DIV",{class:!0});var F=Q(G);g(Y.$$.fragment,F),He=s(F),ie=l(F,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-oem787"&&(ie.innerHTML=Ke),Je=s(F),g(Z.$$.fragment,F),Ee=s(F),g(P.$$.fragment,F),F.forEach(o),D.forEach(o),Te=s(e),de=l(e,"P",{}),Q(de).forEach(o),this.h()},h(){K(n,"name","hf:doc:metadata"),K(n,"content",pt),K(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){d(document.head,n),i(e,u,t),i(e,r,t),i(e,p,t),_($,e,t),i(e,m,t),_(R,e,t),i(e,me,t),i(e,H,t),i(e,ue,t),i(e,J,t),i(e,pe,t),i(e,E,t),i(e,fe,t),i(e,B,t),i(e,he,t),i(e,N,t),i(e,ge,t),i(e,I,t),i(e,_e,t),_(q,e,t),i(e,be,t),i(e,k,t),_(U,k,null),d(k,Ge),d(k,ee),d(k,Re),d(k,te),d(k,Ce),d(k,ne),d(k,ze),_(j,k,null),i(e,ve,t),_(V,e,t),i(e,Me,t),i(e,y,t),_(O,y,null),d(y,xe),d(y,oe),d(y,Le),d(y,re),d(y,je),d(y,ae),d(y,We),d(y,z),_(A,z,null),d(z,Ze),d(z,se),d(z,Pe),_(W,z,null),i(e,ke,t),_(S,e,t),i(e,ye,t),i(e,x,t),_(X,x,null),d(x,Fe),d(x,G),_(Y,G,null),d(G,He),d(G,ie),d(G,Je),_(Z,G,null),d(G,Ee),_(P,G,null),i(e,Te,t),i(e,de,t),we=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),j.$set(T);const w={};t&2&&(w.$$scope={dirty:t,ctx:e}),W.$set(w);const L={};t&2&&(L.$$scope={dirty:t,ctx:e}),Z.$set(L);const D={};t&2&&(D.$$scope={dirty:t,ctx:e}),P.$set(D)},i(e){we||(b($.$$.fragment,e),b(R.$$.fragment,e),b(q.$$.fragment,e),b(U.$$.fragment,e),b(j.$$.fragment,e),b(V.$$.fragment,e),b(O.$$.fragment,e),b(A.$$.fragment,e),b(W.$$.fragment,e),b(S.$$.fragment,e),b(X.$$.fragment,e),b(Y.$$.fragment,e),b(Z.$$.fragment,e),b(P.$$.fragment,e),we=!0)},o(e){v($.$$.fragment,e),v(R.$$.fragment,e),v(q.$$.fragment,e),v(U.$$.fragment,e),v(j.$$.fragment,e),v(V.$$.fragment,e),v(O.$$.fragment,e),v(A.$$.fragment,e),v(W.$$.fragment,e),v(S.$$.fragment,e),v(X.$$.fragment,e),v(Y.$$.fragment,e),v(Z.$$.fragment,e),v(P.$$.fragment,e),we=!1},d(e){e&&(o(u),o(r),o(p),o(m),o(me),o(H),o(ue),o(J),o(pe),o(E),o(fe),o(B),o(he),o(N),o(ge),o(I),o(_e),o(be),o(k),o(ve),o(Me),o(y),o(ke),o(ye),o(x),o(Te),o(de)),o(n),M($,e),M(R,e),M(q,e),M(U),M(j),M(V,e),M(O),M(A),M(W),M(S,e),M(X),M(Y),M(Z),M(P)}}}const pt='{"title":"RecurrentGemma","local":"recurrentgemma","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"RecurrentGemmaConfig","local":"transformers.RecurrentGemmaConfig","sections":[],"depth":2},{"title":"RecurrentGemmaModel","local":"transformers.RecurrentGemmaModel","sections":[],"depth":2},{"title":"RecurrentGemmaForCausalLM","local":"transformers.RecurrentGemmaForCausalLM","sections":[],"depth":2}],"depth":1}';function ft(C){return rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yt extends at{constructor(n){super(),st(this,n,ft,ut,ot,{})}}export{yt as component};
