import{s as at,o as st,n as Re}from"../chunks/scheduler.25b97de1.js";import{S as it,i as dt,g as c,s as a,r as f,A as ct,h as l,f as o,c as s,j as K,u as h,x as M,k as ee,y as d,a as i,v as g,d as _,t as b,w as v}from"../chunks/index.d9030fc9.js";import{T as nt}from"../chunks/Tip.baa67368.js";import{D as le}from"../chunks/Docstring.ffac8efa.js";import{C as rt}from"../chunks/CodeBlock.e6cd0d95.js";import{E as ot}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as me,E as lt}from"../chunks/EditOnGithub.91d95064.js";function mt(C){let n,u;return n=new rt({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(){f(n.$$.fragment)},l(r){h(n.$$.fragment,r)},m(r,p){g(n,r,p),u=!0},p:Re,i(r){u||(_(n.$$.fragment,r),u=!0)},o(r){b(n.$$.fragment,r),u=!1},d(r){v(n,r)}}}function ut(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}),M(n)!=="svelte-fincs2"&&(n.innerHTML=u)},m(r,p){i(r,n,p)},p:Re,d(r){r&&o(n)}}}function pt(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}),M(n)!=="svelte-fincs2"&&(n.innerHTML=u)},m(r,p){i(r,n,p)},p:Re,d(r){r&&o(n)}}}function ft(C){let n,u="Example:",r,p,w;return p=new rt({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(),f(p.$$.fragment)},l(m){n=l(m,"P",{"data-svelte-h":!0}),M(n)!=="svelte-11lpom8"&&(n.textContent=u),r=s(m),h(p.$$.fragment,m)},m(m,R){i(m,n,R),i(m,r,R),g(p,m,R),w=!0},p:Re,i(m){w||(_(p.$$.fragment,m),w=!0)},o(m){b(p.$$.fragment,m),w=!1},d(m){m&&(o(n),o(r)),v(p,m)}}}function ht(C){let n,u,r,p,w,m,R,ue,H,Ie='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.',pe,E,qe="The abstract from the paper is the following:",fe,J,Ue="<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>",he,N,Ve="Tips:",ge,B,Oe='<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>',_e,I,Ae='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>.',be,q,ve,k,U,Ce,te,Se=`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.`,ze,ne,Xe='e.g. <a href="https://huggingface.co/google/recurrentgemma-2b" rel="nofollow">google/recurrentgemma-2b</a>',xe,oe,Ye=`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.`,Le,j,Me,V,ke,y,O,je,re,De=`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.)`,We,ae,Qe=`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.`,Ze,se,Ke="Transformer decoder consisting of <em>config.num_hidden_layers</em> layers. Each layer is a <code>RecurrentGemmaDecoderLayer</code>",Pe,z,A,Fe,ie,et='The <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaModel">RecurrentGemmaModel</a> forward method, overrides the <code>__call__</code> special method.',He,W,ye,S,Te,x,X,Ee,G,Y,Je,de,tt='The <a href="/docs/transformers/main/en/model_doc/recurrent_gemma#transformers.RecurrentGemmaForCausalLM">RecurrentGemmaForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',Ne,Z,Be,P,$e,D,we,ce,Ge;return w=new me({props:{title:"RecurrentGemma",local:"recurrentgemma",headingTag:"h1"}}),R=new me({props:{title:"Overview",local:"overview",headingTag:"h2"}}),q=new me({props:{title:"RecurrentGemmaConfig",local:"transformers.RecurrentGemmaConfig",headingTag:"h2"}}),U=new le({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 ot({props:{anchor:"transformers.RecurrentGemmaConfig.example",$$slots:{default:[mt]},$$scope:{ctx:C}}}),V=new me({props:{title:"RecurrentGemmaModel",local:"transformers.RecurrentGemmaModel",headingTag:"h2"}}),O=new le({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#L641"}}),A=new le({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"}],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#L679"}}),W=new nt({props:{$$slots:{default:[ut]},$$scope:{ctx:C}}}),S=new me({props:{title:"RecurrentGemmaForCausalLM",local:"transformers.RecurrentGemmaForCausalLM",headingTag:"h2"}}),X=new le({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#L779"}}),Y=new le({props:{name:"forward",anchor:"transformers.RecurrentGemmaForCausalLM.forward",parameters:[{name:"input_ids",val:": Optional = None"},{name:"position_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"}],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#L810",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 nt({props:{$$slots:{default:[pt]},$$scope:{ctx:C}}}),P=new ot({props:{anchor:"transformers.RecurrentGemmaForCausalLM.forward.example",$$slots:{default:[ft]},$$scope:{ctx:C}}}),D=new lt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/recurrent_gemma.md"}}),{c(){n=c("meta"),u=a(),r=c("p"),p=a(),f(w.$$.fragment),m=a(),f(R.$$.fragment),ue=a(),H=c("p"),H.innerHTML=Ie,pe=a(),E=c("p"),E.textContent=qe,fe=a(),J=c("p"),J.innerHTML=Ue,he=a(),N=c("p"),N.textContent=Ve,ge=a(),B=c("ul"),B.innerHTML=Oe,_e=a(),I=c("p"),I.innerHTML=Ae,be=a(),f(q.$$.fragment),ve=a(),k=c("div"),f(U.$$.fragment),Ce=a(),te=c("p"),te.innerHTML=Se,ze=a(),ne=c("p"),ne.innerHTML=Xe,xe=a(),oe=c("p"),oe.innerHTML=Ye,Le=a(),f(j.$$.fragment),Me=a(),f(V.$$.fragment),ke=a(),y=c("div"),f(O.$$.fragment),je=a(),re=c("p"),re.innerHTML=De,We=a(),ae=c("p"),ae.innerHTML=Qe,Ze=a(),se=c("p"),se.innerHTML=Ke,Pe=a(),z=c("div"),f(A.$$.fragment),Fe=a(),ie=c("p"),ie.innerHTML=et,He=a(),f(W.$$.fragment),ye=a(),f(S.$$.fragment),Te=a(),x=c("div"),f(X.$$.fragment),Ee=a(),G=c("div"),f(Y.$$.fragment),Je=a(),de=c("p"),de.innerHTML=tt,Ne=a(),f(Z.$$.fragment),Be=a(),f(P.$$.fragment),$e=a(),f(D.$$.fragment),we=a(),ce=c("p"),this.h()},l(e){const t=ct("svelte-u9bgzb",document.head);n=l(t,"META",{name:!0,content:!0}),t.forEach(o),u=s(e),r=l(e,"P",{}),K(r).forEach(o),p=s(e),h(w.$$.fragment,e),m=s(e),h(R.$$.fragment,e),ue=s(e),H=l(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-6oz2cq"&&(H.innerHTML=Ie),pe=s(e),E=l(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-vfdo9a"&&(E.textContent=qe),fe=s(e),J=l(e,"P",{"data-svelte-h":!0}),M(J)!=="svelte-1d1khq2"&&(J.innerHTML=Ue),he=s(e),N=l(e,"P",{"data-svelte-h":!0}),M(N)!=="svelte-axv494"&&(N.textContent=Ve),ge=s(e),B=l(e,"UL",{"data-svelte-h":!0}),M(B)!=="svelte-eiq2pr"&&(B.innerHTML=Oe),_e=s(e),I=l(e,"P",{"data-svelte-h":!0}),M(I)!=="svelte-17fjyye"&&(I.innerHTML=Ae),be=s(e),h(q.$$.fragment,e),ve=s(e),k=l(e,"DIV",{class:!0});var T=K(k);h(U.$$.fragment,T),Ce=s(T),te=l(T,"P",{"data-svelte-h":!0}),M(te)!=="svelte-1k05zil"&&(te.innerHTML=Se),ze=s(T),ne=l(T,"P",{"data-svelte-h":!0}),M(ne)!=="svelte-qt1jrx"&&(ne.innerHTML=Xe),xe=s(T),oe=l(T,"P",{"data-svelte-h":!0}),M(oe)!=="svelte-o55m63"&&(oe.innerHTML=Ye),Le=s(T),h(j.$$.fragment,T),T.forEach(o),Me=s(e),h(V.$$.fragment,e),ke=s(e),y=l(e,"DIV",{class:!0});var $=K(y);h(O.$$.fragment,$),je=s($),re=l($,"P",{"data-svelte-h":!0}),M(re)!=="svelte-194hf7h"&&(re.innerHTML=De),We=s($),ae=l($,"P",{"data-svelte-h":!0}),M(ae)!=="svelte-hswkmf"&&(ae.innerHTML=Qe),Ze=s($),se=l($,"P",{"data-svelte-h":!0}),M(se)!=="svelte-18fy42y"&&(se.innerHTML=Ke),Pe=s($),z=l($,"DIV",{class:!0});var L=K(z);h(A.$$.fragment,L),Fe=s(L),ie=l(L,"P",{"data-svelte-h":!0}),M(ie)!=="svelte-953scn"&&(ie.innerHTML=et),He=s(L),h(W.$$.fragment,L),L.forEach(o),$.forEach(o),ye=s(e),h(S.$$.fragment,e),Te=s(e),x=l(e,"DIV",{class:!0});var Q=K(x);h(X.$$.fragment,Q),Ee=s(Q),G=l(Q,"DIV",{class:!0});var F=K(G);h(Y.$$.fragment,F),Je=s(F),de=l(F,"P",{"data-svelte-h":!0}),M(de)!=="svelte-oem787"&&(de.innerHTML=tt),Ne=s(F),h(Z.$$.fragment,F),Be=s(F),h(P.$$.fragment,F),F.forEach(o),Q.forEach(o),$e=s(e),h(D.$$.fragment,e),we=s(e),ce=l(e,"P",{}),K(ce).forEach(o),this.h()},h(){ee(n,"name","hf:doc:metadata"),ee(n,"content",gt),ee(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(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),g(w,e,t),i(e,m,t),g(R,e,t),i(e,ue,t),i(e,H,t),i(e,pe,t),i(e,E,t),i(e,fe,t),i(e,J,t),i(e,he,t),i(e,N,t),i(e,ge,t),i(e,B,t),i(e,_e,t),i(e,I,t),i(e,be,t),g(q,e,t),i(e,ve,t),i(e,k,t),g(U,k,null),d(k,Ce),d(k,te),d(k,ze),d(k,ne),d(k,xe),d(k,oe),d(k,Le),g(j,k,null),i(e,Me,t),g(V,e,t),i(e,ke,t),i(e,y,t),g(O,y,null),d(y,je),d(y,re),d(y,We),d(y,ae),d(y,Ze),d(y,se),d(y,Pe),d(y,z),g(A,z,null),d(z,Fe),d(z,ie),d(z,He),g(W,z,null),i(e,ye,t),g(S,e,t),i(e,Te,t),i(e,x,t),g(X,x,null),d(x,Ee),d(x,G),g(Y,G,null),d(G,Je),d(G,de),d(G,Ne),g(Z,G,null),d(G,Be),g(P,G,null),i(e,$e,t),g(D,e,t),i(e,we,t),i(e,ce,t),Ge=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),j.$set(T);const $={};t&2&&($.$$scope={dirty:t,ctx:e}),W.$set($);const L={};t&2&&(L.$$scope={dirty:t,ctx:e}),Z.$set(L);const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),P.$set(Q)},i(e){Ge||(_(w.$$.fragment,e),_(R.$$.fragment,e),_(q.$$.fragment,e),_(U.$$.fragment,e),_(j.$$.fragment,e),_(V.$$.fragment,e),_(O.$$.fragment,e),_(A.$$.fragment,e),_(W.$$.fragment,e),_(S.$$.fragment,e),_(X.$$.fragment,e),_(Y.$$.fragment,e),_(Z.$$.fragment,e),_(P.$$.fragment,e),_(D.$$.fragment,e),Ge=!0)},o(e){b(w.$$.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),b(D.$$.fragment,e),Ge=!1},d(e){e&&(o(u),o(r),o(p),o(m),o(ue),o(H),o(pe),o(E),o(fe),o(J),o(he),o(N),o(ge),o(B),o(_e),o(I),o(be),o(ve),o(k),o(Me),o(ke),o(y),o(ye),o(Te),o(x),o($e),o(we),o(ce)),o(n),v(w,e),v(R,e),v(q,e),v(U),v(j),v(V,e),v(O),v(A),v(W),v(S,e),v(X),v(Y),v(Z),v(P),v(D,e)}}}const gt='{"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 _t(C){return st(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class wt extends it{constructor(n){super(),dt(this,n,_t,ht,at,{})}}export{wt as component};
