import{S as tl,i as nl,s as rl,e as n,k as h,w as v,t as s,M as al,c as r,d as t,m as p,a,x as y,h as i,b as l,G as e,g as u,y as w,q as k,o as T,B as M,v as sl,L as qs}from"../../chunks/vendor-hf-doc-builder.js";import{T as Es}from"../../chunks/Tip-hf-doc-builder.js";import{D as J}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Rt}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as G}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as zs}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function il(z){let f,$,_,g,b;return g=new Rt({props:{code:`from transformers import NllbMoeModel, NllbMoeConfig

# Initializing a NllbMoe facebook/nllb-moe-54b style configuration
configuration = NllbMoeConfig()

# Initializing a model from the facebook/nllb-moe-54b style configuration
model = NllbMoeModel(configuration)

# Accessing the model configuration
configuration = model.config`,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`}}),{c(){f=n("p"),$=s("Example:"),_=h(),v(g.$$.fragment)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Example:"),m.forEach(t),_=p(c),y(g.$$.fragment,c)},m(c,m){u(c,f,m),e(f,$),u(c,_,m),w(g,c,m),b=!0},p:qs,i(c){b||(k(g.$$.fragment,c),b=!0)},o(c){T(g.$$.fragment,c),b=!1},d(c){c&&t(f),c&&t(_),M(g,c)}}}function ll(z){let f,$,_,g,b;return{c(){f=n("p"),$=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),g=s("Module"),b=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(m,"CODE",{});var q=a(_);g=i(q,"Module"),q.forEach(t),b=i(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(c,m){u(c,f,m),e(f,$),e(f,_),e(_,g),e(f,b)},d(c){c&&t(f)}}}function dl(z){let f,$,_,g,b;return{c(){f=n("p"),$=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),g=s("Module"),b=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(m,"CODE",{});var q=a(_);g=i(q,"Module"),q.forEach(t),b=i(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(c,m){u(c,f,m),e(f,$),e(f,_),e(_,g),e(f,b)},d(c){c&&t(f)}}}function cl(z){let f,$,_,g,b;return g=new Rt({props:{code:`from transformers import AutoTokenizer, NllbMoeModel

tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/random-nllb-moe-2-experts")
model = SwitchTransformersModel.from_pretrained("hf-internal-testing/random-nllb-moe-2-experts")

input_ids = tokenizer(
    "Studies have been shown that owning a dog is good for you", return_tensors="pt"
).input_ids  # Batch size 1
decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids  # Batch size 1

# preprocess: Prepend decoder_input_ids with start token which is pad token for NllbMoeModel
decoder_input_ids = model._shift_right(decoder_input_ids)

# forward pass
outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
last_hidden_states = outputs.last_hidden_state`,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`}}),{c(){f=n("p"),$=s("Example:"),_=h(),v(g.$$.fragment)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Example:"),m.forEach(t),_=p(c),y(g.$$.fragment,c)},m(c,m){u(c,f,m),e(f,$),u(c,_,m),w(g,c,m),b=!0},p:qs,i(c){b||(k(g.$$.fragment,c),b=!0)},o(c){T(g.$$.fragment,c),b=!1},d(c){c&&t(f),c&&t(_),M(g,c)}}}function hl(z){let f,$,_,g,b;return{c(){f=n("p"),$=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),g=s("Module"),b=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(m,"CODE",{});var q=a(_);g=i(q,"Module"),q.forEach(t),b=i(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(c,m){u(c,f,m),e(f,$),e(f,_),e(_,g),e(f,b)},d(c){c&&t(f)}}}function pl(z){let f,$,_,g,b;return g=new Rt({props:{code:`from transformers import AutoTokenizer, NllbMoeForConditionalGeneration

model = NllbMoeForConditionalGeneration.from_pretrained("facebook/nllb-moe-54b")
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-moe-54b")

text_to_translate = "Life is like a box of chocolates"
model_inputs = tokenizer(text_to_translate, return_tensors="pt")

# translate to French
gen_tokens = model.generate(**model_inputs, forced_bos_token_id=tokenizer.get_lang_id("eng_Latn"))
print(tokenizer.batch_decode(gen_tokens, skip_special_tokens=True))`,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>))`}}),{c(){f=n("p"),$=s("Translation example:"),_=h(),v(g.$$.fragment)},l(c){f=r(c,"P",{});var m=a(f);$=i(m,"Translation example:"),m.forEach(t),_=p(c),y(g.$$.fragment,c)},m(c,m){u(c,f,m),e(f,$),u(c,_,m),w(g,c,m),b=!0},p:qs,i(c){b||(k(g.$$.fragment,c),b=!0)},o(c){T(g.$$.fragment,c),b=!1},d(c){c&&t(f),c&&t(_),M(g,c)}}}function ul(z){let f,$,_,g,b,c,m,q,Dn,Ht,U,de,Ho,Se,Gn,Wo,Bn,Wt,ce,In,Pe,Rn,Hn,Jt,bo,Wn,Ut,vo,Jo,Jn,Vt,yo,Un,Kt,B,Uo,Vn,Kn,Vo,Zn,Xn,Ko,Yn,Zt,I,Qn,Ae,er,or,je,tr,nr,Xt,V,he,Zo,Oe,rr,Xo,ar,Yt,K,pe,Yo,De,sr,Qo,ir,Qt,R,lr,et,dr,cr,ot,hr,pr,en,H,ur,tt,fr,mr,Ge,gr,_r,on,Be,tn,Z,ue,nt,Ie,br,rt,vr,nn,W,yr,at,wr,kr,st,Tr,Mr,rn,wo,$r,an,Re,sn,X,fe,it,He,Nr,lt,xr,ln,me,dt,ko,Er,zr,ct,To,qr,dn,Y,ge,ht,We,Cr,pt,Lr,cn,L,Je,Fr,Q,Sr,Mo,Pr,Ar,Ue,jr,Or,Dr,ee,Gr,$o,Br,Ir,No,Rr,Hr,Wr,_e,hn,oe,be,ut,Ve,Jr,ft,Ur,pn,N,Ke,Vr,mt,Kr,Zr,Ze,Xr,gt,Yr,Qr,ea,_t,oa,ta,ve,Xe,na,te,ra,bt,aa,sa,vt,ia,la,da,ye,Ye,ca,yt,ha,un,ne,we,wt,Qe,pa,kt,ua,fn,D,eo,fa,Tt,ma,ga,P,oo,_a,to,ba,Mt,va,ya,wa,x,ka,$t,Ta,Ma,Nt,$a,Na,xt,xa,Ea,Et,za,qa,zt,Ca,La,qt,Fa,Sa,Pa,Ct,Aa,mn,re,ke,Lt,no,ja,Ft,Oa,gn,F,ro,Da,ao,Ga,xo,Ba,Ia,Ra,so,Ha,io,Wa,Ja,Ua,E,lo,Va,ae,Ka,Eo,Za,Xa,St,Ya,Qa,es,Te,os,se,ts,zo,ns,rs,Pt,as,ss,is,Me,ls,$e,_n,ie,Ne,At,co,ds,jt,cs,bn,S,ho,hs,po,ps,qo,us,fs,ms,uo,gs,fo,_s,bs,vs,A,mo,ys,le,ws,Co,ks,Ts,Ot,Ms,$s,Ns,xe,xs,Ee,vn;return c=new G({}),Se=new G({}),Oe=new G({}),De=new G({}),Be=new Rt({props:{code:`from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-moe-54b")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-moe-54b")

article = "Previously, Ring's CEO, Jamie Siminoff, remarked the company started when his doorbell wasn't audible from his shop in his garage."
inputs = tokenizer(article, return_tensors="pt")

translated_tokens = model.generate(
    **inputs, forced_bos_token_id=tokenizer.lang_code_to_id["fra_Latn"], max_length=50
)
tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]`,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\xE9t\xE9 avait commenc\xE9 lorsque sa sonnette n&#x27;\xE9tait pas audible depuis son magasin dans son garage.&quot;</span>`}}),Ie=new G({}),Re=new Rt({props:{code:`from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-moe-54b", src_lang="ron_Latn")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-moe-54b")

article = "\u015Eeful ONU spune c\u0103 nu exist\u0103 o solu\u0163ie militar\u0103 \xEEn Siria"
inputs = tokenizer(article, return_tensors="pt")

translated_tokens = model.generate(
    **inputs, forced_bos_token_id=tokenizer.lang_code_to_id["deu_Latn"], max_length=30
)
tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]`,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;\u015Eeful ONU spune c\u0103 nu exist\u0103 o solu\u0163ie militar\u0103 \xEEn 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>]`}}),He=new G({}),We=new G({}),Je=new J({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/v4.29.0/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>, defualt ot 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/v4.29.0/src/transformers/models/nllb_moe/configuration_nllb_moe.py#L27"}}),_e=new zs({props:{anchor:"transformers.NllbMoeConfig.example",$$slots:{default:[il]},$$scope:{ctx:z}}}),Ve=new G({}),Ke=new J({props:{name:"class transformers.NllbMoeTop2Router",anchor:"transformers.NllbMoeTop2Router",parameters:[{name:"config",val:": NllbMoeConfig"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L249"}}),Xe=new J({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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L290"}}),Ye=new J({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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L375",returnDescription:`
<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:`
<p>top_1_mask (<code>torch.Tensor</code> of shape (batch_size, sequence_length))</p>
`}}),Qe=new G({}),eo=new J({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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L426"}}),oo=new J({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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L442",returnDescription:`
<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:`
<p>hidden_states (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_dim)</code>)</p>
`}}),no=new G({}),ro=new J({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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1503"}}),lo=new J({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>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.`,name:"input_ids"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1539",returnDescription:`
<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/v4.29.0/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>) \u2014 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>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>) \u2014 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>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 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\u2019s 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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 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:`
<p><code>transformers.modeling_outputs.Seq2SeqMoEModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Te=new Es({props:{$$slots:{default:[ll]},$$scope:{ctx:z}}}),Me=new Es({props:{$$slots:{default:[dl]},$$scope:{ctx:z}}}),$e=new zs({props:{anchor:"transformers.NllbMoeModel.forward.example",$$slots:{default:[cl]},$$scope:{ctx:z}}}),co=new G({}),ho=new J({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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1642"}}),mo=new J({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>) &#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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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>(encoder_layers, encoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the encoder. 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>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
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>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</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>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_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>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{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.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/v4.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/nllb_moe/modeling_nllb_moe.py#L1682",returnDescription:`
<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/v4.29.0/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) \u2014 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>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</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>) \u2014 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>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 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\u2019s 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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 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:`
<p><code>transformers.modeling_outputs.Seq2SeqMoEOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xe=new Es({props:{$$slots:{default:[hl]},$$scope:{ctx:z}}}),Ee=new zs({props:{anchor:"transformers.NllbMoeForConditionalGeneration.forward.example",$$slots:{default:[pl]},$$scope:{ctx:z}}}),{c(){f=n("meta"),$=h(),_=n("h1"),g=n("a"),b=n("span"),v(c.$$.fragment),m=h(),q=n("span"),Dn=s("NLLB-MOE"),Ht=h(),U=n("h2"),de=n("a"),Ho=n("span"),v(Se.$$.fragment),Gn=h(),Wo=n("span"),Bn=s("Overview"),Wt=h(),ce=n("p"),In=s("The NLLB model was presented in "),Pe=n("a"),Rn=s("No Language Left Behind: Scaling Human-Centered Machine Translation"),Hn=s(` by Marta R. Costa-juss\xE0, James Cross, Onur \xC7elebi,
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\xE1n, Philipp Koehn, Alexandre Mourachko, Christophe Ropers,
Safiyyah Saleem, Holger Schwenk, and Jeff Wang.`),Jt=h(),bo=n("p"),Wn=s("The abstract of the paper is the following:"),Ut=h(),vo=n("p"),Jo=n("em"),Jn=s(`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.`),Vt=h(),yo=n("p"),Un=s("Tips:"),Kt=h(),B=n("ul"),Uo=n("li"),Vn=s("M2M100ForConditionalGeneration is the base model for both NLLB and NLLB MoE"),Kn=h(),Vo=n("li"),Zn=s("The NLLB-MoE is very similar to the NLLB model, but it\u2019s feed forward layer is based on the implementation of SwitchTransformers."),Xn=h(),Ko=n("li"),Yn=s("The tokenizer is the same as the NLLB models."),Zt=h(),I=n("p"),Qn=s("This model was contributed by "),Ae=n("a"),er=s("Arthur Zucker"),or=s(`.
The original code can be found `),je=n("a"),tr=s("here"),nr=s("."),Xt=h(),V=n("h2"),he=n("a"),Zo=n("span"),v(Oe.$$.fragment),rr=h(),Xo=n("span"),ar=s("Implementation differences with SwitchTransformers"),Yt=s("\n\nThe biggest difference is the way the tokens are routed. NLLB-MoE uses a `top-2-gate` which means that for each input, only the top two experts are selected based on the \nhighest predicted probabilities from the gating network, and the remaining experts are ignored. In `SwitchTransformers`, only the top-1 probabilities are computed, \nwhich means that tokens have less probability of being forwarded. Moreover, if a token is not routed to any expert, `SwitchTransformers` still adds its unmodified hidden \nstates (kind of like a residual connection) while they are masked in `NLLB`'s top-2 routing mechanism.\n"),K=n("h2"),pe=n("a"),Yo=n("span"),v(De.$$.fragment),sr=h(),Qo=n("span"),ir=s("Generating with NLLB-MoE"),Qt=s(`

