import{s as at,o as st,n as Ce}from"../chunks/scheduler.25b97de1.js";import{S as rt,i as it,g as l,s as r,r as h,A as lt,h as d,f as o,c as i,j as ee,u as f,x as y,k as te,y as c,a,v as g,d as _,t as M,w as b}from"../chunks/index.d9030fc9.js";import{T as ot}from"../chunks/Tip.baa67368.js";import{D as ce}from"../chunks/Docstring.ffac8efa.js";import{C as Ne}from"../chunks/CodeBlock.e6cd0d95.js";import{E as nt}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as me,E as dt}from"../chunks/EditOnGithub.91d95064.js";function ct(C){let n,p;return n=new Ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdyYW5pdGVNb2VNb2RlbCUyQyUyMEdyYW5pdGVNb2VDb25maWclMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwR3Jhbml0ZU1vZSUyMGdyYW5pdGVtb2UtM2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwR3Jhbml0ZU1vZUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwZnJvbSUyMHRoZSUyMGdyYW5pdGVtb2UtN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMEdyYW5pdGVNb2VNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GraniteMoeModel, GraniteMoeConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a GraniteMoe granitemoe-3b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = GraniteMoeConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the granitemoe-7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GraniteMoeModel(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(s){f(n.$$.fragment,s)},m(s,u){g(n,s,u),p=!0},p:Ce,i(s){p||(_(n.$$.fragment,s),p=!0)},o(s){M(n.$$.fragment,s),p=!1},d(s){b(n,s)}}}function mt(C){let n,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.`;return{c(){n=l("p"),n.innerHTML=p},l(s){n=d(s,"P",{"data-svelte-h":!0}),y(n)!=="svelte-fincs2"&&(n.innerHTML=p)},m(s,u){a(s,n,u)},p:Ce,d(s){s&&o(n)}}}function pt(C){let n,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.`;return{c(){n=l("p"),n.innerHTML=p},l(s){n=d(s,"P",{"data-svelte-h":!0}),y(n)!=="svelte-fincs2"&&(n.innerHTML=p)},m(s,u){a(s,n,u)},p:Ce,d(s){s&&o(n)}}}function ut(C){let n,p="Example:",s,u,k;return u=new Ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHcmFuaXRlTW9lRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMEdyYW5pdGVNb2VGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyaWJtJTJGUG93ZXJNb0UtM2IlMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyaWJtJTJGUG93ZXJNb0UtM2IlMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIySGV5JTJDJTIwYXJlJTIweW91JTIwY29uc2Npb3VzJTNGJTIwQ2FuJTIweW91JTIwdGFsayUyMHRvJTIwbWUlM0YlMjIlMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cy5pbnB1dF9pZHMlMkMlMjBtYXhfbGVuZ3RoJTNEMzApJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZV9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSklNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GraniteMoeForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = GraniteMoeForCausalLM.from_pretrained(<span class="hljs-string">&quot;ibm/PowerMoE-3b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;ibm/PowerMoE-3b&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Hey, are you conscious? Can you talk to me?&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;Hey, are you conscious? Can you talk to me?\\nI&#x27;m not conscious, but I can talk to you.&quot;</span>`,wrap:!1}}),{c(){n=l("p"),n.textContent=p,s=r(),h(u.$$.fragment)},l(m){n=d(m,"P",{"data-svelte-h":!0}),y(n)!=="svelte-11lpom8"&&(n.textContent=p),s=i(m),f(u.$$.fragment,m)},m(m,$){a(m,n,$),a(m,s,$),g(u,m,$),k=!0},p:Ce,i(m){k||(_(u.$$.fragment,m),k=!0)},o(m){M(u.$$.fragment,m),k=!1},d(m){m&&(o(n),o(s)),b(u,m)}}}function ht(C){let n,p,s,u,k,m,$,pe,L,Xe='The GraniteMoe model was proposed in <a href="https://arxiv.org/abs/2408.13359" rel="nofollow">Power Scheduler: A Batch Size and Token Number Agnostic Learning Rate Scheduler</a> by Yikang Shen, Matthew Stallone, Mayank Mishra, Gaoyuan Zhang, Shawn Tan, Aditya Prasad, Adriana Meza Soria, David D. Cox and Rameswar Panda.',ue,Z,Re="PowerMoE-3B is a 3B sparse Mixture-of-Experts (sMoE) language model trained with the Power learning rate scheduler. It sparsely activates 800M parameters for each token. It is trained on a mix of open-source and proprietary datasets. PowerMoE-3B has shown promising results compared to other dense models with 2x activate parameters across various benchmarks, including natural language multi-choices, code generation, and math reasoning.",he,V,Se="The abstract from the paper is the following:",fe,P,qe=`<em>Finding the optimal learning rate for language model pretraining is a challenging task.
This is not only because there is a complicated correlation between learning rate, batch size, number of training tokens, model size, and other hyperparameters but also because it is prohibitively expensive to perform a hyperparameter search for large language models with Billions or Trillions of parameters. Recent studies propose using small proxy models and small corpus to perform hyperparameter searches and transposing the optimal parameters to large models and large corpus. While the zero-shot transferability is theoretically and empirically proven for model size related hyperparameters, like depth and width, the zero-shot transfer from small corpus to large corpus is underexplored.
In this paper, we study the correlation between optimal learning rate, batch size, and number of training tokens for the recently proposed WSD scheduler. After thousands of small experiments, we found a power-law relationship between variables and demonstrated its transferability across model sizes. Based on the observation, we propose a new learning rate scheduler, Power scheduler, that is agnostic about the number of training tokens and batch size. The experiment shows that combining the Power scheduler with Maximum Update Parameterization (\\mup) can consistently achieve impressive performance with one set of hyperparameters regardless of the number of training tokens, batch size, model size, and even model architecture. Our 3B dense and MoE models trained with the Power scheduler achieve comparable performance as state-of-the-art small language models.
We <a href="https://huggingface.co/collections/ibm/power-lm-66be64ae647ddf11b9808000" rel="nofollow">open source</a> these pretrained models.</em>`,ge,E,He="Tips:",_e,N,Me,X,Qe='This model was contributed by <a href="https://huggingface.co/mayank-mishra" rel="nofollow">mayank-mishra</a>.',be,R,ye,T,S,ze,oe,Ye=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/granitemoe#transformers.GraniteMoeModel">GraniteMoeModel</a>. It is used to instantiate an GraniteMoe
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 GraniteMoe-3B.`,Ue,ne,Ae=`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.`,Je,I,ve,q,Te,v,H,Ie,ae,De=`The bare GraniteMoe 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.)`,je,se,Oe=`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.`,We,re,Ke="Transformer decoder consisting of <em>config.num_hidden_layers</em> layers. Each layer is a <code>GraniteMoeDecoderLayer</code>",Be,z,Q,Fe,ie,et='The <a href="/docs/transformers/main/en/model_doc/granitemoe#transformers.GraniteMoeModel">GraniteMoeModel</a> forward method, overrides the <code>__call__</code> special method.',Le,j,we,Y,ke,U,A,Ze,G,D,Ve,le,tt='The <a href="/docs/transformers/main/en/model_doc/granitemoe#transformers.GraniteMoeForCausalLM">GraniteMoeForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',Pe,W,Ee,B,Ge,O,$e,de,xe;return k=new me({props:{title:"GraniteMoe",local:"granitemoe",headingTag:"h1"}}),$=new me({props:{title:"Overview",local:"overview",headingTag:"h2"}}),N=new Ne({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTBBJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMmlibSUyRlBvd2VyTW9FLTNiJTIyJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQobW9kZWxfcGF0aCklMEElMEElMjMlMjBkcm9wJTIwZGV2aWNlX21hcCUyMGlmJTIwcnVubmluZyUyMG9uJTIwQ1BVJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfcGF0aCUyQyUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyKSUwQW1vZGVsLmV2YWwoKSUwQSUwQSUyMyUyMGNoYW5nZSUyMGlucHV0JTIwdGV4dCUyMGFzJTIwZGVzaXJlZCUwQXByb21wdCUyMCUzRCUyMCUyMldyaXRlJTIwYSUyMGNvZGUlMjB0byUyMGZpbmQlMjB0aGUlMjBtYXhpbXVtJTIwdmFsdWUlMjBpbiUyMGElMjBsaXN0JTIwb2YlMjBudW1iZXJzLiUyMiUwQSUwQSUyMyUyMHRva2VuaXplJTIwdGhlJTIwdGV4dCUwQWlucHV0X3Rva2VucyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUyMyUyMGdlbmVyYXRlJTIwb3V0cHV0JTIwdG9rZW5zJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dF90b2tlbnMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDEwMCklMEElMjMlMjBkZWNvZGUlMjBvdXRwdXQlMjB0b2tlbnMlMjBpbnRvJTIwdGV4dCUwQW91dHB1dCUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0KSUwQSUyMyUyMGxvb3AlMjBvdmVyJTIwdGhlJTIwYmF0Y2glMjB0byUyMHByaW50JTJDJTIwaW4lMjB0aGlzJTIwZXhhbXBsZSUyMHRoZSUyMGJhdGNoJTIwc2l6ZSUyMGlzJTIwMSUwQWZvciUyMGklMjBpbiUyMG91dHB1dCUzQSUwQSUyMCUyMCUyMCUyMHByaW50KGkp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model_path = <span class="hljs-string">&quot;ibm/PowerMoE-3b&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_path)

<span class="hljs-comment"># drop device_map if running on CPU</span>
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
model.<span class="hljs-built_in">eval</span>()

<span class="hljs-comment"># change input text as desired</span>
prompt = <span class="hljs-string">&quot;Write a code to find the maximum value in a list of numbers.&quot;</span>

<span class="hljs-comment"># tokenize the text</span>
input_tokens = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-comment"># generate output tokens</span>
output = model.generate(**input_tokens, max_new_tokens=<span class="hljs-number">100</span>)
<span class="hljs-comment"># decode output tokens into text</span>
output = tokenizer.batch_decode(output)
<span class="hljs-comment"># loop over the batch to print, in this example the batch size is 1</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> output:
    <span class="hljs-built_in">print</span>(i)`,wrap:!1}}),R=new me({props:{title:"GraniteMoeConfig",local:"transformers.GraniteMoeConfig",headingTag:"h2"}}),S=new ce({props:{name:"class transformers.GraniteMoeConfig",anchor:"transformers.GraniteMoeConfig",parameters:[{name:"vocab_size",val:" = 32000"},{name:"hidden_size",val:" = 4096"},{name:"intermediate_size",val:" = 11008"},{name:"num_hidden_layers",val:" = 32"},{name:"num_attention_heads",val:" = 32"},{name:"num_key_value_heads",val:" = None"},{name:"hidden_act",val:" = 'silu'"},{name:"max_position_embeddings",val:" = 2048"},{name:"initializer_range",val:" = 0.02"},{name:"rms_norm_eps",val:" = 1e-06"},{name:"use_cache",val:" = True"},{name:"pad_token_id",val:" = None"},{name:"bos_token_id",val:" = 1"},{name:"eos_token_id",val:" = 2"},{name:"tie_word_embeddings",val:" = False"},{name:"rope_theta",val:" = 10000.0"},{name:"rope_scaling",val:" = None"},{name:"attention_bias",val:" = False"},{name:"attention_dropout",val:" = 0.0"},{name:"embedding_multiplier",val:" = 1.0"},{name:"logits_scaling",val:" = 1.0"},{name:"residual_multiplier",val:" = 1.0"},{name:"attention_multiplier",val:" = 1.0"},{name:"num_local_experts",val:" = 8"},{name:"num_experts_per_tok",val:" = 2"},{name:"output_router_logits",val:" = False"},{name:"router_aux_loss_coef",val:" = 0.001"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GraniteMoeConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32000) &#x2014;
Vocabulary size of the GraniteMoe 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/granitemoe#transformers.GraniteMoeModel">GraniteMoeModel</a>`,name:"vocab_size"},{anchor:"transformers.GraniteMoeConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.GraniteMoeConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 11008) &#x2014;
Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.GraniteMoeConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.GraniteMoeConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.GraniteMoeConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>) &#x2014;
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 checkout <a href="https://arxiv.org/pdf/2305.13245.pdf" 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.GraniteMoeConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the decoder.`,name:"hidden_act"},{anchor:"transformers.GraniteMoeConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.GraniteMoeConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.GraniteMoeConfig.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.GraniteMoeConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.GraniteMoeConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Padding token id.`,name:"pad_token_id"},{anchor:"transformers.GraniteMoeConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Beginning of stream token id.`,name:"bos_token_id"},{anchor:"transformers.GraniteMoeConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
End of stream token id.`,name:"eos_token_id"},{anchor:"transformers.GraniteMoeConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to tie weight embeddings`,name:"tie_word_embeddings"},{anchor:"transformers.GraniteMoeConfig.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.GraniteMoeConfig.rope_scaling",description:`<strong>rope_scaling</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
<code>{&quot;type&quot;: strategy name, &quot;factor&quot;: scaling factor}</code>. When using this flag, don&#x2019;t update
<code>max_position_embeddings</code> to the expected new maximum. See the following thread for more information on how
these scaling strategies behave:
<a href="https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/" rel="nofollow">https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/</a>. This is an
experimental feature, subject to breaking API changes in future versions.`,name:"rope_scaling"},{anchor:"transformers.GraniteMoeConfig.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use a bias in the query, key, value and output projection layers during self-attention.`,name:"attention_bias"},{anchor:"transformers.GraniteMoeConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.GraniteMoeConfig.embedding_multiplier",description:"<strong>embedding_multiplier</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014; embedding multiplier",name:"embedding_multiplier"},{anchor:"transformers.GraniteMoeConfig.logits_scaling",description:"<strong>logits_scaling</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014; divisor for output logits",name:"logits_scaling"},{anchor:"transformers.GraniteMoeConfig.residual_multiplier",description:"<strong>residual_multiplier</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014; residual multiplier",name:"residual_multiplier"},{anchor:"transformers.GraniteMoeConfig.attention_multiplier",description:"<strong>attention_multiplier</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014; attention multiplier",name:"attention_multiplier"},{anchor:"transformers.GraniteMoeConfig.num_local_experts",description:"<strong>num_local_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014; total number of experts",name:"num_local_experts"},{anchor:"transformers.GraniteMoeConfig.num_experts_per_tok",description:"<strong>num_experts_per_tok</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014; number of experts per token",name:"num_experts_per_tok"},{anchor:"transformers.GraniteMoeConfig.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the router logits should be returned by the model. Enabeling this will also
allow the model to output the auxiliary loss.`,name:"output_router_logits"},{anchor:"transformers.GraniteMoeConfig.router_aux_loss_coef",description:"<strong>router_aux_loss_coef</strong> (<code>float</code>, <em>optional</em>, defaults to 0.001) &#x2014; router auxialiary loss coefficient",name:"router_aux_loss_coef"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/granitemoe/configuration_granitemoe.py#L30"}}),I=new nt({props:{anchor:"transformers.GraniteMoeConfig.example",$$slots:{default:[ct]},$$scope:{ctx:C}}}),q=new me({props:{title:"GraniteMoeModel",local:"transformers.GraniteMoeModel",headingTag:"h2"}}),H=new ce({props:{name:"class transformers.GraniteMoeModel",anchor:"transformers.GraniteMoeModel",parameters:[{name:"config",val:": GraniteMoeConfig"}],parametersDescription:[{anchor:"transformers.GraniteMoeModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/granitemoe#transformers.GraniteMoeConfig">GraniteMoeConfig</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.`,name:"config"},{anchor:"transformers.GraniteMoeModel.config",description:"<strong>config</strong> &#x2014; GraniteMoeConfig",name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/granitemoe/modeling_granitemoe.py#L938"}}),Q=new ce({props:{name:"forward",anchor:"transformers.GraniteMoeModel.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Union[transformers.cache_utils.Cache, typing.List[torch.FloatTensor], NoneType] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.GraniteMoeModel.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.GraniteMoeModel.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.GraniteMoeModel.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.GraniteMoeModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Cache</code> or <code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>) &#x2014;
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code>
returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p>
<p>Two formats are allowed:</p>
<ul>
<li>a <a href="/docs/transformers/main/en/internal/generation_utils#transformers.Cache">Cache</a> instance;</li>
<li>Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of
shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>). This is also known as the legacy
cache format.</li>
</ul>
<p>The model will output the same cache format that is fed as input. If no <code>past_key_values</code> are passed, the
legacy cache format will be returned.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>input_ids</code> (those that don&#x2019;t
have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all <code>input_ids</code>
of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.GraniteMoeModel.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.GraniteMoeModel.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.GraniteMoeModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GraniteMoeModel.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 layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GraniteMoeModel.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.GraniteMoeModel.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/granitemoe/modeling_granitemoe.py#L981"}}),j=new ot({props:{$$slots:{default:[mt]},$$scope:{ctx:C}}}),Y=new me({props:{title:"GraniteMoeForCausalLM",local:"transformers.GraniteMoeForCausalLM",headingTag:"h2"}}),A=new ce({props:{name:"class transformers.GraniteMoeForCausalLM",anchor:"transformers.GraniteMoeForCausalLM",parameters:[{name:"config",val:": GraniteMoeConfig"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/granitemoe/modeling_granitemoe.py#L1237"}}),D=new ce({props:{name:"forward",anchor:"transformers.GraniteMoeForCausalLM.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Union[transformers.cache_utils.Cache, typing.List[torch.FloatTensor], NoneType] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GraniteMoeForCausalLM.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.GraniteMoeForCausalLM.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.GraniteMoeForCausalLM.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.GraniteMoeForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Cache</code> or <code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>) &#x2014;
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code>
returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p>
<p>Two formats are allowed:</p>
<ul>
<li>a <a href="/docs/transformers/main/en/internal/generation_utils#transformers.Cache">Cache</a> instance;</li>
<li>Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of
shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>). This is also known as the legacy
cache format.</li>
</ul>
<p>The model will output the same cache format that is fed as input. If no <code>past_key_values</code> are passed, the
legacy cache format will be returned.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>input_ids</code> (those that don&#x2019;t
have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all <code>input_ids</code>
of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.GraniteMoeForCausalLM.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.GraniteMoeForCausalLM.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.GraniteMoeForCausalLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GraniteMoeForCausalLM.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 layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GraniteMoeForCausalLM.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.GraniteMoeForCausalLM.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"},{anchor:"transformers.GraniteMoeForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/granitemoe/modeling_granitemoe.py#L1271",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.modeling_outputs.MoeCausalLMOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/granitemoe#transformers.GraniteMoeConfig"
>GraniteMoeConfig</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>aux_loss</strong> (<code>torch.FloatTensor</code>, <em>optional</em>, returned when <code>labels</code> is provided) — aux_loss for the sparse modules.</p>
</li>
<li>
<p><strong>router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_probs=True</code> and <code>config.add_router_probs=True</code> is passed or when <code>config.output_router_probs=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Raw router logtis (post-softmax) that are computed by MoE routers, these terms are used to compute the auxiliary
loss for Mixture of Experts models.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.modeling_outputs.MoeCausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),W=new ot({props:{$$slots:{default:[pt]},$$scope:{ctx:C}}}),B=new nt({props:{anchor:"transformers.GraniteMoeForCausalLM.forward.example",$$slots:{default:[ut]},$$scope:{ctx:C}}}),O=new dt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/granitemoe.md"}}),{c(){n=l("meta"),p=r(),s=l("p"),u=r(),h(k.$$.fragment),m=r(),h($.$$.fragment),pe=r(),L=l("p"),L.innerHTML=Xe,ue=r(),Z=l("p"),Z.textContent=Re,he=r(),V=l("p"),V.textContent=Se,fe=r(),P=l("p"),P.innerHTML=qe,ge=r(),E=l("p"),E.textContent=He,_e=r(),h(N.$$.fragment),Me=r(),X=l("p"),X.innerHTML=Qe,be=r(),h(R.$$.fragment),ye=r(),T=l("div"),h(S.$$.fragment),ze=r(),oe=l("p"),oe.innerHTML=Ye,Ue=r(),ne=l("p"),ne.innerHTML=Ae,Je=r(),h(I.$$.fragment),ve=r(),h(q.$$.fragment),Te=r(),v=l("div"),h(H.$$.fragment),Ie=r(),ae=l("p"),ae.innerHTML=De,je=r(),se=l("p"),se.innerHTML=Oe,We=r(),re=l("p"),re.innerHTML=Ke,Be=r(),z=l("div"),h(Q.$$.fragment),Fe=r(),ie=l("p"),ie.innerHTML=et,Le=r(),h(j.$$.fragment),we=r(),h(Y.$$.fragment),ke=r(),U=l("div"),h(A.$$.fragment),Ze=r(),G=l("div"),h(D.$$.fragment),Ve=r(),le=l("p"),le.innerHTML=tt,Pe=r(),h(W.$$.fragment),Ee=r(),h(B.$$.fragment),Ge=r(),h(O.$$.fragment),$e=r(),de=l("p"),this.h()},l(e){const t=lt("svelte-u9bgzb",document.head);n=d(t,"META",{name:!0,content:!0}),t.forEach(o),p=i(e),s=d(e,"P",{}),ee(s).forEach(o),u=i(e),f(k.$$.fragment,e),m=i(e),f($.$$.fragment,e),pe=i(e),L=d(e,"P",{"data-svelte-h":!0}),y(L)!=="svelte-1ckss4i"&&(L.innerHTML=Xe),ue=i(e),Z=d(e,"P",{"data-svelte-h":!0}),y(Z)!=="svelte-fc3udx"&&(Z.textContent=Re),he=i(e),V=d(e,"P",{"data-svelte-h":!0}),y(V)!=="svelte-vfdo9a"&&(V.textContent=Se),fe=i(e),P=d(e,"P",{"data-svelte-h":!0}),y(P)!=="svelte-16cvzw6"&&(P.innerHTML=qe),ge=i(e),E=d(e,"P",{"data-svelte-h":!0}),y(E)!=="svelte-axv494"&&(E.textContent=He),_e=i(e),f(N.$$.fragment,e),Me=i(e),X=d(e,"P",{"data-svelte-h":!0}),y(X)!=="svelte-xzc2lh"&&(X.innerHTML=Qe),be=i(e),f(R.$$.fragment,e),ye=i(e),T=d(e,"DIV",{class:!0});var x=ee(T);f(S.$$.fragment,x),ze=i(x),oe=d(x,"P",{"data-svelte-h":!0}),y(oe)!=="svelte-9eipei"&&(oe.innerHTML=Ye),Ue=i(x),ne=d(x,"P",{"data-svelte-h":!0}),y(ne)!=="svelte-o55m63"&&(ne.innerHTML=Ae),Je=i(x),f(I.$$.fragment,x),x.forEach(o),ve=i(e),f(q.$$.fragment,e),Te=i(e),v=d(e,"DIV",{class:!0});var w=ee(v);f(H.$$.fragment,w),Ie=i(w),ae=d(w,"P",{"data-svelte-h":!0}),y(ae)!=="svelte-1yjeqjr"&&(ae.innerHTML=De),je=i(w),se=d(w,"P",{"data-svelte-h":!0}),y(se)!=="svelte-hswkmf"&&(se.innerHTML=Oe),We=i(w),re=d(w,"P",{"data-svelte-h":!0}),y(re)!=="svelte-1ozix6s"&&(re.innerHTML=Ke),Be=i(w),z=d(w,"DIV",{class:!0});var J=ee(z);f(Q.$$.fragment,J),Fe=i(J),ie=d(J,"P",{"data-svelte-h":!0}),y(ie)!=="svelte-199v9w0"&&(ie.innerHTML=et),Le=i(J),f(j.$$.fragment,J),J.forEach(o),w.forEach(o),we=i(e),f(Y.$$.fragment,e),ke=i(e),U=d(e,"DIV",{class:!0});var K=ee(U);f(A.$$.fragment,K),Ze=i(K),G=d(K,"DIV",{class:!0});var F=ee(G);f(D.$$.fragment,F),Ve=i(F),le=d(F,"P",{"data-svelte-h":!0}),y(le)!=="svelte-i7ptuo"&&(le.innerHTML=tt),Pe=i(F),f(W.$$.fragment,F),Ee=i(F),f(B.$$.fragment,F),F.forEach(o),K.forEach(o),Ge=i(e),f(O.$$.fragment,e),$e=i(e),de=d(e,"P",{}),ee(de).forEach(o),this.h()},h(){te(n,"name","hf:doc:metadata"),te(n,"content",ft),te(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(U,"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){c(document.head,n),a(e,p,t),a(e,s,t),a(e,u,t),g(k,e,t),a(e,m,t),g($,e,t),a(e,pe,t),a(e,L,t),a(e,ue,t),a(e,Z,t),a(e,he,t),a(e,V,t),a(e,fe,t),a(e,P,t),a(e,ge,t),a(e,E,t),a(e,_e,t),g(N,e,t),a(e,Me,t),a(e,X,t),a(e,be,t),g(R,e,t),a(e,ye,t),a(e,T,t),g(S,T,null),c(T,ze),c(T,oe),c(T,Ue),c(T,ne),c(T,Je),g(I,T,null),a(e,ve,t),g(q,e,t),a(e,Te,t),a(e,v,t),g(H,v,null),c(v,Ie),c(v,ae),c(v,je),c(v,se),c(v,We),c(v,re),c(v,Be),c(v,z),g(Q,z,null),c(z,Fe),c(z,ie),c(z,Le),g(j,z,null),a(e,we,t),g(Y,e,t),a(e,ke,t),a(e,U,t),g(A,U,null),c(U,Ze),c(U,G),g(D,G,null),c(G,Ve),c(G,le),c(G,Pe),g(W,G,null),c(G,Ee),g(B,G,null),a(e,Ge,t),g(O,e,t),a(e,$e,t),a(e,de,t),xe=!0},p(e,[t]){const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),I.$set(x);const w={};t&2&&(w.$$scope={dirty:t,ctx:e}),j.$set(w);const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),W.$set(J);const K={};t&2&&(K.$$scope={dirty:t,ctx:e}),B.$set(K)},i(e){xe||(_(k.$$.fragment,e),_($.$$.fragment,e),_(N.$$.fragment,e),_(R.$$.fragment,e),_(S.$$.fragment,e),_(I.$$.fragment,e),_(q.$$.fragment,e),_(H.$$.fragment,e),_(Q.$$.fragment,e),_(j.$$.fragment,e),_(Y.$$.fragment,e),_(A.$$.fragment,e),_(D.$$.fragment,e),_(W.$$.fragment,e),_(B.$$.fragment,e),_(O.$$.fragment,e),xe=!0)},o(e){M(k.$$.fragment,e),M($.$$.fragment,e),M(N.$$.fragment,e),M(R.$$.fragment,e),M(S.$$.fragment,e),M(I.$$.fragment,e),M(q.$$.fragment,e),M(H.$$.fragment,e),M(Q.$$.fragment,e),M(j.$$.fragment,e),M(Y.$$.fragment,e),M(A.$$.fragment,e),M(D.$$.fragment,e),M(W.$$.fragment,e),M(B.$$.fragment,e),M(O.$$.fragment,e),xe=!1},d(e){e&&(o(p),o(s),o(u),o(m),o(pe),o(L),o(ue),o(Z),o(he),o(V),o(fe),o(P),o(ge),o(E),o(_e),o(Me),o(X),o(be),o(ye),o(T),o(ve),o(Te),o(v),o(we),o(ke),o(U),o(Ge),o($e),o(de)),o(n),b(k,e),b($,e),b(N,e),b(R,e),b(S),b(I),b(q,e),b(H),b(Q),b(j),b(Y,e),b(A),b(D),b(W),b(B),b(O,e)}}}const ft='{"title":"GraniteMoe","local":"granitemoe","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"GraniteMoeConfig","local":"transformers.GraniteMoeConfig","sections":[],"depth":2},{"title":"GraniteMoeModel","local":"transformers.GraniteMoeModel","sections":[],"depth":2},{"title":"GraniteMoeForCausalLM","local":"transformers.GraniteMoeForCausalLM","sections":[],"depth":2}],"depth":1}';function gt(C){return st(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class kt extends rt{constructor(n){super(),it(this,n,gt,ht,at,{})}}export{kt as component};
