import{s as Xo,o as Po,n as ot}from"../chunks/scheduler.18a86fab.js";import{S as Yo,i as Do,g as l,s as n,r as m,A as Oo,h as i,f as o,c as s,j as F,u as h,x as p,k as C,y as r,a,v as u,d as f,t as g,w as _}from"../chunks/index.98837b22.js";import{T as Vo}from"../chunks/Tip.77304350.js";import{D as I}from"../chunks/Docstring.6758ea23.js";import{C as tt}from"../chunks/CodeBlock.8d0c2e8a.js";import{E as mo}from"../chunks/ExampleCodeBlock.0c42463f.js";import{H as Z}from"../chunks/Heading.7e7e0c5b.js";import{E as Ao}from"../chunks/index.499f366c.js";function Qo(z){let d,v="Example:",b,y,M;return y=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME5sbGJNb2VNb2RlbCUyQyUyME5sbGJNb2VDb25maWclMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwTmxsYk1vZSUyMGZhY2Vib29rJTJGbmxsYi1tb2UtNTRiJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyME5sbGJNb2VDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBmYWNlYm9vayUyRm5sbGItbW9lLTU0YiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwTmxsYk1vZU1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> NllbMoeModel, NllbMoeConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a NllbMoe facebook/nllb-moe-54b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = NllbMoeConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the facebook/nllb-moe-54b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NllbMoeModel(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(){d=l("p"),d.textContent=v,b=n(),m(y.$$.fragment)},l(c){d=i(c,"P",{"data-svelte-h":!0}),p(d)!=="svelte-11lpom8"&&(d.textContent=v),b=s(c),h(y.$$.fragment,c)},m(c,T){a(c,d,T),a(c,b,T),u(y,c,T),M=!0},p:ot,i(c){M||(f(y.$$.fragment,c),M=!0)},o(c){g(y.$$.fragment,c),M=!1},d(c){c&&(o(d),o(b)),_(y,c)}}}function Ko(z){let d,v=`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(){d=l("p"),d.innerHTML=v},l(b){d=i(b,"P",{"data-svelte-h":!0}),p(d)!=="svelte-fincs2"&&(d.innerHTML=v)},m(b,y){a(b,d,y)},p:ot,d(b){b&&o(d)}}}function en(z){let d,v="Example:",b,y,M;return y=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBObGxiTW9lTW9kZWwlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGcmFuZG9tLW5sbGItbW9lLTItZXhwZXJ0cyUyMiklMEFtb2RlbCUyMCUzRCUyMFN3aXRjaFRyYW5zZm9ybWVyc01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGcmFuZG9tLW5sbGItbW9lLTItZXhwZXJ0cyUyMiklMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIyU3R1ZGllcyUyMGhhdmUlMjBiZWVuJTIwc2hvd24lMjB0aGF0JTIwb3duaW5nJTIwYSUyMGRvZyUyMGlzJTIwZ29vZCUyMGZvciUyMHlvdSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMEEpLmlucHV0X2lkcyUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEFkZWNvZGVyX2lucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglMjJTdHVkaWVzJTIwc2hvdyUyMHRoYXQlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHMlMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlMjAxJTBBJTBBJTIzJTIwcHJlcHJvY2VzcyUzQSUyMFByZXBlbmQlMjBkZWNvZGVyX2lucHV0X2lkcyUyMHdpdGglMjBzdGFydCUyMHRva2VuJTIwd2hpY2glMjBpcyUyMHBhZCUyMHRva2VuJTIwZm9yJTIwTmxsYk1vZU1vZGVsJTBBZGVjb2Rlcl9pbnB1dF9pZHMlMjAlM0QlMjBtb2RlbC5fc2hpZnRfcmlnaHQoZGVjb2Rlcl9pbnB1dF9pZHMpJTBBJTBBJTIzJTIwZm9yd2FyZCUyMHBhc3MlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RkZWNvZGVyX2lucHV0X2lkcyklMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NllbMoeModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;hf-internal-testing/random-nllb-moe-2-experts&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwitchTransformersModel.from_pretrained(<span class="hljs-string">&quot;hf-internal-testing/random-nllb-moe-2-experts&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Studies have been shown that owning a dog is good for you&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>).input_ids  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = tokenizer(<span class="hljs-string">&quot;Studies show that&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids  <span class="hljs-comment"># Batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># preprocess: Prepend decoder_input_ids with start token which is pad token for NllbMoeModel</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = model._shift_right(decoder_input_ids)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){d=l("p"),d.textContent=v,b=n(),m(y.$$.fragment)},l(c){d=i(c,"P",{"data-svelte-h":!0}),p(d)!=="svelte-11lpom8"&&(d.textContent=v),b=s(c),h(y.$$.fragment,c)},m(c,T){a(c,d,T),a(c,b,T),u(y,c,T),M=!0},p:ot,i(c){M||(f(y.$$.fragment,c),M=!0)},o(c){g(y.$$.fragment,c),M=!1},d(c){c&&(o(d),o(b)),_(y,c)}}}function tn(z){let d,v=`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(){d=l("p"),d.innerHTML=v},l(b){d=i(b,"P",{"data-svelte-h":!0}),p(d)!=="svelte-fincs2"&&(d.innerHTML=v)},m(b,y){a(b,d,y)},p:ot,d(b){b&&o(d)}}}function on(z){let d,v="Example Translation:",b,y,M;return y=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBObGxiTW9lRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBObGxiTW9lRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm5sbGItbW9lLTU0YiUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm5sbGItbW9lLTU0YiUyMiklMEElMEF0ZXh0X3RvX3RyYW5zbGF0ZSUyMCUzRCUyMCUyMkxpZmUlMjBpcyUyMGxpa2UlMjBhJTIwYm94JTIwb2YlMjBjaG9jb2xhdGVzJTIyJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHRfdG9fdHJhbnNsYXRlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjB0cmFuc2xhdGUlMjB0byUyMEZyZW5jaCUwQWdlbl90b2tlbnMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKm1vZGVsX2lucHV0cyUyQyUyMGZvcmNlZF9ib3NfdG9rZW5faWQlM0R0b2tlbml6ZXIuZ2V0X2xhbmdfaWQoJTIyZW5nX0xhdG4lMjIpKSUwQXByaW50KHRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuX3Rva2VucyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NllbMoeForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = NllbMoeForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>text_to_translate = <span class="hljs-string">&quot;Life is like a box of chocolates&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_inputs = tokenizer(text_to_translate, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># translate to French</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>gen_tokens = model.generate(**model_inputs, forced_bos_token_id=tokenizer.get_lang_id(<span class="hljs-string">&quot;eng_Latn&quot;</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(gen_tokens, skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),{c(){d=l("p"),d.textContent=v,b=n(),m(y.$$.fragment)},l(c){d=i(c,"P",{"data-svelte-h":!0}),p(d)!=="svelte-hvxwgb"&&(d.textContent=v),b=s(c),h(y.$$.fragment,c)},m(c,T){a(c,d,T),a(c,b,T),u(y,c,T),M=!0},p:ot,i(c){M||(f(y.$$.fragment,c),M=!0)},o(c){g(y.$$.fragment,c),M=!1},d(c){c&&(o(d),o(b)),_(y,c)}}}function nn(z){let d,v,b,y,M,c,T,ho='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',nt,A,st,Q,uo=`The NLLB model was presented in <a href="https://arxiv.org/abs/2207.04672" rel="nofollow">No Language Left Behind: Scaling Human-Centered Machine Translation</a> by Marta R. Costa-jussà, James Cross, Onur Çelebi,
Maha Elbayad, Kenneth Heafield, Kevin Heffernan, Elahe Kalbassi, Janice Lam, Daniel Licht, Jean Maillard, Anna Sun, Skyler Wang, Guillaume Wenzek, Al Youngblood, Bapi Akula,
Loic Barrault, Gabriel Mejia Gonzalez, Prangthip Hansanti, John Hoffman, Semarley Jarrett, Kaushik Ram Sadagopan, Dirk Rowe, Shannon Spruit, Chau Tran, Pierre Andrews,
Necip Fazil Ayan, Shruti Bhosale, Sergey Edunov, Angela Fan, Cynthia Gao, Vedanuj Goswami, Francisco Guzmán, Philipp Koehn, Alexandre Mourachko, Christophe Ropers,
Safiyyah Saleem, Holger Schwenk, and Jeff Wang.`,at,K,fo="The abstract of the paper is the following:",rt,ee,go=`<em>Driven by the goal of eradicating language barriers on a global scale, machine translation has solidified itself as a key focus of artificial intelligence research today.
However, such efforts have coalesced around a small subset of languages, leaving behind the vast majority of mostly low-resource languages. What does it take to break the
200 language barrier while ensuring safe, high quality results, all while keeping ethical considerations in mind? In No Language Left Behind, we took on this challenge by
first contextualizing the need for low-resource language translation support through exploratory interviews with native speakers. Then, we created datasets and models aimed
at narrowing the performance gap between low and high-resource languages. More specifically, we developed a conditional compute model based on Sparsely Gated Mixture of
Experts that is trained on data obtained with novel and effective data mining techniques tailored for low-resource languages. We propose multiple architectural and training
improvements to counteract overfitting while training on thousands of tasks. Critically, we evaluated the performance of over 40,000 different translation directions using
a human-translated benchmark, Flores-200, and combined human evaluation with a novel toxicity benchmark covering all languages in Flores-200 to assess translation safety.
Our model achieves an improvement of 44% BLEU relative to the previous state-of-the-art, laying important groundwork towards realizing a universal translation system.</em>`,lt,te,_o=`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/facebookresearch/fairseq" rel="nofollow">here</a>.`,it,oe,dt,ne,bo="<li>M2M100ForConditionalGeneration is the base model for both NLLB and NLLB MoE</li> <li>The NLLB-MoE is very similar to the NLLB model, but it’s feed forward layer is based on the implementation of SwitchTransformers.</li> <li>The tokenizer is the same as the NLLB models.</li>",ct,se,pt,ae,yo=`The biggest difference is the way the tokens are routed. NLLB-MoE uses a <code>top-2-gate</code> which means that for each input, only the top two experts are selected based on the
highest predicted probabilities from the gating network, and the remaining experts are ignored. In <code>SwitchTransformers</code>, only the top-1 probabilities are computed,
which means that tokens have less probability of being forwarded. Moreover, if a token is not routed to any expert, <code>SwitchTransformers</code> still adds its unmodified hidden
states (kind of like a residual connection) while they are masked in <code>NLLB</code>’s top-2 routing mechanism.`,mt,re,ht,le,Mo="The available checkpoints require around 350GB of storage. Make sure to use <code>accelerate</code> if you do not have enough RAM on your machine.",ut,ie,To=`While generating the target text set the <code>forced_bos_token_id</code> to the target language id. The following
example shows how to translate English to French using the <em>facebook/nllb-200-distilled-600M</em> model.`,ft,de,vo=`Note that we’re using the BCP-47 code for French <code>fra_Latn</code>. See <a href="https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200" rel="nofollow">here</a>
for the list of all BCP-47 in the Flores 200 dataset.`,gt,ce,_t,pe,bt,me,ko=`English (<code>eng_Latn</code>) is set as the default language from which to translate. In order to specify that you’d like to translate from a different language,
you should specify the BCP-47 code in the <code>src_lang</code> keyword argument of the tokenizer initialization.`,yt,he,wo="See example below for a translation from romanian to german:",Mt,ue,Tt,fe,vt,ge,xo='<li><a href="../tasks/translation">Translation task guide</a></li> <li><a href="../tasks/summarization">Summarization task guide</a></li>',kt,_e,wt,N,be,Lt,Ge,$o=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/nllb-moe#transformers.NllbMoeModel">NllbMoeModel</a>. It is used to instantiate an
NLLB-MoE 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 NLLB-MoE
<a href="https://huggingface.co/facebook/nllb-moe-54b" rel="nofollow">facebook/nllb-moe-54b</a> architecture.`,qt,Le,No=`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.`,Wt,R,xt,ye,$t,k,Me,It,qe,Co="Router using tokens choose top-2 experts assignment.",Bt,We,zo=`This router uses the same mechanism as in NLLB-MoE from the fairseq repository. Items are sorted by router_probs
and then routed to their choice of expert until the expert’s expert_capacity is reached. <strong>There is no guarantee
that each token is processed by an expert</strong>, or that each expert receives at least one token.`,Rt,Ie,jo="The router combining weights are also returned to make sure that the states that are not updated will be masked.",Et,E,Te,Ht,Be,Uo=`Computes the <code>dispatch_mask</code> and the <code>dispatch_weights</code> for each experts. The masks are adapted to the expert
capacity.`,St,H,ve,Vt,Re,Jo=`The hidden states are reshaped to simplify the computation of the router probabilities (combining weights for
each experts.)`,Nt,ke,Ct,G,we,Xt,Ee,Fo="Implementation of the NLLB-MoE sparse MLP module.",Pt,j,xe,Yt,He,Zo=`The goal of this forward pass is to have the same number of operation as the equivalent <code>NllbMoeDenseActDense</code>
(mlp) layer. This means that all of the hidden states should be processed at most twice ( since we are using a
top_2 gating mechanism). This means that we keep the complexity to O(batch_size x sequence_length x hidden_dim)
instead of O(num_experts x batch_size x sequence_length x hidden_dim).`,Dt,Se,Go=`1- Get the <code>router_probs</code> from the <code>router</code>. The shape of the <code>router_mask</code> is <code>(batch_size X sequence_length, num_expert)</code> and corresponds to the boolean version of the <code>router_probs</code>. The inputs are masked using the
<code>router_mask</code>.`,Ot,Ve,Lo=`2- Dispatch the hidden_states to its associated experts. The router probabilities are used to weight the
contribution of each experts when updating the masked hidden states.`,zt,$e,jt,w,Ne,At,Xe,qo="The bare Nllb Moe Model outputting raw hidden-states without any specific head on top.",Qt,Pe,Wo=`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.)`,Kt,Ye,Io=`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.`,eo,U,Ce,to,De,Bo='The <a href="/docs/transformers/main/en/model_doc/nllb-moe#transformers.NllbMoeModel">NllbMoeModel</a> forward method, overrides the <code>__call__</code> special method.',oo,S,no,V,Ut,ze,Jt,x,je,so,Oe,Ro="The NllbMoe Model with a language modeling head. Can be used for summarization.",ao,Ae,Eo=`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.)`,ro,Qe,Ho=`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.`,lo,J,Ue,io,Ke,So='The <a href="/docs/transformers/main/en/model_doc/nllb-moe#transformers.NllbMoeForConditionalGeneration">NllbMoeForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',co,X,po,P,Ft,Je,Zt,et,Gt;return M=new Z({props:{title:"NLLB-MOE",local:"nllb-moe",headingTag:"h1"}}),A=new Z({props:{title:"Overview",local:"overview",headingTag:"h2"}}),oe=new Z({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),se=new Z({props:{title:"Implementation differences with SwitchTransformers",local:"implementation-differences-with-switchtransformers",headingTag:"h2"}}),re=new Z({props:{title:"Generating with NLLB-MoE",local:"generating-with-nllb-moe",headingTag:"h2"}}),ce=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm5sbGItbW9lLTU0YiUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZubGxiLW1vZS01NGIlMjIpJTBBJTBBYXJ0aWNsZSUyMCUzRCUyMCUyMlByZXZpb3VzbHklMkMlMjBSaW5nJ3MlMjBDRU8lMkMlMjBKYW1pZSUyMFNpbWlub2ZmJTJDJTIwcmVtYXJrZWQlMjB0aGUlMjBjb21wYW55JTIwc3RhcnRlZCUyMHdoZW4lMjBoaXMlMjBkb29yYmVsbCUyMHdhc24ndCUyMGF1ZGlibGUlMjBmcm9tJTIwaGlzJTIwc2hvcCUyMGluJTIwaGlzJTIwZ2FyYWdlLiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihhcnRpY2xlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF0cmFuc2xhdGVkX3Rva2VucyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMCoqaW5wdXRzJTJDJTIwZm9yY2VkX2Jvc190b2tlbl9pZCUzRHRva2VuaXplci5sYW5nX2NvZGVfdG9faWQlNUIlMjJmcmFfTGF0biUyMiU1RCUyQyUyMG1heF9sZW5ndGglM0Q1MCUwQSklMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKHRyYW5zbGF0ZWRfdG9rZW5zJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>article = <span class="hljs-string">&quot;Previously, Ring&#x27;s CEO, Jamie Siminoff, remarked the company started when his doorbell wasn&#x27;t audible from his shop in his garage.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(article, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>translated_tokens = model.generate(
<span class="hljs-meta">... </span>    **inputs, forced_bos_token_id=tokenizer.lang_code_to_id[<span class="hljs-string">&quot;fra_Latn&quot;</span>], max_length=<span class="hljs-number">50</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(translated_tokens, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-string">&quot;Auparavant, le PDG de Ring, Jamie Siminoff, a fait remarquer que la société avait commencé lorsque sa sonnette n&#x27;était pas audible depuis son magasin dans son garage.&quot;</span>`,wrap:!1}}),pe=new Z({props:{title:"Generating from any other language than English",local:"generating-from-any-other-language-than-english",headingTag:"h3"}}),ue=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm5sbGItbW9lLTU0YiUyMiUyQyUyMHNyY19sYW5nJTNEJTIycm9uX0xhdG4lMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGbmxsYi1tb2UtNTRiJTIyKSUwQSUwQWFydGljbGUlMjAlM0QlMjAlMjIlQzUlOUVlZnVsJTIwT05VJTIwc3B1bmUlMjBjJUM0JTgzJTIwbnUlMjBleGlzdCVDNCU4MyUyMG8lMjBzb2x1JUM1JUEzaWUlMjBtaWxpdGFyJUM0JTgzJTIwJUMzJUFFbiUyMFNpcmlhJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKGFydGljbGUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXRyYW5zbGF0ZWRfdG9rZW5zJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwKippbnB1dHMlMkMlMjBmb3JjZWRfYm9zX3Rva2VuX2lkJTNEdG9rZW5pemVyLmxhbmdfY29kZV90b19pZCU1QiUyMmRldV9MYXRuJTIyJTVEJTJDJTIwbWF4X2xlbmd0aCUzRDMwJTBBKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUodHJhbnNsYXRlZF90b2tlbnMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>, src_lang=<span class="hljs-string">&quot;ron_Latn&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-moe-54b&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>article = <span class="hljs-string">&quot;Şeful ONU spune că nu există o soluţie militară în Siria&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(article, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>translated_tokens = model.generate(
<span class="hljs-meta">... </span>    **inputs, forced_bos_token_id=tokenizer.lang_code_to_id[<span class="hljs-string">&quot;deu_Latn&quot;</span>], max_length=<span class="hljs-number">30</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(translated_tokens, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,wrap:!1}}),fe=new Z({props:{title:"Resources",local:"resources",headingTag:"h2"}}),_e=new Z({props:{title:"NllbMoeConfig",local:"transformers.NllbMoeConfig",headingTag:"h2"}}),be=new I({props:{name:"class transformers.NllbMoeConfig",anchor:"transformers.NllbMoeConfig",parameters:[{name:"vocab_size",val:" = 128112"},{name:"max_position_embeddings",val:" = 1024"},{name:"encoder_layers",val:" = 12"},{name:"encoder_ffn_dim",val:" = 4096"},{name:"encoder_attention_heads",val:" = 16"},{name:"decoder_layers",val:" = 12"},{name:"decoder_ffn_dim",val:" = 4096"},{name:"decoder_attention_heads",val:" = 16"},{name:"encoder_layerdrop",val:" = 0.05"},{name:"decoder_layerdrop",val:" = 0.05"},{name:"use_cache",val:" = True"},{name:"is_encoder_decoder",val:" = True"},{name:"activation_function",val:" = 'relu'"},{name:"d_model",val:" = 1024"},{name:"dropout",val:" = 0.1"},{name:"attention_dropout",val:" = 0.1"},{name:"activation_dropout",val:" = 0.0"},{name:"init_std",val:" = 0.02"},{name:"decoder_start_token_id",val:" = 2"},{name:"scale_embedding",val:" = True"},{name:"router_bias",val:" = False"},{name:"router_dtype",val:" = 'float32'"},{name:"router_ignore_padding_tokens",val:" = False"},{name:"num_experts",val:" = 128"},{name:"expert_capacity",val:" = 64"},{name:"encoder_sparse_step",val:" = 4"},{name:"decoder_sparse_step",val:" = 4"},{name:"router_z_loss_coef",val:" = 0.001"},{name:"router_aux_loss_coef",val:" = 0.001"},{name:"second_expert_policy",val:" = 'all'"},{name:"normalize_router_prob_before_dropping",val:" = False"},{name:"batch_prioritized_routing",val:" = False"},{name:"moe_eval_capacity_token_fraction",val:" = 1.0"},{name:"moe_token_dropout",val:" = 0.2"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"output_router_logits",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.NllbMoeConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50265) &#x2014;
Vocabulary size of the NllbMoe 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/nllb-moe#transformers.NllbMoeModel">NllbMoeModel</a> or`,name:"vocab_size"},{anchor:"transformers.NllbMoeConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the layers and the pooler layer.`,name:"d_model"},{anchor:"transformers.NllbMoeConfig.encoder_layers",description:`<strong>encoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of encoder layers.`,name:"encoder_layers"},{anchor:"transformers.NllbMoeConfig.decoder_layers",description:`<strong>decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of decoder layers.`,name:"decoder_layers"},{anchor:"transformers.NllbMoeConfig.encoder_attention_heads",description:`<strong>encoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"encoder_attention_heads"},{anchor:"transformers.NllbMoeConfig.decoder_attention_heads",description:`<strong>decoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"decoder_attention_heads"},{anchor:"transformers.NllbMoeConfig.decoder_ffn_dim",description:`<strong>decoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in decoder.`,name:"decoder_ffn_dim"},{anchor:"transformers.NllbMoeConfig.encoder_ffn_dim",description:`<strong>encoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in encoder.`,name:"encoder_ffn_dim"},{anchor:"transformers.NllbMoeConfig.activation_function",description:`<strong>activation_function</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"activation_function"},{anchor:"transformers.NllbMoeConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"dropout"},{anchor:"transformers.NllbMoeConfig.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.NllbMoeConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.NllbMoeConfig.classifier_dropout",description:`<strong>classifier_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for classifier.`,name:"classifier_dropout"},{anchor:"transformers.NllbMoeConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.NllbMoeConfig.init_std",description:`<strong>init_std</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:"init_std"},{anchor:"transformers.NllbMoeConfig.encoder_layerdrop",description:`<strong>encoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The LayerDrop probability for the encoder. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>)
for more details.`,name:"encoder_layerdrop"},{anchor:"transformers.NllbMoeConfig.decoder_layerdrop",description:`<strong>decoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The LayerDrop probability for the decoder. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>)
for more details.`,name:"decoder_layerdrop"},{anchor:"transformers.NllbMoeConfig.second_expert_policy",description:`<strong>second_expert_policy</strong> ( <code>str</code>, <em>optional</em>, default to <code>&quot;all&quot;</code>) &#x2014;
The policy used for the sampling the probability of being sampled to a second expert for each token.`,name:"second_expert_policy"},{anchor:"transformers.NllbMoeConfig.normalize_router_prob_before_dropping",description:`<strong>normalize_router_prob_before_dropping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to normalize the router probabilities before applying a mask based on the experts capacity
(capacity dropping).`,name:"normalize_router_prob_before_dropping"},{anchor:"transformers.NllbMoeConfig.batch_prioritized_routing",description:`<strong>batch_prioritized_routing</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to orders the tokens by their router probabilities before capacity dropping. This means that
the tokens that have the highest probabilities will be routed before other tokens that might be further in
the sequence.`,name:"batch_prioritized_routing"},{anchor:"transformers.NllbMoeConfig.moe_eval_capacity_token_fraction",description:`<strong>moe_eval_capacity_token_fraction</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Fraction of tokens as capacity during validation, if set to negative, uses the same as training. Should be
in range: (0.0, 1.0].`,name:"moe_eval_capacity_token_fraction"},{anchor:"transformers.NllbMoeConfig.num_experts",description:`<strong>num_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Number of experts for each NllbMoeSparseMlp layer.`,name:"num_experts"},{anchor:"transformers.NllbMoeConfig.expert_capacity",description:`<strong>expert_capacity</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Number of tokens that can be stored in each expert.`,name:"expert_capacity"},{anchor:"transformers.NllbMoeConfig.encoder_sparse_step",description:`<strong>encoder_sparse_step</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Frequency of the sparse layers in the encoder. 4 means that one out of 4 layers will be sparse.`,name:"encoder_sparse_step"},{anchor:"transformers.NllbMoeConfig.decoder_sparse_step",description:`<strong>decoder_sparse_step</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Frequency of the sparse layers in the decoder. 4 means that one out of 4 layers will be sparse.`,name:"decoder_sparse_step"},{anchor:"transformers.NllbMoeConfig.router_dtype",description:`<strong>router_dtype</strong> (<code>str</code>, <em>optional</em>, default to <code>&quot;float32&quot;</code>) &#x2014;
The <code>dtype</code> used for the routers. It is preferable to keep the <code>dtype</code> to <code>&quot;float32&quot;</code> as specified in the
<em>selective precision</em> discussion in <a href="https://arxiv.org/abs/2101.03961" rel="nofollow">the paper</a>.`,name:"router_dtype"},{anchor:"transformers.NllbMoeConfig.router_ignore_padding_tokens",description:`<strong>router_ignore_padding_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to ignore padding tokens when routing. if <code>False</code>, the padding tokens are not routed to any
experts.`,name:"router_ignore_padding_tokens"},{anchor:"transformers.NllbMoeConfig.router_bias",description:`<strong>router_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the classifier of the router should have a bias.`,name:"router_bias"},{anchor:"transformers.NllbMoeConfig.moe_token_dropout",description:`<strong>moe_token_dropout</strong> (<code>float</code>, <em>optional</em>, default to 0.2) &#x2014;
Masking rate for MoE expert output masking (EOM), which is implemented via a Dropout2d on the expert
outputs.`,name:"moe_token_dropout"},{anchor:"transformers.NllbMoeConfig.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the router logits. Only set to <code>True</code> to get the auxiliary loss when training.`,name:"output_router_logits"},{anchor:"transformers.NllbMoeConfig.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).`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/configuration_nllb_moe.py#L24"}}),R=new mo({props:{anchor:"transformers.NllbMoeConfig.example",$$slots:{default:[Qo]},$$scope:{ctx:z}}}),ye=new Z({props:{title:"NllbMoeTop2Router",local:"transformers.NllbMoeTop2Router",headingTag:"h2"}}),Me=new I({props:{name:"class transformers.NllbMoeTop2Router",anchor:"transformers.NllbMoeTop2Router",parameters:[{name:"config",val:": NllbMoeConfig"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L221"}}),Te=new I({props:{name:"route_tokens",anchor:"transformers.NllbMoeTop2Router.route_tokens",parameters:[{name:"router_logits",val:": Tensor"},{name:"input_dtype",val:": dtype = torch.float32"},{name:"padding_mask",val:": typing.Optional[torch.LongTensor] = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L262"}}),ve=new I({props:{name:"forward",anchor:"transformers.NllbMoeTop2Router.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"padding_mask",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.NllbMoeTop2Router.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
(batch_size, sequence_length, hidden_dim) from which router probabilities are computed.`,name:"hidden_states"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L347",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Index tensor of shape [batch_size, sequence_length] corresponding to the expert selected for each token
using the top1 probabilities of the router.
router_probabilities (<code>torch.Tensor</code> of shape (batch_size, sequence_length, nump_experts)):
Tensor of shape (batch_size, sequence_length, num_experts) corresponding to the probabilities for each
token and expert. Used for routing tokens to experts.
router_logits (<code>torch.Tensor</code> of shape (batch_size, sequence_length))):
Logits tensor of shape (batch_size, sequence_length, num_experts) corresponding to raw router logits.
This is used later for computing router z-loss.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>top_1_mask (<code>torch.Tensor</code> of shape (batch_size, sequence_length))</p>
`}}),ke=new Z({props:{title:"NllbMoeSparseMLP",local:"transformers.NllbMoeSparseMLP",headingTag:"h2"}}),we=new I({props:{name:"class transformers.NllbMoeSparseMLP",anchor:"transformers.NllbMoeSparseMLP",parameters:[{name:"config",val:": NllbMoeConfig"},{name:"ffn_dim",val:": int"},{name:"expert_class",val:": Module = <class 'transformers.models.nllb_moe.modeling_nllb_moe.NllbMoeDenseActDense'>"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L398"}}),xe=new I({props:{name:"forward",anchor:"transformers.NllbMoeSparseMLP.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"padding_mask",val:": typing.Optional[torch.Tensor] = False"}],parametersDescription:[{anchor:"transformers.NllbMoeSparseMLP.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_dim)</code>) &#x2014;
The hidden states`,name:"hidden_states"},{anchor:"transformers.NllbMoeSparseMLP.forward.padding_mask",description:`<strong>padding_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Attention mask. Can be in the causal form or not.`,name:"padding_mask"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L414",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Updated hidden states
router_logits (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, num_experts)</code>):
Needed for computing the loss</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>hidden_states (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_dim)</code>)</p>
`}}),$e=new Z({props:{title:"NllbMoeModel",local:"transformers.NllbMoeModel",headingTag:"h2"}}),Ne=new I({props:{name:"class transformers.NllbMoeModel",anchor:"transformers.NllbMoeModel",parameters:[{name:"config",val:": NllbMoeConfig"}],parametersDescription:[{anchor:"transformers.NllbMoeModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nllb-moe#transformers.NllbMoeConfig">NllbMoeConfig</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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1334"}}),Ce=new I({props:{name:"forward",anchor:"transformers.NllbMoeModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_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"}],parametersDescription:[{anchor:"transformers.NllbMoeModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/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.NllbMoeModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.NllbMoeModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</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#decoder-input-ids">What are decoder input IDs?</a></p>
<p>NllbMoe uses the <code>eos_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).`,name:"decoder_input_ids"},{anchor:"transformers.NllbMoeModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.NllbMoeModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</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:"head_mask"},{anchor:"transformers.NllbMoeModel.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</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:"decoder_head_mask"},{anchor:"transformers.NllbMoeModel.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</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:"cross_attn_head_mask"},{anchor:"transformers.NllbMoeModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>Tuple[Tuple[torch.FloatTensor]]</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) is a sequence of
hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.NllbMoeModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<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, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>;</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.NllbMoeModel.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.NllbMoeModel.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>decoder_input_ids</code> and <code>decoder_inputs_embeds</code> are both unset, <code>decoder_inputs_embeds</code> takes the value
of <code>inputs_embeds</code>.`,name:"decoder_inputs_embeds"},{anchor:"transformers.NllbMoeModel.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.NllbMoeModel.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.NllbMoeModel.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.NllbMoeModel.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the logits of all the routers. They are useful for computing the router loss, and
should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.NllbMoeModel.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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1370",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.modeling_outputs.Seq2SeqMoEModelOutput</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/nllb-moe#transformers.NllbMoeConfig"
>NllbMoeConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the decoder of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>EncoderDecoderCache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.EncoderDecoderCache"
>EncoderDecoderCache</a> instance. For more details, see our <a
  href="https://huggingface.co/docs/transformers/en/kv_cache"
  rel="nofollow"
>kv cache guide</a>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_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 decoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_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 of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>decoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_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>Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.</p>
</li>
<li>
<p><strong>cross_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 of the decoder’s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_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 encoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_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 of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>encoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_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>Router logits of the encoder model, useful to compute the auxiliary loss and the z_loss for the sparse
modules.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.modeling_outputs.Seq2SeqMoEModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),S=new Vo({props:{$$slots:{default:[Ko]},$$scope:{ctx:z}}}),V=new mo({props:{anchor:"transformers.NllbMoeModel.forward.example",$$slots:{default:[en]},$$scope:{ctx:z}}}),ze=new Z({props:{title:"NllbMoeForConditionalGeneration",local:"transformers.NllbMoeForConditionalGeneration",headingTag:"h2"}}),je=new I({props:{name:"class transformers.NllbMoeForConditionalGeneration",anchor:"transformers.NllbMoeForConditionalGeneration",parameters:[{name:"config",val:": NllbMoeConfig"}],parametersDescription:[{anchor:"transformers.NllbMoeForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nllb-moe#transformers.NllbMoeConfig">NllbMoeConfig</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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1487"}}),Ue=new I({props:{name:"forward",anchor:"transformers.NllbMoeForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_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"}],parametersDescription:[{anchor:"transformers.NllbMoeForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/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.NllbMoeForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</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#decoder-input-ids">What are decoder input IDs?</a></p>
<p>NllbMoe uses the <code>eos_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).`,name:"decoder_input_ids"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</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:"head_mask"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</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:"decoder_head_mask"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</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:"cross_attn_head_mask"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>Tuple[Tuple[torch.FloatTensor]]</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) is a sequence of
hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<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, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>;</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.NllbMoeForConditionalGeneration.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.NllbMoeForConditionalGeneration.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>decoder_input_ids</code> and <code>decoder_inputs_embeds</code> are both unset, <code>decoder_inputs_embeds</code> takes the value
of <code>inputs_embeds</code>.`,name:"decoder_inputs_embeds"},{anchor:"transformers.NllbMoeForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.NllbMoeForConditionalGeneration.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.NllbMoeForConditionalGeneration.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.NllbMoeForConditionalGeneration.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.NllbMoeForConditionalGeneration.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the logits of all the routers. They are useful for computing the router loss, and
should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.NllbMoeForConditionalGeneration.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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1518",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.modeling_outputs.Seq2SeqMoEOutput</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/nllb-moe#transformers.NllbMoeConfig"
>NllbMoeConfig</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.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>EncoderDecoderCache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.EncoderDecoderCache"
>EncoderDecoderCache</a> instance. For more details, see our <a
  href="https://huggingface.co/docs/transformers/en/kv_cache"
  rel="nofollow"
>kv cache guide</a>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_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 decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_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 of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>decoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_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>Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.</p>
</li>
<li>
<p><strong>cross_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 of the decoder’s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_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 encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_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 of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>encoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_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>Router logits of the encoder model, useful to compute the auxiliary loss and z_loss for Mixture of Experts
models.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.modeling_outputs.Seq2SeqMoEOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),X=new Vo({props:{$$slots:{default:[tn]},$$scope:{ctx:z}}}),P=new mo({props:{anchor:"transformers.NllbMoeForConditionalGeneration.forward.example",$$slots:{default:[on]},$$scope:{ctx:z}}}),Je=new Ao({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/nllb-moe.md"}}),{c(){d=l("meta"),v=n(),b=l("p"),y=n(),m(M.$$.fragment),c=n(),T=l("div"),T.innerHTML=ho,nt=n(),m(A.$$.fragment),st=n(),Q=l("p"),Q.innerHTML=uo,at=n(),K=l("p"),K.textContent=fo,rt=n(),ee=l("p"),ee.innerHTML=go,lt=n(),te=l("p"),te.innerHTML=_o,it=n(),m(oe.$$.fragment),dt=n(),ne=l("ul"),ne.innerHTML=bo,ct=n(),m(se.$$.fragment),pt=n(),ae=l("p"),ae.innerHTML=yo,mt=n(),m(re.$$.fragment),ht=n(),le=l("p"),le.innerHTML=Mo,ut=n(),ie=l("p"),ie.innerHTML=To,ft=n(),de=l("p"),de.innerHTML=vo,gt=n(),m(ce.$$.fragment),_t=n(),m(pe.$$.fragment),bt=n(),me=l("p"),me.innerHTML=ko,yt=n(),he=l("p"),he.textContent=wo,Mt=n(),m(ue.$$.fragment),Tt=n(),m(fe.$$.fragment),vt=n(),ge=l("ul"),ge.innerHTML=xo,kt=n(),m(_e.$$.fragment),wt=n(),N=l("div"),m(be.$$.fragment),Lt=n(),Ge=l("p"),Ge.innerHTML=$o,qt=n(),Le=l("p"),Le.innerHTML=No,Wt=n(),m(R.$$.fragment),xt=n(),m(ye.$$.fragment),$t=n(),k=l("div"),m(Me.$$.fragment),It=n(),qe=l("p"),qe.textContent=Co,Bt=n(),We=l("p"),We.innerHTML=zo,Rt=n(),Ie=l("p"),Ie.textContent=jo,Et=n(),E=l("div"),m(Te.$$.fragment),Ht=n(),Be=l("p"),Be.innerHTML=Uo,St=n(),H=l("div"),m(ve.$$.fragment),Vt=n(),Re=l("p"),Re.textContent=Jo,Nt=n(),m(ke.$$.fragment),Ct=n(),G=l("div"),m(we.$$.fragment),Xt=n(),Ee=l("p"),Ee.textContent=Fo,Pt=n(),j=l("div"),m(xe.$$.fragment),Yt=n(),He=l("p"),He.innerHTML=Zo,Dt=n(),Se=l("p"),Se.innerHTML=Go,Ot=n(),Ve=l("p"),Ve.textContent=Lo,zt=n(),m($e.$$.fragment),jt=n(),w=l("div"),m(Ne.$$.fragment),At=n(),Xe=l("p"),Xe.textContent=qo,Qt=n(),Pe=l("p"),Pe.innerHTML=Wo,Kt=n(),Ye=l("p"),Ye.innerHTML=Io,eo=n(),U=l("div"),m(Ce.$$.fragment),to=n(),De=l("p"),De.innerHTML=Bo,oo=n(),m(S.$$.fragment),no=n(),m(V.$$.fragment),Ut=n(),m(ze.$$.fragment),Jt=n(),x=l("div"),m(je.$$.fragment),so=n(),Oe=l("p"),Oe.textContent=Ro,ao=n(),Ae=l("p"),Ae.innerHTML=Eo,ro=n(),Qe=l("p"),Qe.innerHTML=Ho,lo=n(),J=l("div"),m(Ue.$$.fragment),io=n(),Ke=l("p"),Ke.innerHTML=So,co=n(),m(X.$$.fragment),po=n(),m(P.$$.fragment),Ft=n(),m(Je.$$.fragment),Zt=n(),et=l("p"),this.h()},l(e){const t=Oo("svelte-u9bgzb",document.head);d=i(t,"META",{name:!0,content:!0}),t.forEach(o),v=s(e),b=i(e,"P",{}),F(b).forEach(o),y=s(e),h(M.$$.fragment,e),c=s(e),T=i(e,"DIV",{class:!0,"data-svelte-h":!0}),p(T)!=="svelte-13t8s2t"&&(T.innerHTML=ho),nt=s(e),h(A.$$.fragment,e),st=s(e),Q=i(e,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-12x4cpm"&&(Q.innerHTML=uo),at=s(e),K=i(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-wu27l3"&&(K.textContent=fo),rt=s(e),ee=i(e,"P",{"data-svelte-h":!0}),p(ee)!=="svelte-1j7uypk"&&(ee.innerHTML=go),lt=s(e),te=i(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-10n1tet"&&(te.innerHTML=_o),it=s(e),h(oe.$$.fragment,e),dt=s(e),ne=i(e,"UL",{"data-svelte-h":!0}),p(ne)!=="svelte-1d7jqov"&&(ne.innerHTML=bo),ct=s(e),h(se.$$.fragment,e),pt=s(e),ae=i(e,"P",{"data-svelte-h":!0}),p(ae)!=="svelte-udi8rb"&&(ae.innerHTML=yo),mt=s(e),h(re.$$.fragment,e),ht=s(e),le=i(e,"P",{"data-svelte-h":!0}),p(le)!=="svelte-19ah26a"&&(le.innerHTML=Mo),ut=s(e),ie=i(e,"P",{"data-svelte-h":!0}),p(ie)!=="svelte-gz9jek"&&(ie.innerHTML=To),ft=s(e),de=i(e,"P",{"data-svelte-h":!0}),p(de)!=="svelte-c2ujwv"&&(de.innerHTML=vo),gt=s(e),h(ce.$$.fragment,e),_t=s(e),h(pe.$$.fragment,e),bt=s(e),me=i(e,"P",{"data-svelte-h":!0}),p(me)!=="svelte-ets0jr"&&(me.innerHTML=ko),yt=s(e),he=i(e,"P",{"data-svelte-h":!0}),p(he)!=="svelte-14hvt1f"&&(he.textContent=wo),Mt=s(e),h(ue.$$.fragment,e),Tt=s(e),h(fe.$$.fragment,e),vt=s(e),ge=i(e,"UL",{"data-svelte-h":!0}),p(ge)!=="svelte-6ej6p2"&&(ge.innerHTML=xo),kt=s(e),h(_e.$$.fragment,e),wt=s(e),N=i(e,"DIV",{class:!0});var L=F(N);h(be.$$.fragment,L),Lt=s(L),Ge=i(L,"P",{"data-svelte-h":!0}),p(Ge)!=="svelte-1l2hikf"&&(Ge.innerHTML=$o),qt=s(L),Le=i(L,"P",{"data-svelte-h":!0}),p(Le)!=="svelte-o55m63"&&(Le.innerHTML=No),Wt=s(L),h(R.$$.fragment,L),L.forEach(o),xt=s(e),h(ye.$$.fragment,e),$t=s(e),k=i(e,"DIV",{class:!0});var $=F(k);h(Me.$$.fragment,$),It=s($),qe=i($,"P",{"data-svelte-h":!0}),p(qe)!=="svelte-1j1lh5i"&&(qe.textContent=Co),Bt=s($),We=i($,"P",{"data-svelte-h":!0}),p(We)!=="svelte-ov8d9x"&&(We.innerHTML=zo),Rt=s($),Ie=i($,"P",{"data-svelte-h":!0}),p(Ie)!=="svelte-1wf6mr8"&&(Ie.textContent=jo),Et=s($),E=i($,"DIV",{class:!0});var Fe=F(E);h(Te.$$.fragment,Fe),Ht=s(Fe),Be=i(Fe,"P",{"data-svelte-h":!0}),p(Be)!=="svelte-xjs57s"&&(Be.innerHTML=Uo),Fe.forEach(o),St=s($),H=i($,"DIV",{class:!0});var Ze=F(H);h(ve.$$.fragment,Ze),Vt=s(Ze),Re=i(Ze,"P",{"data-svelte-h":!0}),p(Re)!=="svelte-19860ws"&&(Re.textContent=Jo),Ze.forEach(o),$.forEach(o),Nt=s(e),h(ke.$$.fragment,e),Ct=s(e),G=i(e,"DIV",{class:!0});var B=F(G);h(we.$$.fragment,B),Xt=s(B),Ee=i(B,"P",{"data-svelte-h":!0}),p(Ee)!=="svelte-35dv9n"&&(Ee.textContent=Fo),Pt=s(B),j=i(B,"DIV",{class:!0});var Y=F(j);h(xe.$$.fragment,Y),Yt=s(Y),He=i(Y,"P",{"data-svelte-h":!0}),p(He)!=="svelte-163dwss"&&(He.innerHTML=Zo),Dt=s(Y),Se=i(Y,"P",{"data-svelte-h":!0}),p(Se)!=="svelte-bpke9a"&&(Se.innerHTML=Go),Ot=s(Y),Ve=i(Y,"P",{"data-svelte-h":!0}),p(Ve)!=="svelte-t4vd7i"&&(Ve.textContent=Lo),Y.forEach(o),B.forEach(o),zt=s(e),h($e.$$.fragment,e),jt=s(e),w=i(e,"DIV",{class:!0});var q=F(w);h(Ne.$$.fragment,q),At=s(q),Xe=i(q,"P",{"data-svelte-h":!0}),p(Xe)!=="svelte-tu0wbz"&&(Xe.textContent=qo),Qt=s(q),Pe=i(q,"P",{"data-svelte-h":!0}),p(Pe)!=="svelte-6pahdo"&&(Pe.innerHTML=Wo),Kt=s(q),Ye=i(q,"P",{"data-svelte-h":!0}),p(Ye)!=="svelte-hswkmf"&&(Ye.innerHTML=Io),eo=s(q),U=i(q,"DIV",{class:!0});var D=F(U);h(Ce.$$.fragment,D),to=s(D),De=i(D,"P",{"data-svelte-h":!0}),p(De)!=="svelte-1ugew6t"&&(De.innerHTML=Bo),oo=s(D),h(S.$$.fragment,D),no=s(D),h(V.$$.fragment,D),D.forEach(o),q.forEach(o),Ut=s(e),h(ze.$$.fragment,e),Jt=s(e),x=i(e,"DIV",{class:!0});var W=F(x);h(je.$$.fragment,W),so=s(W),Oe=i(W,"P",{"data-svelte-h":!0}),p(Oe)!=="svelte-9kghpx"&&(Oe.textContent=Ro),ao=s(W),Ae=i(W,"P",{"data-svelte-h":!0}),p(Ae)!=="svelte-6pahdo"&&(Ae.innerHTML=Eo),ro=s(W),Qe=i(W,"P",{"data-svelte-h":!0}),p(Qe)!=="svelte-hswkmf"&&(Qe.innerHTML=Ho),lo=s(W),J=i(W,"DIV",{class:!0});var O=F(J);h(Ue.$$.fragment,O),io=s(O),Ke=i(O,"P",{"data-svelte-h":!0}),p(Ke)!=="svelte-zf431p"&&(Ke.innerHTML=So),co=s(O),h(X.$$.fragment,O),po=s(O),h(P.$$.fragment,O),O.forEach(o),W.forEach(o),Ft=s(e),h(Je.$$.fragment,e),Zt=s(e),et=i(e,"P",{}),F(et).forEach(o),this.h()},h(){C(d,"name","hf:doc:metadata"),C(d,"content",sn),C(T,"class","flex flex-wrap space-x-1"),C(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(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){r(document.head,d),a(e,v,t),a(e,b,t),a(e,y,t),u(M,e,t),a(e,c,t),a(e,T,t),a(e,nt,t),u(A,e,t),a(e,st,t),a(e,Q,t),a(e,at,t),a(e,K,t),a(e,rt,t),a(e,ee,t),a(e,lt,t),a(e,te,t),a(e,it,t),u(oe,e,t),a(e,dt,t),a(e,ne,t),a(e,ct,t),u(se,e,t),a(e,pt,t),a(e,ae,t),a(e,mt,t),u(re,e,t),a(e,ht,t),a(e,le,t),a(e,ut,t),a(e,ie,t),a(e,ft,t),a(e,de,t),a(e,gt,t),u(ce,e,t),a(e,_t,t),u(pe,e,t),a(e,bt,t),a(e,me,t),a(e,yt,t),a(e,he,t),a(e,Mt,t),u(ue,e,t),a(e,Tt,t),u(fe,e,t),a(e,vt,t),a(e,ge,t),a(e,kt,t),u(_e,e,t),a(e,wt,t),a(e,N,t),u(be,N,null),r(N,Lt),r(N,Ge),r(N,qt),r(N,Le),r(N,Wt),u(R,N,null),a(e,xt,t),u(ye,e,t),a(e,$t,t),a(e,k,t),u(Me,k,null),r(k,It),r(k,qe),r(k,Bt),r(k,We),r(k,Rt),r(k,Ie),r(k,Et),r(k,E),u(Te,E,null),r(E,Ht),r(E,Be),r(k,St),r(k,H),u(ve,H,null),r(H,Vt),r(H,Re),a(e,Nt,t),u(ke,e,t),a(e,Ct,t),a(e,G,t),u(we,G,null),r(G,Xt),r(G,Ee),r(G,Pt),r(G,j),u(xe,j,null),r(j,Yt),r(j,He),r(j,Dt),r(j,Se),r(j,Ot),r(j,Ve),a(e,zt,t),u($e,e,t),a(e,jt,t),a(e,w,t),u(Ne,w,null),r(w,At),r(w,Xe),r(w,Qt),r(w,Pe),r(w,Kt),r(w,Ye),r(w,eo),r(w,U),u(Ce,U,null),r(U,to),r(U,De),r(U,oo),u(S,U,null),r(U,no),u(V,U,null),a(e,Ut,t),u(ze,e,t),a(e,Jt,t),a(e,x,t),u(je,x,null),r(x,so),r(x,Oe),r(x,ao),r(x,Ae),r(x,ro),r(x,Qe),r(x,lo),r(x,J),u(Ue,J,null),r(J,io),r(J,Ke),r(J,co),u(X,J,null),r(J,po),u(P,J,null),a(e,Ft,t),u(Je,e,t),a(e,Zt,t),a(e,et,t),Gt=!0},p(e,[t]){const L={};t&2&&(L.$$scope={dirty:t,ctx:e}),R.$set(L);const $={};t&2&&($.$$scope={dirty:t,ctx:e}),S.$set($);const Fe={};t&2&&(Fe.$$scope={dirty:t,ctx:e}),V.$set(Fe);const Ze={};t&2&&(Ze.$$scope={dirty:t,ctx:e}),X.$set(Ze);const B={};t&2&&(B.$$scope={dirty:t,ctx:e}),P.$set(B)},i(e){Gt||(f(M.$$.fragment,e),f(A.$$.fragment,e),f(oe.$$.fragment,e),f(se.$$.fragment,e),f(re.$$.fragment,e),f(ce.$$.fragment,e),f(pe.$$.fragment,e),f(ue.$$.fragment,e),f(fe.$$.fragment,e),f(_e.$$.fragment,e),f(be.$$.fragment,e),f(R.$$.fragment,e),f(ye.$$.fragment,e),f(Me.$$.fragment,e),f(Te.$$.fragment,e),f(ve.$$.fragment,e),f(ke.$$.fragment,e),f(we.$$.fragment,e),f(xe.$$.fragment,e),f($e.$$.fragment,e),f(Ne.$$.fragment,e),f(Ce.$$.fragment,e),f(S.$$.fragment,e),f(V.$$.fragment,e),f(ze.$$.fragment,e),f(je.$$.fragment,e),f(Ue.$$.fragment,e),f(X.$$.fragment,e),f(P.$$.fragment,e),f(Je.$$.fragment,e),Gt=!0)},o(e){g(M.$$.fragment,e),g(A.$$.fragment,e),g(oe.$$.fragment,e),g(se.$$.fragment,e),g(re.$$.fragment,e),g(ce.$$.fragment,e),g(pe.$$.fragment,e),g(ue.$$.fragment,e),g(fe.$$.fragment,e),g(_e.$$.fragment,e),g(be.$$.fragment,e),g(R.$$.fragment,e),g(ye.$$.fragment,e),g(Me.$$.fragment,e),g(Te.$$.fragment,e),g(ve.$$.fragment,e),g(ke.$$.fragment,e),g(we.$$.fragment,e),g(xe.$$.fragment,e),g($e.$$.fragment,e),g(Ne.$$.fragment,e),g(Ce.$$.fragment,e),g(S.$$.fragment,e),g(V.$$.fragment,e),g(ze.$$.fragment,e),g(je.$$.fragment,e),g(Ue.$$.fragment,e),g(X.$$.fragment,e),g(P.$$.fragment,e),g(Je.$$.fragment,e),Gt=!1},d(e){e&&(o(v),o(b),o(y),o(c),o(T),o(nt),o(st),o(Q),o(at),o(K),o(rt),o(ee),o(lt),o(te),o(it),o(dt),o(ne),o(ct),o(pt),o(ae),o(mt),o(ht),o(le),o(ut),o(ie),o(ft),o(de),o(gt),o(_t),o(bt),o(me),o(yt),o(he),o(Mt),o(Tt),o(vt),o(ge),o(kt),o(wt),o(N),o(xt),o($t),o(k),o(Nt),o(Ct),o(G),o(zt),o(jt),o(w),o(Ut),o(Jt),o(x),o(Ft),o(Zt),o(et)),o(d),_(M,e),_(A,e),_(oe,e),_(se,e),_(re,e),_(ce,e),_(pe,e),_(ue,e),_(fe,e),_(_e,e),_(be),_(R),_(ye,e),_(Me),_(Te),_(ve),_(ke,e),_(we),_(xe),_($e,e),_(Ne),_(Ce),_(S),_(V),_(ze,e),_(je),_(Ue),_(X),_(P),_(Je,e)}}}const sn='{"title":"NLLB-MOE","local":"nllb-moe","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Implementation differences with SwitchTransformers","local":"implementation-differences-with-switchtransformers","sections":[],"depth":2},{"title":"Generating with NLLB-MoE","local":"generating-with-nllb-moe","sections":[{"title":"Generating from any other language than English","local":"generating-from-any-other-language-than-english","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"NllbMoeConfig","local":"transformers.NllbMoeConfig","sections":[],"depth":2},{"title":"NllbMoeTop2Router","local":"transformers.NllbMoeTop2Router","sections":[],"depth":2},{"title":"NllbMoeSparseMLP","local":"transformers.NllbMoeSparseMLP","sections":[],"depth":2},{"title":"NllbMoeModel","local":"transformers.NllbMoeModel","sections":[],"depth":2},{"title":"NllbMoeForConditionalGeneration","local":"transformers.NllbMoeForConditionalGeneration","sections":[],"depth":2}],"depth":1}';function an(z){return Po(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fn extends Yo{constructor(d){super(),Do(this,d,an,nn,Xo,{})}}export{fn as component};