The avalable checkpoints requires around 350GB of storage. Make sure to use \`accelerate\` if you do not have enough RAM on your machine.
`),R=n("p"),lr=s("While generating the target text set the "),et=n("code"),dr=s("forced_bos_token_id"),cr=s(` to the target language id. The following
example shows how to translate English to French using the `),ot=n("em"),hr=s("facebook/nllb-200-distilled-600M"),pr=s(" model."),en=h(),H=n("p"),ur=s("Note that we\u2019re using the BCP-47 code for French "),tt=n("code"),fr=s("fra_Latn"),mr=s(". See "),Ge=n("a"),gr=s("here"),_r=s(`
for the list of all BCP-47 in the Flores 200 dataset.`),on=h(),v(Be.$$.fragment),tn=h(),Z=n("h3"),ue=n("a"),nt=n("span"),v(Ie.$$.fragment),br=h(),rt=n("span"),vr=s("Generating from any other language than English"),nn=h(),W=n("p"),yr=s("English ("),at=n("code"),wr=s("eng_Latn"),kr=s(`) is set as the default language from which to translate. In order to specify that you\u2019d like to translate from a different language,
you should specify the BCP-47 code in the `),st=n("code"),Tr=s("src_lang"),Mr=s(" keyword argument of the tokenizer initialization."),rn=h(),wo=n("p"),$r=s("See example below for a translation from romanian to german:"),an=h(),v(Re.$$.fragment),sn=h(),X=n("h2"),fe=n("a"),it=n("span"),v(He.$$.fragment),Nr=h(),lt=n("span"),xr=s("Documentation resources"),ln=h(),me=n("ul"),dt=n("li"),ko=n("a"),Er=s("Translation task guide"),zr=h(),ct=n("li"),To=n("a"),qr=s("Summarization task guide"),dn=h(),Y=n("h2"),ge=n("a"),ht=n("span"),v(We.$$.fragment),Cr=h(),pt=n("span"),Lr=s("NllbMoeConfig"),cn=h(),L=n("div"),v(Je.$$.fragment),Fr=h(),Q=n("p"),Sr=s("This is the configuration class to store the configuration of a "),Mo=n("a"),Pr=s("NllbMoeModel"),Ar=s(`. 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
`),Ue=n("a"),jr=s("facebook/nllb-moe-54b"),Or=s(" architecture."),Dr=h(),ee=n("p"),Gr=s("Configuration objects inherit from "),$o=n("a"),Br=s("PretrainedConfig"),Ir=s(` and can be used to control the model outputs. Read the
documentation from `),No=n("a"),Rr=s("PretrainedConfig"),Hr=s(" for more information."),Wr=h(),v(_e.$$.fragment),hn=h(),oe=n("h2"),be=n("a"),ut=n("span"),v(Ve.$$.fragment),Jr=h(),ft=n("span"),Ur=s("NllbMoeTop2Router"),pn=h(),N=n("div"),v(Ke.$$.fragment),Vr=h(),mt=n("p"),Kr=s("Router using tokens choose top-2 experts assignment."),Zr=h(),Ze=n("p"),Xr=s(`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\u2019s expert_capacity is reached. `),gt=n("strong"),Yr=s(`There is no guarantee
that each token is processed by an expert`),Qr=s(", or that each expert receives at least one token."),ea=h(),_t=n("p"),oa=s("The router combining weights are also returned to make sure that the states that are not updated will be masked."),ta=h(),ve=n("div"),v(Xe.$$.fragment),na=h(),te=n("p"),ra=s("Computes the "),bt=n("code"),aa=s("dispatch_mask"),sa=s(" and the "),vt=n("code"),ia=s("dispatch_weights"),la=s(` for each experts. The masks are adapted to the expert
capacity.`),da=h(),ye=n("div"),v(Ye.$$.fragment),ca=h(),yt=n("p"),ha=s(`The hidden states are reshaped to simplify the computation of the router probabilities (combining weights for
each experts.)`),un=h(),ne=n("h2"),we=n("a"),wt=n("span"),v(Qe.$$.fragment),pa=h(),kt=n("span"),ua=s("NllbMoeSparseMLP"),fn=h(),D=n("div"),v(eo.$$.fragment),fa=h(),Tt=n("p"),ma=s("Implementation of the NLLB-MoE sparse MLP module."),ga=h(),P=n("div"),v(oo.$$.fragment),_a=h(),to=n("p"),ba=s("The goal of this forward pass is to have the same number of operation as the equivalent "),Mt=n("code"),va=s("NllbMoeDenseActDense"),ya=s(`
(mlp) layer. This means that all of the hidden states should be processed at most twice ( since we are using a
top_2 gating mecanism). 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).`),wa=h(),x=n("p"),ka=s("1- Get the "),$t=n("code"),Ta=s("router_probs"),Ma=s(" from the "),Nt=n("code"),$a=s("router"),Na=s(". The shape of the "),xt=n("code"),xa=s("router_mask"),Ea=s(" is "),Et=n("code"),za=s("(batch_size X sequence_length, num_expert)"),qa=s(" and corresponds to the boolean version of the "),zt=n("code"),Ca=s("router_probs"),La=s(`. The inputs are masked using the
`),qt=n("code"),Fa=s("router_mask"),Sa=s("."),Pa=h(),Ct=n("p"),Aa=s(`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.`),mn=h(),re=n("h2"),ke=n("a"),Lt=n("span"),v(no.$$.fragment),ja=h(),Ft=n("span"),Oa=s("NllbMoeModel"),gn=h(),F=n("div"),v(ro.$$.fragment),Da=h(),ao=n("p"),Ga=s(`The bare NllbMoe Model outputting raw hidden-states without any specific head on top.
This model inherits from `),xo=n("a"),Ba=s("PreTrainedModel"),Ia=s(`. 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.)`),Ra=h(),so=n("p"),Ha=s("This model is also a PyTorch "),io=n("a"),Wa=s("torch.nn.Module"),Ja=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ua=h(),E=n("div"),v(lo.$$.fragment),Va=h(),ae=n("p"),Ka=s("The "),Eo=n("a"),Za=s("NllbMoeModel"),Xa=s(" forward method, overrides the "),St=n("code"),Ya=s("__call__"),Qa=s(" special method."),es=h(),v(Te.$$.fragment),os=h(),se=n("p"),ts=s("The "),zo=n("a"),ns=s("NllbMoeModel"),rs=s(" forward method, overrides the "),Pt=n("code"),as=s("__call__"),ss=s(" special method."),is=h(),v(Me.$$.fragment),ls=h(),v($e.$$.fragment),_n=h(),ie=n("h2"),Ne=n("a"),At=n("span"),v(co.$$.fragment),ds=h(),jt=n("span"),cs=s("NllbMoeForConditionalGeneration"),bn=h(),S=n("div"),v(ho.$$.fragment),hs=h(),po=n("p"),ps=s(`The NllbMoe Model with a language modeling head. Can be used for summarization.
This model inherits from `),qo=n("a"),us=s("PreTrainedModel"),fs=s(`. 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.)`),ms=h(),uo=n("p"),gs=s("This model is also a PyTorch "),fo=n("a"),_s=s("torch.nn.Module"),bs=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),vs=h(),A=n("div"),v(mo.$$.fragment),ys=h(),le=n("p"),ws=s("The "),Co=n("a"),ks=s("NllbMoeForConditionalGeneration"),Ts=s(" forward method, overrides the "),Ot=n("code"),Ms=s("__call__"),$s=s(" special method."),Ns=h(),v(xe.$$.fragment),xs=h(),v(Ee.$$.fragment),this.h()},l(o){const d=al('[data-svelte="svelte-1phssyn"]',document.head);f=r(d,"META",{name:!0,content:!0}),d.forEach(t),$=p(o),_=r(o,"H1",{class:!0});var go=a(_);g=r(go,"A",{id:!0,class:!0,href:!0});var Dt=a(g);b=r(Dt,"SPAN",{});var Gt=a(b);y(c.$$.fragment,Gt),Gt.forEach(t),Dt.forEach(t),m=p(go),q=r(go,"SPAN",{});var Bt=a(q);Dn=i(Bt,"NLLB-MOE"),Bt.forEach(t),go.forEach(t),Ht=p(o),U=r(o,"H2",{class:!0});var _o=a(U);de=r(_o,"A",{id:!0,class:!0,href:!0});var It=a(de);Ho=r(It,"SPAN",{});var Cs=a(Ho);y(Se.$$.fragment,Cs),Cs.forEach(t),It.forEach(t),Gn=p(_o),Wo=r(_o,"SPAN",{});var Ls=a(Wo);Bn=i(Ls,"Overview"),Ls.forEach(t),_o.forEach(t),Wt=p(o),ce=r(o,"P",{});var yn=a(ce);In=i(yn,"The NLLB model was presented in "),Pe=r(yn,"A",{href:!0,rel:!0});var Fs=a(Pe);Rn=i(Fs,"No Language Left Behind: Scaling Human-Centered Machine Translation"),Fs.forEach(t),Hn=i(yn,` by Marta R. Costa-juss\xE0, James Cross, Onur \xC7elebi,
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\xE1n, Philipp Koehn, Alexandre Mourachko, Christophe Ropers,
Safiyyah Saleem, Holger Schwenk, and Jeff Wang.`),yn.forEach(t),Jt=p(o),bo=r(o,"P",{});var Ss=a(bo);Wn=i(Ss,"The abstract of the paper is the following:"),Ss.forEach(t),Ut=p(o),vo=r(o,"P",{});var Ps=a(vo);Jo=r(Ps,"EM",{});var As=a(Jo);Jn=i(As,`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.`),As.forEach(t),Ps.forEach(t),Vt=p(o),yo=r(o,"P",{});var js=a(yo);Un=i(js,"Tips:"),js.forEach(t),Kt=p(o),B=r(o,"UL",{});var Lo=a(B);Uo=r(Lo,"LI",{});var Os=a(Uo);Vn=i(Os,"M2M100ForConditionalGeneration is the base model for both NLLB and NLLB MoE"),Os.forEach(t),Kn=p(Lo),Vo=r(Lo,"LI",{});var Ds=a(Vo);Zn=i(Ds,"The NLLB-MoE is very similar to the NLLB model, but it\u2019s feed forward layer is based on the implementation of SwitchTransformers."),Ds.forEach(t),Xn=p(Lo),Ko=r(Lo,"LI",{});var Gs=a(Ko);Yn=i(Gs,"The tokenizer is the same as the NLLB models."),Gs.forEach(t),Lo.forEach(t),Zt=p(o),I=r(o,"P",{});var Fo=a(I);Qn=i(Fo,"This model was contributed by "),Ae=r(Fo,"A",{href:!0,rel:!0});var Bs=a(Ae);er=i(Bs,"Arthur Zucker"),Bs.forEach(t),or=i(Fo,`.
The original code can be found `),je=r(Fo,"A",{href:!0,rel:!0});var Is=a(je);tr=i(Is,"here"),Is.forEach(t),nr=i(Fo,"."),Fo.forEach(t),Xt=p(o),V=r(o,"H2",{class:!0});var wn=a(V);he=r(wn,"A",{id:!0,class:!0,href:!0});var Rs=a(he);Zo=r(Rs,"SPAN",{});var Hs=a(Zo);y(Oe.$$.fragment,Hs),Hs.forEach(t),Rs.forEach(t),rr=p(wn),Xo=r(wn,"SPAN",{});var Ws=a(Xo);ar=i(Ws,"Implementation differences with SwitchTransformers"),Ws.forEach(t),wn.forEach(t),Yt=i(o,"\n\nThe biggest difference is the way the tokens are routed. NLLB-MoE uses a `top-2-gate` which means that for each input, only the top two experts are selected based on the \nhighest predicted probabilities from the gating network, and the remaining experts are ignored. In `SwitchTransformers`, only the top-1 probabilities are computed, \nwhich means that tokens have less probability of being forwarded. Moreover, if a token is not routed to any expert, `SwitchTransformers` still adds its unmodified hidden \nstates (kind of like a residual connection) while they are masked in `NLLB`'s top-2 routing mechanism.\n"),K=r(o,"H2",{class:!0});var kn=a(K);pe=r(kn,"A",{id:!0,class:!0,href:!0});var Js=a(pe);Yo=r(Js,"SPAN",{});var Us=a(Yo);y(De.$$.fragment,Us),Us.forEach(t),Js.forEach(t),sr=p(kn),Qo=r(kn,"SPAN",{});var Vs=a(Qo);ir=i(Vs,"Generating with NLLB-MoE"),Vs.forEach(t),kn.forEach(t),Qt=i(o,`

The avalable checkpoints requires around 350GB of storage. Make sure to use \`accelerate\` if you do not have enough RAM on your machine.
`),R=r(o,"P",{});var So=a(R);lr=i(So,"While generating the target text set the "),et=r(So,"CODE",{});var Ks=a(et);dr=i(Ks,"forced_bos_token_id"),Ks.forEach(t),cr=i(So,` to the target language id. The following
example shows how to translate English to French using the `),ot=r(So,"EM",{});var Zs=a(ot);hr=i(Zs,"facebook/nllb-200-distilled-600M"),Zs.forEach(t),pr=i(So," model."),So.forEach(t),en=p(o),H=r(o,"P",{});var Po=a(H);ur=i(Po,"Note that we\u2019re using the BCP-47 code for French "),tt=r(Po,"CODE",{});var Xs=a(tt);fr=i(Xs,"fra_Latn"),Xs.forEach(t),mr=i(Po,". See "),Ge=r(Po,"A",{href:!0,rel:!0});var Ys=a(Ge);gr=i(Ys,"here"),Ys.forEach(t),_r=i(Po,`
for the list of all BCP-47 in the Flores 200 dataset.`),Po.forEach(t),on=p(o),y(Be.$$.fragment,o),tn=p(o),Z=r(o,"H3",{class:!0});var Tn=a(Z);ue=r(Tn,"A",{id:!0,class:!0,href:!0});var Qs=a(ue);nt=r(Qs,"SPAN",{});var ei=a(nt);y(Ie.$$.fragment,ei),ei.forEach(t),Qs.forEach(t),br=p(Tn),rt=r(Tn,"SPAN",{});var oi=a(rt);vr=i(oi,"Generating from any other language than English"),oi.forEach(t),Tn.forEach(t),nn=p(o),W=r(o,"P",{});var Ao=a(W);yr=i(Ao,"English ("),at=r(Ao,"CODE",{});var ti=a(at);wr=i(ti,"eng_Latn"),ti.forEach(t),kr=i(Ao,`) is set as the default language from which to translate. In order to specify that you\u2019d like to translate from a different language,
you should specify the BCP-47 code in the `),st=r(Ao,"CODE",{});var ni=a(st);Tr=i(ni,"src_lang"),ni.forEach(t),Mr=i(Ao," keyword argument of the tokenizer initialization."),Ao.forEach(t),rn=p(o),wo=r(o,"P",{});var ri=a(wo);$r=i(ri,"See example below for a translation from romanian to german:"),ri.forEach(t),an=p(o),y(Re.$$.fragment,o),sn=p(o),X=r(o,"H2",{class:!0});var Mn=a(X);fe=r(Mn,"A",{id:!0,class:!0,href:!0});var ai=a(fe);it=r(ai,"SPAN",{});var si=a(it);y(He.$$.fragment,si),si.forEach(t),ai.forEach(t),Nr=p(Mn),lt=r(Mn,"SPAN",{});var ii=a(lt);xr=i(ii,"Documentation resources"),ii.forEach(t),Mn.forEach(t),ln=p(o),me=r(o,"UL",{});var $n=a(me);dt=r($n,"LI",{});var li=a(dt);ko=r(li,"A",{href:!0});var di=a(ko);Er=i(di,"Translation task guide"),di.forEach(t),li.forEach(t),zr=p($n),ct=r($n,"LI",{});var ci=a(ct);To=r(ci,"A",{href:!0});var hi=a(To);qr=i(hi,"Summarization task guide"),hi.forEach(t),ci.forEach(t),$n.forEach(t),dn=p(o),Y=r(o,"H2",{class:!0});var Nn=a(Y);ge=r(Nn,"A",{id:!0,class:!0,href:!0});var pi=a(ge);ht=r(pi,"SPAN",{});var ui=a(ht);y(We.$$.fragment,ui),ui.forEach(t),pi.forEach(t),Cr=p(Nn),pt=r(Nn,"SPAN",{});var fi=a(pt);Lr=i(fi,"NllbMoeConfig"),fi.forEach(t),Nn.forEach(t),cn=p(o),L=r(o,"DIV",{class:!0});var ze=a(L);y(Je.$$.fragment,ze),Fr=p(ze),Q=r(ze,"P",{});var jo=a(Q);Sr=i(jo,"This is the configuration class to store the configuration of a "),Mo=r(jo,"A",{href:!0});var mi=a(Mo);Pr=i(mi,"NllbMoeModel"),mi.forEach(t),Ar=i(jo,`. 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
`),Ue=r(jo,"A",{href:!0,rel:!0});var gi=a(Ue);jr=i(gi,"facebook/nllb-moe-54b"),gi.forEach(t),Or=i(jo," architecture."),jo.forEach(t),Dr=p(ze),ee=r(ze,"P",{});var Oo=a(ee);Gr=i(Oo,"Configuration objects inherit from "),$o=r(Oo,"A",{href:!0});var _i=a($o);Br=i(_i,"PretrainedConfig"),_i.forEach(t),Ir=i(Oo,` and can be used to control the model outputs. Read the
documentation from `),No=r(Oo,"A",{href:!0});var bi=a(No);Rr=i(bi,"PretrainedConfig"),bi.forEach(t),Hr=i(Oo," for more information."),Oo.forEach(t),Wr=p(ze),y(_e.$$.fragment,ze),ze.forEach(t),hn=p(o),oe=r(o,"H2",{class:!0});var xn=a(oe);be=r(xn,"A",{id:!0,class:!0,href:!0});var vi=a(be);ut=r(vi,"SPAN",{});var yi=a(ut);y(Ve.$$.fragment,yi),yi.forEach(t),vi.forEach(t),Jr=p(xn),ft=r(xn,"SPAN",{});var wi=a(ft);Ur=i(wi,"NllbMoeTop2Router"),wi.forEach(t),xn.forEach(t),pn=p(o),N=r(o,"DIV",{class:!0});var j=a(N);y(Ke.$$.fragment,j),Vr=p(j),mt=r(j,"P",{});var ki=a(mt);Kr=i(ki,"Router using tokens choose top-2 experts assignment."),ki.forEach(t),Zr=p(j),Ze=r(j,"P",{});var En=a(Ze);Xr=i(En,`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\u2019s expert_capacity is reached. `),gt=r(En,"STRONG",{});var Ti=a(gt);Yr=i(Ti,`There is no guarantee
that each token is processed by an expert`),Ti.forEach(t),Qr=i(En,", or that each expert receives at least one token."),En.forEach(t),ea=p(j),_t=r(j,"P",{});var Mi=a(_t);oa=i(Mi,"The router combining weights are also returned to make sure that the states that are not updated will be masked."),Mi.forEach(t),ta=p(j),ve=r(j,"DIV",{class:!0});var zn=a(ve);y(Xe.$$.fragment,zn),na=p(zn),te=r(zn,"P",{});var Do=a(te);ra=i(Do,"Computes the "),bt=r(Do,"CODE",{});var $i=a(bt);aa=i($i,"dispatch_mask"),$i.forEach(t),sa=i(Do," and the "),vt=r(Do,"CODE",{});var Ni=a(vt);ia=i(Ni,"dispatch_weights"),Ni.forEach(t),la=i(Do,` for each experts. The masks are adapted to the expert
capacity.`),Do.forEach(t),zn.forEach(t),da=p(j),ye=r(j,"DIV",{class:!0});var qn=a(ye);y(Ye.$$.fragment,qn),ca=p(qn),yt=r(qn,"P",{});var xi=a(yt);ha=i(xi,`The hidden states are reshaped to simplify the computation of the router probabilities (combining weights for
each experts.)`),xi.forEach(t),qn.forEach(t),j.forEach(t),un=p(o),ne=r(o,"H2",{class:!0});var Cn=a(ne);we=r(Cn,"A",{id:!0,class:!0,href:!0});var Ei=a(we);wt=r(Ei,"SPAN",{});var zi=a(wt);y(Qe.$$.fragment,zi),zi.forEach(t),Ei.forEach(t),pa=p(Cn),kt=r(Cn,"SPAN",{});var qi=a(kt);ua=i(qi,"NllbMoeSparseMLP"),qi.forEach(t),Cn.forEach(t),fn=p(o),D=r(o,"DIV",{class:!0});var Go=a(D);y(eo.$$.fragment,Go),fa=p(Go),Tt=r(Go,"P",{});var Ci=a(Tt);ma=i(Ci,"Implementation of the NLLB-MoE sparse MLP module."),Ci.forEach(t),ga=p(Go),P=r(Go,"DIV",{class:!0});var qe=a(P);y(oo.$$.fragment,qe),_a=p(qe),to=r(qe,"P",{});var Ln=a(to);ba=i(Ln,"The goal of this forward pass is to have the same number of operation as the equivalent "),Mt=r(Ln,"CODE",{});var Li=a(Mt);va=i(Li,"NllbMoeDenseActDense"),Li.forEach(t),ya=i(Ln,`
(mlp) layer. This means that all of the hidden states should be processed at most twice ( since we are using a
top_2 gating mecanism). 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).`),Ln.forEach(t),wa=p(qe),x=r(qe,"P",{});var C=a(x);ka=i(C,"1- Get the "),$t=r(C,"CODE",{});var Fi=a($t);Ta=i(Fi,"router_probs"),Fi.forEach(t),Ma=i(C," from the "),Nt=r(C,"CODE",{});var Si=a(Nt);$a=i(Si,"router"),Si.forEach(t),Na=i(C,". The shape of the "),xt=r(C,"CODE",{});var Pi=a(xt);xa=i(Pi,"router_mask"),Pi.forEach(t),Ea=i(C," is "),Et=r(C,"CODE",{});var Ai=a(Et);za=i(Ai,"(batch_size X sequence_length, num_expert)"),Ai.forEach(t),qa=i(C," and corresponds to the boolean version of the "),zt=r(C,"CODE",{});var ji=a(zt);Ca=i(ji,"router_probs"),ji.forEach(t),La=i(C,`. The inputs are masked using the
`),qt=r(C,"CODE",{});var Oi=a(qt);Fa=i(Oi,"router_mask"),Oi.forEach(t),Sa=i(C,"."),C.forEach(t),Pa=p(qe),Ct=r(qe,"P",{});var Di=a(Ct);Aa=i(Di,`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.`),Di.forEach(t),qe.forEach(t),Go.forEach(t),mn=p(o),re=r(o,"H2",{class:!0});var Fn=a(re);ke=r(Fn,"A",{id:!0,class:!0,href:!0});var Gi=a(ke);Lt=r(Gi,"SPAN",{});var Bi=a(Lt);y(no.$$.fragment,Bi),Bi.forEach(t),Gi.forEach(t),ja=p(Fn),Ft=r(Fn,"SPAN",{});var Ii=a(Ft);Oa=i(Ii,"NllbMoeModel"),Ii.forEach(t),Fn.forEach(t),gn=p(o),F=r(o,"DIV",{class:!0});var Ce=a(F);y(ro.$$.fragment,Ce),Da=p(Ce),ao=r(Ce,"P",{});var Sn=a(ao);Ga=i(Sn,`The bare NllbMoe Model outputting raw hidden-states without any specific head on top.
This model inherits from `),xo=r(Sn,"A",{href:!0});var Ri=a(xo);Ba=i(Ri,"PreTrainedModel"),Ri.forEach(t),Ia=i(Sn,`. 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.)`),Sn.forEach(t),Ra=p(Ce),so=r(Ce,"P",{});var Pn=a(so);Ha=i(Pn,"This model is also a PyTorch "),io=r(Pn,"A",{href:!0,rel:!0});var Hi=a(io);Wa=i(Hi,"torch.nn.Module"),Hi.forEach(t),Ja=i(Pn,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Pn.forEach(t),Ua=p(Ce),E=r(Ce,"DIV",{class:!0});var O=a(E);y(lo.$$.fragment,O),Va=p(O),ae=r(O,"P",{});var Bo=a(ae);Ka=i(Bo,"The "),Eo=r(Bo,"A",{href:!0});var Wi=a(Eo);Za=i(Wi,"NllbMoeModel"),Wi.forEach(t),Xa=i(Bo," forward method, overrides the "),St=r(Bo,"CODE",{});var Ji=a(St);Ya=i(Ji,"__call__"),Ji.forEach(t),Qa=i(Bo," special method."),Bo.forEach(t),es=p(O),y(Te.$$.fragment,O),os=p(O),se=r(O,"P",{});var Io=a(se);ts=i(Io,"The "),zo=r(Io,"A",{href:!0});var Ui=a(zo);ns=i(Ui,"NllbMoeModel"),Ui.forEach(t),rs=i(Io," forward method, overrides the "),Pt=r(Io,"CODE",{});var Vi=a(Pt);as=i(Vi,"__call__"),Vi.forEach(t),ss=i(Io," special method."),Io.forEach(t),is=p(O),y(Me.$$.fragment,O),ls=p(O),y($e.$$.fragment,O),O.forEach(t),Ce.forEach(t),_n=p(o),ie=r(o,"H2",{class:!0});var An=a(ie);Ne=r(An,"A",{id:!0,class:!0,href:!0});var Ki=a(Ne);At=r(Ki,"SPAN",{});var Zi=a(At);y(co.$$.fragment,Zi),Zi.forEach(t),Ki.forEach(t),ds=p(An),jt=r(An,"SPAN",{});var Xi=a(jt);cs=i(Xi,"NllbMoeForConditionalGeneration"),Xi.forEach(t),An.forEach(t),bn=p(o),S=r(o,"DIV",{class:!0});var Le=a(S);y(ho.$$.fragment,Le),hs=p(Le),po=r(Le,"P",{});var jn=a(po);ps=i(jn,`The NllbMoe Model with a language modeling head. Can be used for summarization.
This model inherits from `),qo=r(jn,"A",{href:!0});var Yi=a(qo);us=i(Yi,"PreTrainedModel"),Yi.forEach(t),fs=i(jn,`. 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.)`),jn.forEach(t),ms=p(Le),uo=r(Le,"P",{});var On=a(uo);gs=i(On,"This model is also a PyTorch "),fo=r(On,"A",{href:!0,rel:!0});var Qi=a(fo);_s=i(Qi,"torch.nn.Module"),Qi.forEach(t),bs=i(On,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),On.forEach(t),vs=p(Le),A=r(Le,"DIV",{class:!0});var Fe=a(A);y(mo.$$.fragment,Fe),ys=p(Fe),le=r(Fe,"P",{});var Ro=a(le);ws=i(Ro,"The "),Co=r(Ro,"A",{href:!0});var el=a(Co);ks=i(el,"NllbMoeForConditionalGeneration"),el.forEach(t),Ts=i(Ro," forward method, overrides the "),Ot=r(Ro,"CODE",{});var ol=a(Ot);Ms=i(ol,"__call__"),ol.forEach(t),$s=i(Ro," special method."),Ro.forEach(t),Ns=p(Fe),y(xe.$$.fragment,Fe),xs=p(Fe),y(Ee.$$.fragment,Fe),Fe.forEach(t),Le.forEach(t),this.h()},h(){l(f,"name","hf:doc:metadata"),l(f,"content",JSON.stringify(fl)),l(g,"id","nllbmoe"),l(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(g,"href","#nllbmoe"),l(_,"class","relative group"),l(de,"id","overview"),l(de,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(de,"href","#overview"),l(U,"class","relative group"),l(Pe,"href","https://arxiv.org/abs/2207.04672"),l(Pe,"rel","nofollow"),l(Ae,"href","https://huggingface.co/ArtZucker"),l(Ae,"rel","nofollow"),l(je,"href","https://github.com/facebookresearch/fairseq"),l(je,"rel","nofollow"),l(he,"id","implementation-differences-with-switchtransformers"),l(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(he,"href","#implementation-differences-with-switchtransformers"),l(V,"class","relative group"),l(pe,"id","generating-with-nllbmoe"),l(pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(pe,"href","#generating-with-nllbmoe"),l(K,"class","relative group"),l(Ge,"href","https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200"),l(Ge,"rel","nofollow"),l(ue,"id","generating-from-any-other-language-than-english"),l(ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ue,"href","#generating-from-any-other-language-than-english"),l(Z,"class","relative group"),l(fe,"id","documentation-resources"),l(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(fe,"href","#documentation-resources"),l(X,"class","relative group"),l(ko,"href","./tasks/translation"),l(To,"href","./tasks/summarization"),l(ge,"id","transformers.NllbMoeConfig"),l(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ge,"href","#transformers.NllbMoeConfig"),l(Y,"class","relative group"),l(Mo,"href","/docs/transformers/v4.29.0/en/model_doc/nllb-moe#transformers.NllbMoeModel"),l(Ue,"href","https://huggingface.co/facebook/nllb-moe-54b"),l(Ue,"rel","nofollow"),l($o,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(No,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(be,"id","transformers.NllbMoeTop2Router"),l(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(be,"href","#transformers.NllbMoeTop2Router"),l(oe,"class","relative group"),l(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(we,"id","transformers.NllbMoeSparseMLP"),l(we,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(we,"href","#transformers.NllbMoeSparseMLP"),l(ne,"class","relative group"),l(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ke,"id","transformers.NllbMoeModel"),l(ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ke,"href","#transformers.NllbMoeModel"),l(re,"class","relative group"),l(xo,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel"),l(io,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(io,"rel","nofollow"),l(Eo,"href","/docs/transformers/v4.29.0/en/model_doc/nllb-moe#transformers.NllbMoeModel"),l(zo,"href","/docs/transformers/v4.29.0/en/model_doc/nllb-moe#transformers.NllbMoeModel"),l(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Ne,"id","transformers.NllbMoeForConditionalGeneration"),l(Ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Ne,"href","#transformers.NllbMoeForConditionalGeneration"),l(ie,"class","relative group"),l(qo,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel"),l(fo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(fo,"rel","nofollow"),l(Co,"href","/docs/transformers/v4.29.0/en/model_doc/nllb-moe#transformers.NllbMoeForConditionalGeneration"),l(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,d){e(document.head,f),u(o,$,d),u(o,_,d),e(_,g),e(g,b),w(c,b,null),e(_,m),e(_,q),e(q,Dn),u(o,Ht,d),u(o,U,d),e(U,de),e(de,Ho),w(Se,Ho,null),e(U,Gn),e(U,Wo),e(Wo,Bn),u(o,Wt,d),u(o,ce,d),e(ce,In),e(ce,Pe),e(Pe,Rn),e(ce,Hn),u(o,Jt,d),u(o,bo,d),e(bo,Wn),u(o,Ut,d),u(o,vo,d),e(vo,Jo),e(Jo,Jn),u(o,Vt,d),u(o,yo,d),e(yo,Un),u(o,Kt,d),u(o,B,d),e(B,Uo),e(Uo,Vn),e(B,Kn),e(B,Vo),e(Vo,Zn),e(B,Xn),e(B,Ko),e(Ko,Yn),u(o,Zt,d),u(o,I,d),e(I,Qn),e(I,Ae),e(Ae,er),e(I,or),e(I,je),e(je,tr),e(I,nr),u(o,Xt,d),u(o,V,d),e(V,he),e(he,Zo),w(Oe,Zo,null),e(V,rr),e(V,Xo),e(Xo,ar),u(o,Yt,d),u(o,K,d),e(K,pe),e(pe,Yo),w(De,Yo,null),e(K,sr),e(K,Qo),e(Qo,ir),u(o,Qt,d),u(o,R,d),e(R,lr),e(R,et),e(et,dr),e(R,cr),e(R,ot),e(ot,hr),e(R,pr),u(o,en,d),u(o,H,d),e(H,ur),e(H,tt),e(tt,fr),e(H,mr),e(H,Ge),e(Ge,gr),e(H,_r),u(o,on,d),w(Be,o,d),u(o,tn,d),u(o,Z,d),e(Z,ue),e(ue,nt),w(Ie,nt,null),e(Z,br),e(Z,rt),e(rt,vr),u(o,nn,d),u(o,W,d),e(W,yr),e(W,at),e(at,wr),e(W,kr),e(W,st),e(st,Tr),e(W,Mr),u(o,rn,d),u(o,wo,d),e(wo,$r),u(o,an,d),w(Re,o,d),u(o,sn,d),u(o,X,d),e(X,fe),e(fe,it),w(He,it,null),e(X,Nr),e(X,lt),e(lt,xr),u(o,ln,d),u(o,me,d),e(me,dt),e(dt,ko),e(ko,Er),e(me,zr),e(me,ct),e(ct,To),e(To,qr),u(o,dn,d),u(o,Y,d),e(Y,ge),e(ge,ht),w(We,ht,null),e(Y,Cr),e(Y,pt),e(pt,Lr),u(o,cn,d),u(o,L,d),w(Je,L,null),e(L,Fr),e(L,Q),e(Q,Sr),e(Q,Mo),e(Mo,Pr),e(Q,Ar),e(Q,Ue),e(Ue,jr),e(Q,Or),e(L,Dr),e(L,ee),e(ee,Gr),e(ee,$o),e($o,Br),e(ee,Ir),e(ee,No),e(No,Rr),e(ee,Hr),e(L,Wr),w(_e,L,null),u(o,hn,d),u(o,oe,d),e(oe,be),e(be,ut),w(Ve,ut,null),e(oe,Jr),e(oe,ft),e(ft,Ur),u(o,pn,d),u(o,N,d),w(Ke,N,null),e(N,Vr),e(N,mt),e(mt,Kr),e(N,Zr),e(N,Ze),e(Ze,Xr),e(Ze,gt),e(gt,Yr),e(Ze,Qr),e(N,ea),e(N,_t),e(_t,oa),e(N,ta),e(N,ve),w(Xe,ve,null),e(ve,na),e(ve,te),e(te,ra),e(te,bt),e(bt,aa),e(te,sa),e(te,vt),e(vt,ia),e(te,la),e(N,da),e(N,ye),w(Ye,ye,null),e(ye,ca),e(ye,yt),e(yt,ha),u(o,un,d),u(o,ne,d),e(ne,we),e(we,wt),w(Qe,wt,null),e(ne,pa),e(ne,kt),e(kt,ua),u(o,fn,d),u(o,D,d),w(eo,D,null),e(D,fa),e(D,Tt),e(Tt,ma),e(D,ga),e(D,P),w(oo,P,null),e(P,_a),e(P,to),e(to,ba),e(to,Mt),e(Mt,va),e(to,ya),e(P,wa),e(P,x),e(x,ka),e(x,$t),e($t,Ta),e(x,Ma),e(x,Nt),e(Nt,$a),e(x,Na),e(x,xt),e(xt,xa),e(x,Ea),e(x,Et),e(Et,za),e(x,qa),e(x,zt),e(zt,Ca),e(x,La),e(x,qt),e(qt,Fa),e(x,Sa),e(P,Pa),e(P,Ct),e(Ct,Aa),u(o,mn,d),u(o,re,d),e(re,ke),e(ke,Lt),w(no,Lt,null),e(re,ja),e(re,Ft),e(Ft,Oa),u(o,gn,d),u(o,F,d),w(ro,F,null),e(F,Da),e(F,ao),e(ao,Ga),e(ao,xo),e(xo,Ba),e(ao,Ia),e(F,Ra),e(F,so),e(so,Ha),e(so,io),e(io,Wa),e(so,Ja),e(F,Ua),e(F,E),w(lo,E,null),e(E,Va),e(E,ae),e(ae,Ka),e(ae,Eo),e(Eo,Za),e(ae,Xa),e(ae,St),e(St,Ya),e(ae,Qa),e(E,es),w(Te,E,null),e(E,os),e(E,se),e(se,ts),e(se,zo),e(zo,ns),e(se,rs),e(se,Pt),e(Pt,as),e(se,ss),e(E,is),w(Me,E,null),e(E,ls),w($e,E,null),u(o,_n,d),u(o,ie,d),e(ie,Ne),e(Ne,At),w(co,At,null),e(ie,ds),e(ie,jt),e(jt,cs),u(o,bn,d),u(o,S,d),w(ho,S,null),e(S,hs),e(S,po),e(po,ps),e(po,qo),e(qo,us),e(po,fs),e(S,ms),e(S,uo),e(uo,gs),e(uo,fo),e(fo,_s),e(uo,bs),e(S,vs),e(S,A),w(mo,A,null),e(A,ys),e(A,le),e(le,ws),e(le,Co),e(Co,ks),e(le,Ts),e(le,Ot),e(Ot,Ms),e(le,$s),e(A,Ns),w(xe,A,null),e(A,xs),w(Ee,A,null),vn=!0},p(o,[d]){const go={};d&2&&(go.$$scope={dirty:d,ctx:o}),_e.$set(go);const Dt={};d&2&&(Dt.$$scope={dirty:d,ctx:o}),Te.$set(Dt);const Gt={};d&2&&(Gt.$$scope={dirty:d,ctx:o}),Me.$set(Gt);const Bt={};d&2&&(Bt.$$scope={dirty:d,ctx:o}),$e.$set(Bt);const _o={};d&2&&(_o.$$scope={dirty:d,ctx:o}),xe.$set(_o);const It={};d&2&&(It.$$scope={dirty:d,ctx:o}),Ee.$set(It)},i(o){vn||(k(c.$$.fragment,o),k(Se.$$.fragment,o),k(Oe.$$.fragment,o),k(De.$$.fragment,o),k(Be.$$.fragment,o),k(Ie.$$.fragment,o),k(Re.$$.fragment,o),k(He.$$.fragment,o),k(We.$$.fragment,o),k(Je.$$.fragment,o),k(_e.$$.fragment,o),k(Ve.$$.fragment,o),k(Ke.$$.fragment,o),k(Xe.$$.fragment,o),k(Ye.$$.fragment,o),k(Qe.$$.fragment,o),k(eo.$$.fragment,o),k(oo.$$.fragment,o),k(no.$$.fragment,o),k(ro.$$.fragment,o),k(lo.$$.fragment,o),k(Te.$$.fragment,o),k(Me.$$.fragment,o),k($e.$$.fragment,o),k(co.$$.fragment,o),k(ho.$$.fragment,o),k(mo.$$.fragment,o),k(xe.$$.fragment,o),k(Ee.$$.fragment,o),vn=!0)},o(o){T(c.$$.fragment,o),T(Se.$$.fragment,o),T(Oe.$$.fragment,o),T(De.$$.fragment,o),T(Be.$$.fragment,o),T(Ie.$$.fragment,o),T(Re.$$.fragment,o),T(He.$$.fragment,o),T(We.$$.fragment,o),T(Je.$$.fragment,o),T(_e.$$.fragment,o),T(Ve.$$.fragment,o),T(Ke.$$.fragment,o),T(Xe.$$.fragment,o),T(Ye.$$.fragment,o),T(Qe.$$.fragment,o),T(eo.$$.fragment,o),T(oo.$$.fragment,o),T(no.$$.fragment,o),T(ro.$$.fragment,o),T(lo.$$.fragment,o),T(Te.$$.fragment,o),T(Me.$$.fragment,o),T($e.$$.fragment,o),T(co.$$.fragment,o),T(ho.$$.fragment,o),T(mo.$$.fragment,o),T(xe.$$.fragment,o),T(Ee.$$.fragment,o),vn=!1},d(o){t(f),o&&t($),o&&t(_),M(c),o&&t(Ht),o&&t(U),M(Se),o&&t(Wt),o&&t(ce),o&&t(Jt),o&&t(bo),o&&t(Ut),o&&t(vo),o&&t(Vt),o&&t(yo),o&&t(Kt),o&&t(B),o&&t(Zt),o&&t(I),o&&t(Xt),o&&t(V),M(Oe),o&&t(Yt),o&&t(K),M(De),o&&t(Qt),o&&t(R),o&&t(en),o&&t(H),o&&t(on),M(Be,o),o&&t(tn),o&&t(Z),M(Ie),o&&t(nn),o&&t(W),o&&t(rn),o&&t(wo),o&&t(an),M(Re,o),o&&t(sn),o&&t(X),M(He),o&&t(ln),o&&t(me),o&&t(dn),o&&t(Y),M(We),o&&t(cn),o&&t(L),M(Je),M(_e),o&&t(hn),o&&t(oe),M(Ve),o&&t(pn),o&&t(N),M(Ke),M(Xe),M(Ye),o&&t(un),o&&t(ne),M(Qe),o&&t(fn),o&&t(D),M(eo),M(oo),o&&t(mn),o&&t(re),M(no),o&&t(gn),o&&t(F),M(ro),M(lo),M(Te),M(Me),M($e),o&&t(_n),o&&t(ie),M(co),o&&t(bn),o&&t(S),M(ho),M(mo),M(xe),M(Ee)}}}const fl={local:"nllbmoe",sections:[{local:"overview",title:"Overview"},{local:"implementation-differences-with-switchtransformers",title:"Implementation differences with SwitchTransformers"},{local:"generating-with-nllbmoe",sections:[{local:"generating-from-any-other-language-than-english",title:"Generating from any other language than English"}],title:"Generating with NLLB-MoE"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.NllbMoeConfig",title:"NllbMoeConfig"},{local:"transformers.NllbMoeTop2Router",title:"NllbMoeTop2Router"},{local:"transformers.NllbMoeSparseMLP",title:"NllbMoeSparseMLP"},{local:"transformers.NllbMoeModel",title:"NllbMoeModel"},{local:"transformers.NllbMoeForConditionalGeneration",title:"NllbMoeForConditionalGeneration"}],title:"NLLB-MOE"};function ml(z){return sl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class kl extends tl{constructor(f){super();nl(this,f,ml,ul,rl,{})}}export{kl as default,fl as metadata};
