import{S as kr,i as br,s as vr,e as a,k as i,w as _,t as r,M as wr,c as o,d as n,m as c,a as s,x as k,h as l,b as d,G as e,g as p,y as b,q as v,o as w,B as y,v as yr,L as _r}from"../../chunks/vendor-hf-doc-builder.js";import{D as Oe}from"../../chunks/Docstring-hf-doc-builder.js";import{C as On}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ge}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as mr}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function $r(He){let g,x,$,u,T;return u=new On({props:{code:`from transformers import NllbTokenizer

tokenizer = NllbTokenizer.from_pretrained(
    "facebook/nllb-200-distilled-600M", src_lang="eng_Latn", tgt_lang="fra_Latn"
)
example_english_phrase = " UN Chief Says There Is No Military Solution in Syria"
expected_translation_french = "Le chef de l'ONU affirme qu'il n'y a pas de solution militaire en Syrie."
inputs = tokenizer(example_english_phrase, text_target=expected_translation_french, return_tensors="pt")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> NllbTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = NllbTokenizer.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/nllb-200-distilled-600M&quot;</span>, src_lang=<span class="hljs-string">&quot;eng_Latn&quot;</span>, tgt_lang=<span class="hljs-string">&quot;fra_Latn&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example_english_phrase = <span class="hljs-string">&quot; UN Chief Says There Is No Military Solution in Syria&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>expected_translation_french = <span class="hljs-string">&quot;Le chef de l&#x27;ONU affirme qu&#x27;il n&#x27;y a pas de solution militaire en Syrie.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(example_english_phrase, text_target=expected_translation_french, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`}}),{c(){g=a("p"),x=r("Examples:"),$=i(),_(u.$$.fragment)},l(f){g=o(f,"P",{});var E=s(g);x=l(E,"Examples:"),E.forEach(n),$=c(f),k(u.$$.fragment,f)},m(f,E){p(f,g,E),e(g,x),p(f,$,E),b(u,f,E),T=!0},p:_r,i(f){T||(v(u.$$.fragment,f),T=!0)},o(f){w(u.$$.fragment,f),T=!1},d(f){f&&n(g),f&&n($),y(u,f)}}}function qr(He){let g,x,$,u,T;return u=new On({props:{code:`from transformers import NllbTokenizerFast

tokenizer = NllbTokenizerFast.from_pretrained(
    "facebook/nllb-200-distilled-600M", src_lang="eng_Latn", tgt_lang="fra_Latn"
)
example_english_phrase = " UN Chief Says There Is No Military Solution in Syria"
expected_translation_french = "Le chef de l'ONU affirme qu'il n'y a pas de solution militaire en Syrie."
inputs = tokenizer(example_english_phrase, text_target=expected_translation_french, return_tensors="pt")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> NllbTokenizerFast

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = NllbTokenizerFast.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/nllb-200-distilled-600M&quot;</span>, src_lang=<span class="hljs-string">&quot;eng_Latn&quot;</span>, tgt_lang=<span class="hljs-string">&quot;fra_Latn&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example_english_phrase = <span class="hljs-string">&quot; UN Chief Says There Is No Military Solution in Syria&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>expected_translation_french = <span class="hljs-string">&quot;Le chef de l&#x27;ONU affirme qu&#x27;il n&#x27;y a pas de solution militaire en Syrie.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(example_english_phrase, text_target=expected_translation_french, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`}}),{c(){g=a("p"),x=r("Examples:"),$=i(),_(u.$$.fragment)},l(f){g=o(f,"P",{});var E=s(g);x=l(E,"Examples:"),E.forEach(n),$=c(f),k(u.$$.fragment,f)},m(f,E){p(f,g,E),e(g,x),p(f,$,E),b(u,f,E),T=!0},p:_r,i(f){T||(v(u.$$.fragment,f),T=!0)},o(f){w(u.$$.fragment,f),T=!1},d(f){f&&n(g),f&&n($),y(u,f)}}}function Er(He){let g,x,$,u,T,f,E,rt,Gn,Qt,D,lt,Hn,Un,ce,Rn,Wn,Zt,B,X,it,de,Jn,ct,Xn,en,K,Kn,he,Vn,Yn,tn,Ue,Qn,nn,Re,dt,Zn,an,We,ea,on,A,ta,pe,na,aa,fe,oa,sa,sn,I,V,ht,ue,ra,pt,la,rn,P,ia,ft,ca,da,ut,ha,pa,ln,F,fa,gt,ua,ga,ge,ma,_a,cn,me,dn,O,Y,mt,_e,ka,_t,ba,hn,M,va,kt,wa,ya,bt,$a,qa,pn,Je,Ea,fn,ke,un,G,Q,vt,be,za,wt,Ta,gn,Z,yt,Xe,Na,xa,$t,Ke,La,mn,H,ee,qt,ve,Sa,Et,ja,_n,z,we,Aa,zt,Pa,Fa,j,Ma,Ve,Ca,Da,Ye,Ba,Ia,ye,Oa,Ga,Ha,U,Ua,Tt,Ra,Wa,Nt,Ja,Xa,Ka,te,Va,L,$e,Ya,qe,Qa,xt,Za,eo,to,Ee,ze,Lt,no,ao,St,oo,so,Te,jt,ro,lo,At,io,co,Pt,ho,kn,R,ne,Ft,Ne,po,Mt,fo,bn,m,xe,uo,W,go,Ct,mo,_o,Le,ko,bo,vo,Se,wo,Qe,yo,$o,qo,J,Eo,Dt,zo,To,Bt,No,xo,Lo,ae,So,N,je,jo,It,Ao,Po,Ae,Fo,Ot,Mo,Co,Do,Pe,Fe,Gt,Bo,Io,Ht,Oo,Go,Me,Ut,Ho,Uo,Rt,Ro,Wo,Wt,Jo,Xo,oe,Ce,Ko,Jt,Vo,Yo,se,De,Qo,Xt,Zo,es,re,Be,ts,Kt,ns,vn;return f=new Ge({}),de=new Ge({}),ue=new Ge({}),me=new On({props:{code:`from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")

article = "UN Chief says there is no military solution in Syria"
inputs = tokenizer(article, return_tensors="pt")

translated_tokens = model.generate(
    **inputs, forced_bos_token_id=tokenizer.lang_code_to_id["fra_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-200-distilled-600M&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-200-distilled-600M&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>article = <span class="hljs-string">&quot;UN Chief says there is no military solution in Syria&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">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>]
Le chef de l<span class="hljs-string">&#x27;ONU dit qu&#x27;</span>il n<span class="hljs-string">&#x27;y a pas de solution militaire en Syrie</span>`}}),_e=new Ge({}),ke=new On({props:{code:`from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(
    "facebook/nllb-200-distilled-600M", use_auth_token=True, src_lang="ron_Latn"
)
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M", use_auth_token=True)

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-meta">... </span>    <span class="hljs-string">&quot;facebook/nllb-200-distilled-600M&quot;</span>, use_auth_token=<span class="hljs-literal">True</span>, src_lang=<span class="hljs-string">&quot;ron_Latn&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;facebook/nllb-200-distilled-600M&quot;</span>, use_auth_token=<span class="hljs-literal">True</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>]
UN-Chef sagt, es gibt keine milit\xE4rische L\xF6sung <span class="hljs-keyword">in</span> Syrien`}}),be=new Ge({}),ve=new Ge({}),we=new Oe({props:{name:"class transformers.NllbTokenizer",anchor:"transformers.NllbTokenizer",parameters:[{name:"vocab_file",val:""},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"sep_token",val:" = '</s>'"},{name:"cls_token",val:" = '<s>'"},{name:"unk_token",val:" = '<unk>'"},{name:"pad_token",val:" = '<pad>'"},{name:"mask_token",val:" = '<mask>'"},{name:"tokenizer_file",val:" = None"},{name:"src_lang",val:" = None"},{name:"tgt_lang",val:" = None"},{name:"sp_model_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"additional_special_tokens",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.NllbTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.NllbTokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;s&gt;&quot;</code>) &#x2014;
The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the beginning of
sequence. The token used is the <code>cls_token</code>.</p>

					</div>`,name:"bos_token"},{anchor:"transformers.NllbTokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The end of sequence token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the end of sequence.
The token used is the <code>sep_token</code>.</p>

					</div>`,name:"eos_token"},{anchor:"transformers.NllbTokenizer.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.`,name:"sep_token"},{anchor:"transformers.NllbTokenizer.cls_token",description:`<strong>cls_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;s&gt;&quot;</code>) &#x2014;
The classifier token which is used when doing sequence classification (classification of the whole sequence
instead of per-token classification). It is the first token of the sequence when built with special tokens.`,name:"cls_token"},{anchor:"transformers.NllbTokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;unk&gt;&quot;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.NllbTokenizer.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;pad&gt;&quot;</code>) &#x2014;
The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"},{anchor:"transformers.NllbTokenizer.mask_token",description:`<strong>mask_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;mask&gt;&quot;</code>) &#x2014;
The token used for masking values. This is the token used when training this model with masked language
modeling. This is the token which the model will try to predict.`,name:"mask_token"},{anchor:"transformers.NllbTokenizer.tokenizer_file",description:`<strong>tokenizer_file</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to a tokenizer file to use instead of the vocab file.`,name:"tokenizer_file"},{anchor:"transformers.NllbTokenizer.src_lang",description:`<strong>src_lang</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language to use as source language for translation.`,name:"src_lang"},{anchor:"transformers.NllbTokenizer.tgt_lang",description:`<strong>tgt_lang</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language to use as target language for translation.`,name:"tgt_lang"},{anchor:"transformers.NllbTokenizer.sp_model_kwargs",description:`<strong>sp_model_kwargs</strong> (<code>Dict[str, str]</code>) &#x2014;
Additional keyword arguments to pass to the model initialization.`,name:"sp_model_kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb.py#L49"}}),te=new mr({props:{anchor:"transformers.NllbTokenizer.example",$$slots:{default:[$r]},$$scope:{ctx:He}}}),$e=new Oe({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.NllbTokenizer.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.NllbTokenizer.build_inputs_with_special_tokens.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs to which the special tokens will be added.`,name:"token_ids_0"},{anchor:"transformers.NllbTokenizer.build_inputs_with_special_tokens.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb.py#L263",returnDescription:`
<p>List of <a href="../glossary#input-ids">input IDs</a> with the appropriate special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),Ne=new Ge({}),xe=new Oe({props:{name:"class transformers.NllbTokenizerFast",anchor:"transformers.NllbTokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"sep_token",val:" = '</s>'"},{name:"cls_token",val:" = '<s>'"},{name:"unk_token",val:" = '<unk>'"},{name:"pad_token",val:" = '<pad>'"},{name:"mask_token",val:" = '<mask>'"},{name:"src_lang",val:" = None"},{name:"tgt_lang",val:" = None"},{name:"additional_special_tokens",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.NllbTokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.NllbTokenizerFast.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;s&gt;&quot;</code>) &#x2014;
The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the beginning of
sequence. The token used is the <code>cls_token</code>.</p>

					</div>`,name:"bos_token"},{anchor:"transformers.NllbTokenizerFast.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The end of sequence token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the end of sequence.
The token used is the <code>sep_token</code>.</p>

					</div>`,name:"eos_token"},{anchor:"transformers.NllbTokenizerFast.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.`,name:"sep_token"},{anchor:"transformers.NllbTokenizerFast.cls_token",description:`<strong>cls_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;s&gt;&quot;</code>) &#x2014;
The classifier token which is used when doing sequence classification (classification of the whole sequence
instead of per-token classification). It is the first token of the sequence when built with special tokens.`,name:"cls_token"},{anchor:"transformers.NllbTokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;unk&gt;&quot;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.NllbTokenizerFast.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;pad&gt;&quot;</code>) &#x2014;
The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"},{anchor:"transformers.NllbTokenizerFast.mask_token",description:`<strong>mask_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;mask&gt;&quot;</code>) &#x2014;
The token used for masking values. This is the token used when training this model with masked language
modeling. This is the token which the model will try to predict.`,name:"mask_token"},{anchor:"transformers.NllbTokenizerFast.tokenizer_file",description:`<strong>tokenizer_file</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to a tokenizer file to use instead of the vocab file.`,name:"tokenizer_file"},{anchor:"transformers.NllbTokenizerFast.src_lang",description:`<strong>src_lang</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language to use as source language for translation.`,name:"src_lang"},{anchor:"transformers.NllbTokenizerFast.tgt_lang",description:`<strong>tgt_lang</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language to use as target language for translation.`,name:"tgt_lang"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb_fast.py#L61"}}),ae=new mr({props:{anchor:"transformers.NllbTokenizerFast.example",$$slots:{default:[qr]},$$scope:{ctx:He}}}),je=new Oe({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.NllbTokenizerFast.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.NllbTokenizerFast.build_inputs_with_special_tokens.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs to which the special tokens will be added.`,name:"token_ids_0"},{anchor:"transformers.NllbTokenizerFast.build_inputs_with_special_tokens.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb_fast.py#L205",returnDescription:`
<p>list of <a href="../glossary#input-ids">input IDs</a> with the appropriate special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),Ce=new Oe({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.NllbTokenizerFast.create_token_type_ids_from_sequences",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.NllbTokenizerFast.create_token_type_ids_from_sequences.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.NllbTokenizerFast.create_token_type_ids_from_sequences.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb_fast.py#L234",returnDescription:`
<p>List of zeros.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),De=new Oe({props:{name:"set_src_lang_special_tokens",anchor:"transformers.NllbTokenizerFast.set_src_lang_special_tokens",parameters:[{name:"src_lang",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb_fast.py#L289"}}),Be=new Oe({props:{name:"set_tgt_lang_special_tokens",anchor:"transformers.NllbTokenizerFast.set_tgt_lang_special_tokens",parameters:[{name:"lang",val:": str"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/nllb/tokenization_nllb_fast.py#L304"}}),{c(){g=a("meta"),x=i(),$=a("h1"),u=a("a"),T=a("span"),_(f.$$.fragment),E=i(),rt=a("span"),Gn=r("NLLB"),Qt=i(),D=a("p"),lt=a("strong"),Hn=r("DISCLAIMER:"),Un=r(" If you see something strange, file a "),ce=a("a"),Rn=r("Github Issue"),Wn=r(` and assign
@LysandreJik`),Zt=i(),B=a("h2"),X=a("a"),it=a("span"),_(de.$$.fragment),Jn=i(),ct=a("span"),Xn=r("Overview of NLLB"),en=i(),K=a("p"),Kn=r("The NLLB model was presented in "),he=a("a"),Vn=r("No Language Left Behind: Scaling Human-Centered Machine Translation"),Yn=r(` 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.`),tn=i(),Ue=a("p"),Qn=r("The abstract of the paper is the following:"),nn=i(),Re=a("p"),dt=a("em"),Zn=r(`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.`),an=i(),We=a("p"),ea=r("This implementation contains the dense models available on release. Let us know via a GitHub issue if you would like to see the MoE models as well."),on=i(),A=a("p"),ta=r("This model was contributed by "),pe=a("a"),na=r("Lysandre"),aa=r(". The authors\u2019 code can be found "),fe=a("a"),oa=r("here"),sa=r("."),sn=i(),I=a("h2"),V=a("a"),ht=a("span"),_(ue.$$.fragment),ra=i(),pt=a("span"),la=r("Generating with NLLB"),rn=i(),P=a("p"),ia=r("While generating the target text set the "),ft=a("code"),ca=r("forced_bos_token_id"),da=r(` to the target language id. The following
example shows how to translate English to French using the `),ut=a("em"),ha=r("facebook/nllb-200-distilled-600M"),pa=r(" model."),ln=i(),F=a("p"),fa=r("Note that we\u2019re using the BCP-47 code for French "),gt=a("code"),ua=r("fra_Latn"),ga=r(". See "),ge=a("a"),ma=r("here"),_a=r(`
for the list of all BCP-47 in the Flores 200 dataset.`),cn=i(),_(me.$$.fragment),dn=i(),O=a("h3"),Y=a("a"),mt=a("span"),_(_e.$$.fragment),ka=i(),_t=a("span"),ba=r("Generating from any other language than English"),hn=i(),M=a("p"),va=r("English ("),kt=a("code"),wa=r("eng_Latn"),ya=r(`) 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 `),bt=a("code"),$a=r("src_lang"),qa=r(" keyword argument of the tokenizer initialization."),pn=i(),Je=a("p"),Ea=r("See example below for a translation from romanian to german:"),fn=i(),_(ke.$$.fragment),un=i(),G=a("h2"),Q=a("a"),vt=a("span"),_(be.$$.fragment),za=i(),wt=a("span"),Ta=r("Documentation resources"),gn=i(),Z=a("ul"),yt=a("li"),Xe=a("a"),Na=r("Translation task guide"),xa=i(),$t=a("li"),Ke=a("a"),La=r("Summarization task guide"),mn=i(),H=a("h2"),ee=a("a"),qt=a("span"),_(ve.$$.fragment),Sa=i(),Et=a("span"),ja=r("NllbTokenizer"),_n=i(),z=a("div"),_(we.$$.fragment),Aa=i(),zt=a("p"),Pa=r("Construct an NLLB tokenizer."),Fa=i(),j=a("p"),Ma=r("Adapted from "),Ve=a("a"),Ca=r("RobertaTokenizer"),Da=r(" and "),Ye=a("a"),Ba=r("XLNetTokenizer"),Ia=r(`. Based on
`),ye=a("a"),Oa=r("SentencePiece"),Ga=r("."),Ha=i(),U=a("p"),Ua=r("The tokenization method is "),Tt=a("code"),Ra=r("<tokens> <eos> <language code>"),Wa=r(" for source language documents, and "),Nt=a("code"),Ja=r("<language code> <tokens> <eos>"),Xa=r(" for target language documents."),Ka=i(),_(te.$$.fragment),Va=i(),L=a("div"),_($e.$$.fragment),Ya=i(),qe=a("p"),Qa=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An NLLB sequence has the following format, where `),xt=a("code"),Za=r("X"),eo=r(" represents the sequence:"),to=i(),Ee=a("ul"),ze=a("li"),Lt=a("code"),no=r("input_ids"),ao=r(" (for encoder) "),St=a("code"),oo=r("X [eos, src_lang_code]"),so=i(),Te=a("li"),jt=a("code"),ro=r("decoder_input_ids"),lo=r(": (for decoder) "),At=a("code"),io=r("X [eos, tgt_lang_code]"),co=i(),Pt=a("p"),ho=r(`BOS is never used. Pairs of sequences are not the expected use case, but they will be handled without a
separator.`),kn=i(),R=a("h2"),ne=a("a"),Ft=a("span"),_(Ne.$$.fragment),po=i(),Mt=a("span"),fo=r("NllbTokenizerFast"),bn=i(),m=a("div"),_(xe.$$.fragment),uo=i(),W=a("p"),go=r("Construct a \u201Cfast\u201D NLLB tokenizer (backed by HuggingFace\u2019s "),Ct=a("em"),mo=r("tokenizers"),_o=r(` library). Based on
`),Le=a("a"),ko=r("BPE"),bo=r("."),vo=i(),Se=a("p"),wo=r("This tokenizer inherits from "),Qe=a("a"),yo=r("PreTrainedTokenizerFast"),$o=r(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),qo=i(),J=a("p"),Eo=r("The tokenization method is "),Dt=a("code"),zo=r("<tokens> <eos> <language code>"),To=r(" for source language documents, and "),Bt=a("code"),No=r("<language code> <tokens> <eos>"),xo=r(" for target language documents."),Lo=i(),_(ae.$$.fragment),So=i(),N=a("div"),_(je.$$.fragment),jo=i(),It=a("p"),Ao=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. The special tokens depend on calling set_lang.`),Po=i(),Ae=a("p"),Fo=r("An NLLB sequence has the following format, where "),Ot=a("code"),Mo=r("X"),Co=r(" represents the sequence:"),Do=i(),Pe=a("ul"),Fe=a("li"),Gt=a("code"),Bo=r("input_ids"),Io=r(" (for encoder) "),Ht=a("code"),Oo=r("X [eos, src_lang_code]"),Go=i(),Me=a("li"),Ut=a("code"),Ho=r("decoder_input_ids"),Uo=r(": (for decoder) "),Rt=a("code"),Ro=r("X [eos, tgt_lang_code]"),Wo=i(),Wt=a("p"),Jo=r(`BOS is never used. Pairs of sequences are not the expected use case, but they will be handled without a
separator.`),Xo=i(),oe=a("div"),_(Ce.$$.fragment),Ko=i(),Jt=a("p"),Vo=r(`Create a mask from the two sequences passed to be used in a sequence-pair classification task. nllb does not
make use of token type ids, therefore a list of zeros is returned.`),Yo=i(),se=a("div"),_(De.$$.fragment),Qo=i(),Xt=a("p"),Zo=r("Reset the special tokens to the source lang setting. No prefix and suffix=[eos, src_lang_code]."),es=i(),re=a("div"),_(Be.$$.fragment),ts=i(),Kt=a("p"),ns=r("Reset the special tokens to the target language setting. No prefix and suffix=[eos, tgt_lang_code]."),this.h()},l(t){const h=wr('[data-svelte="svelte-1phssyn"]',document.head);g=o(h,"META",{name:!0,content:!0}),h.forEach(n),x=c(t),$=o(t,"H1",{class:!0});var Ie=s($);u=o(Ie,"A",{id:!0,class:!0,href:!0});var Vt=s(u);T=o(Vt,"SPAN",{});var as=s(T);k(f.$$.fragment,as),as.forEach(n),Vt.forEach(n),E=c(Ie),rt=o(Ie,"SPAN",{});var os=s(rt);Gn=l(os,"NLLB"),os.forEach(n),Ie.forEach(n),Qt=c(t),D=o(t,"P",{});var Yt=s(D);lt=o(Yt,"STRONG",{});var ss=s(lt);Hn=l(ss,"DISCLAIMER:"),ss.forEach(n),Un=l(Yt," If you see something strange, file a "),ce=o(Yt,"A",{href:!0,rel:!0});var rs=s(ce);Rn=l(rs,"Github Issue"),rs.forEach(n),Wn=l(Yt,` and assign
@LysandreJik`),Yt.forEach(n),Zt=c(t),B=o(t,"H2",{class:!0});var wn=s(B);X=o(wn,"A",{id:!0,class:!0,href:!0});var ls=s(X);it=o(ls,"SPAN",{});var is=s(it);k(de.$$.fragment,is),is.forEach(n),ls.forEach(n),Jn=c(wn),ct=o(wn,"SPAN",{});var cs=s(ct);Xn=l(cs,"Overview of NLLB"),cs.forEach(n),wn.forEach(n),en=c(t),K=o(t,"P",{});var yn=s(K);Kn=l(yn,"The NLLB model was presented in "),he=o(yn,"A",{href:!0,rel:!0});var ds=s(he);Vn=l(ds,"No Language Left Behind: Scaling Human-Centered Machine Translation"),ds.forEach(n),Yn=l(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(n),tn=c(t),Ue=o(t,"P",{});var hs=s(Ue);Qn=l(hs,"The abstract of the paper is the following:"),hs.forEach(n),nn=c(t),Re=o(t,"P",{});var ps=s(Re);dt=o(ps,"EM",{});var fs=s(dt);Zn=l(fs,`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.`),fs.forEach(n),ps.forEach(n),an=c(t),We=o(t,"P",{});var us=s(We);ea=l(us,"This implementation contains the dense models available on release. Let us know via a GitHub issue if you would like to see the MoE models as well."),us.forEach(n),on=c(t),A=o(t,"P",{});var Ze=s(A);ta=l(Ze,"This model was contributed by "),pe=o(Ze,"A",{href:!0,rel:!0});var gs=s(pe);na=l(gs,"Lysandre"),gs.forEach(n),aa=l(Ze,". The authors\u2019 code can be found "),fe=o(Ze,"A",{href:!0,rel:!0});var ms=s(fe);oa=l(ms,"here"),ms.forEach(n),sa=l(Ze,"."),Ze.forEach(n),sn=c(t),I=o(t,"H2",{class:!0});var $n=s(I);V=o($n,"A",{id:!0,class:!0,href:!0});var _s=s(V);ht=o(_s,"SPAN",{});var ks=s(ht);k(ue.$$.fragment,ks),ks.forEach(n),_s.forEach(n),ra=c($n),pt=o($n,"SPAN",{});var bs=s(pt);la=l(bs,"Generating with NLLB"),bs.forEach(n),$n.forEach(n),rn=c(t),P=o(t,"P",{});var et=s(P);ia=l(et,"While generating the target text set the "),ft=o(et,"CODE",{});var vs=s(ft);ca=l(vs,"forced_bos_token_id"),vs.forEach(n),da=l(et,` to the target language id. The following
example shows how to translate English to French using the `),ut=o(et,"EM",{});var ws=s(ut);ha=l(ws,"facebook/nllb-200-distilled-600M"),ws.forEach(n),pa=l(et," model."),et.forEach(n),ln=c(t),F=o(t,"P",{});var tt=s(F);fa=l(tt,"Note that we\u2019re using the BCP-47 code for French "),gt=o(tt,"CODE",{});var ys=s(gt);ua=l(ys,"fra_Latn"),ys.forEach(n),ga=l(tt,". See "),ge=o(tt,"A",{href:!0,rel:!0});var $s=s(ge);ma=l($s,"here"),$s.forEach(n),_a=l(tt,`
for the list of all BCP-47 in the Flores 200 dataset.`),tt.forEach(n),cn=c(t),k(me.$$.fragment,t),dn=c(t),O=o(t,"H3",{class:!0});var qn=s(O);Y=o(qn,"A",{id:!0,class:!0,href:!0});var qs=s(Y);mt=o(qs,"SPAN",{});var Es=s(mt);k(_e.$$.fragment,Es),Es.forEach(n),qs.forEach(n),ka=c(qn),_t=o(qn,"SPAN",{});var zs=s(_t);ba=l(zs,"Generating from any other language than English"),zs.forEach(n),qn.forEach(n),hn=c(t),M=o(t,"P",{});var nt=s(M);va=l(nt,"English ("),kt=o(nt,"CODE",{});var Ts=s(kt);wa=l(Ts,"eng_Latn"),Ts.forEach(n),ya=l(nt,`) 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 `),bt=o(nt,"CODE",{});var Ns=s(bt);$a=l(Ns,"src_lang"),Ns.forEach(n),qa=l(nt," keyword argument of the tokenizer initialization."),nt.forEach(n),pn=c(t),Je=o(t,"P",{});var xs=s(Je);Ea=l(xs,"See example below for a translation from romanian to german:"),xs.forEach(n),fn=c(t),k(ke.$$.fragment,t),un=c(t),G=o(t,"H2",{class:!0});var En=s(G);Q=o(En,"A",{id:!0,class:!0,href:!0});var Ls=s(Q);vt=o(Ls,"SPAN",{});var Ss=s(vt);k(be.$$.fragment,Ss),Ss.forEach(n),Ls.forEach(n),za=c(En),wt=o(En,"SPAN",{});var js=s(wt);Ta=l(js,"Documentation resources"),js.forEach(n),En.forEach(n),gn=c(t),Z=o(t,"UL",{});var zn=s(Z);yt=o(zn,"LI",{});var As=s(yt);Xe=o(As,"A",{href:!0});var Ps=s(Xe);Na=l(Ps,"Translation task guide"),Ps.forEach(n),As.forEach(n),xa=c(zn),$t=o(zn,"LI",{});var Fs=s($t);Ke=o(Fs,"A",{href:!0});var Ms=s(Ke);La=l(Ms,"Summarization task guide"),Ms.forEach(n),Fs.forEach(n),zn.forEach(n),mn=c(t),H=o(t,"H2",{class:!0});var Tn=s(H);ee=o(Tn,"A",{id:!0,class:!0,href:!0});var Cs=s(ee);qt=o(Cs,"SPAN",{});var Ds=s(qt);k(ve.$$.fragment,Ds),Ds.forEach(n),Cs.forEach(n),Sa=c(Tn),Et=o(Tn,"SPAN",{});var Bs=s(Et);ja=l(Bs,"NllbTokenizer"),Bs.forEach(n),Tn.forEach(n),_n=c(t),z=o(t,"DIV",{class:!0});var S=s(z);k(we.$$.fragment,S),Aa=c(S),zt=o(S,"P",{});var Is=s(zt);Pa=l(Is,"Construct an NLLB tokenizer."),Is.forEach(n),Fa=c(S),j=o(S,"P",{});var le=s(j);Ma=l(le,"Adapted from "),Ve=o(le,"A",{href:!0});var Os=s(Ve);Ca=l(Os,"RobertaTokenizer"),Os.forEach(n),Da=l(le," and "),Ye=o(le,"A",{href:!0});var Gs=s(Ye);Ba=l(Gs,"XLNetTokenizer"),Gs.forEach(n),Ia=l(le,`. Based on
`),ye=o(le,"A",{href:!0,rel:!0});var Hs=s(ye);Oa=l(Hs,"SentencePiece"),Hs.forEach(n),Ga=l(le,"."),le.forEach(n),Ha=c(S),U=o(S,"P",{});var at=s(U);Ua=l(at,"The tokenization method is "),Tt=o(at,"CODE",{});var Us=s(Tt);Ra=l(Us,"<tokens> <eos> <language code>"),Us.forEach(n),Wa=l(at," for source language documents, and "),Nt=o(at,"CODE",{});var Rs=s(Nt);Ja=l(Rs,"<language code> <tokens> <eos>"),Rs.forEach(n),Xa=l(at," for target language documents."),at.forEach(n),Ka=c(S),k(te.$$.fragment,S),Va=c(S),L=o(S,"DIV",{class:!0});var ie=s(L);k($e.$$.fragment,ie),Ya=c(ie),qe=o(ie,"P",{});var Nn=s(qe);Qa=l(Nn,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An NLLB sequence has the following format, where `),xt=o(Nn,"CODE",{});var Ws=s(xt);Za=l(Ws,"X"),Ws.forEach(n),eo=l(Nn," represents the sequence:"),Nn.forEach(n),to=c(ie),Ee=o(ie,"UL",{});var xn=s(Ee);ze=o(xn,"LI",{});var Ln=s(ze);Lt=o(Ln,"CODE",{});var Js=s(Lt);no=l(Js,"input_ids"),Js.forEach(n),ao=l(Ln," (for encoder) "),St=o(Ln,"CODE",{});var Xs=s(St);oo=l(Xs,"X [eos, src_lang_code]"),Xs.forEach(n),Ln.forEach(n),so=c(xn),Te=o(xn,"LI",{});var Sn=s(Te);jt=o(Sn,"CODE",{});var Ks=s(jt);ro=l(Ks,"decoder_input_ids"),Ks.forEach(n),lo=l(Sn,": (for decoder) "),At=o(Sn,"CODE",{});var Vs=s(At);io=l(Vs,"X [eos, tgt_lang_code]"),Vs.forEach(n),Sn.forEach(n),xn.forEach(n),co=c(ie),Pt=o(ie,"P",{});var Ys=s(Pt);ho=l(Ys,`BOS is never used. Pairs of sequences are not the expected use case, but they will be handled without a
separator.`),Ys.forEach(n),ie.forEach(n),S.forEach(n),kn=c(t),R=o(t,"H2",{class:!0});var jn=s(R);ne=o(jn,"A",{id:!0,class:!0,href:!0});var Qs=s(ne);Ft=o(Qs,"SPAN",{});var Zs=s(Ft);k(Ne.$$.fragment,Zs),Zs.forEach(n),Qs.forEach(n),po=c(jn),Mt=o(jn,"SPAN",{});var er=s(Mt);fo=l(er,"NllbTokenizerFast"),er.forEach(n),jn.forEach(n),bn=c(t),m=o(t,"DIV",{class:!0});var q=s(m);k(xe.$$.fragment,q),uo=c(q),W=o(q,"P",{});var ot=s(W);go=l(ot,"Construct a \u201Cfast\u201D NLLB tokenizer (backed by HuggingFace\u2019s "),Ct=o(ot,"EM",{});var tr=s(Ct);mo=l(tr,"tokenizers"),tr.forEach(n),_o=l(ot,` library). Based on
`),Le=o(ot,"A",{href:!0,rel:!0});var nr=s(Le);ko=l(nr,"BPE"),nr.forEach(n),bo=l(ot,"."),ot.forEach(n),vo=c(q),Se=o(q,"P",{});var An=s(Se);wo=l(An,"This tokenizer inherits from "),Qe=o(An,"A",{href:!0});var ar=s(Qe);yo=l(ar,"PreTrainedTokenizerFast"),ar.forEach(n),$o=l(An,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),An.forEach(n),qo=c(q),J=o(q,"P",{});var st=s(J);Eo=l(st,"The tokenization method is "),Dt=o(st,"CODE",{});var or=s(Dt);zo=l(or,"<tokens> <eos> <language code>"),or.forEach(n),To=l(st," for source language documents, and "),Bt=o(st,"CODE",{});var sr=s(Bt);No=l(sr,"<language code> <tokens> <eos>"),sr.forEach(n),xo=l(st," for target language documents."),st.forEach(n),Lo=c(q),k(ae.$$.fragment,q),So=c(q),N=o(q,"DIV",{class:!0});var C=s(N);k(je.$$.fragment,C),jo=c(C),It=o(C,"P",{});var rr=s(It);Ao=l(rr,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. The special tokens depend on calling set_lang.`),rr.forEach(n),Po=c(C),Ae=o(C,"P",{});var Pn=s(Ae);Fo=l(Pn,"An NLLB sequence has the following format, where "),Ot=o(Pn,"CODE",{});var lr=s(Ot);Mo=l(lr,"X"),lr.forEach(n),Co=l(Pn," represents the sequence:"),Pn.forEach(n),Do=c(C),Pe=o(C,"UL",{});var Fn=s(Pe);Fe=o(Fn,"LI",{});var Mn=s(Fe);Gt=o(Mn,"CODE",{});var ir=s(Gt);Bo=l(ir,"input_ids"),ir.forEach(n),Io=l(Mn," (for encoder) "),Ht=o(Mn,"CODE",{});var cr=s(Ht);Oo=l(cr,"X [eos, src_lang_code]"),cr.forEach(n),Mn.forEach(n),Go=c(Fn),Me=o(Fn,"LI",{});var Cn=s(Me);Ut=o(Cn,"CODE",{});var dr=s(Ut);Ho=l(dr,"decoder_input_ids"),dr.forEach(n),Uo=l(Cn,": (for decoder) "),Rt=o(Cn,"CODE",{});var hr=s(Rt);Ro=l(hr,"X [eos, tgt_lang_code]"),hr.forEach(n),Cn.forEach(n),Fn.forEach(n),Wo=c(C),Wt=o(C,"P",{});var pr=s(Wt);Jo=l(pr,`BOS is never used. Pairs of sequences are not the expected use case, but they will be handled without a
separator.`),pr.forEach(n),C.forEach(n),Xo=c(q),oe=o(q,"DIV",{class:!0});var Dn=s(oe);k(Ce.$$.fragment,Dn),Ko=c(Dn),Jt=o(Dn,"P",{});var fr=s(Jt);Vo=l(fr,`Create a mask from the two sequences passed to be used in a sequence-pair classification task. nllb does not
make use of token type ids, therefore a list of zeros is returned.`),fr.forEach(n),Dn.forEach(n),Yo=c(q),se=o(q,"DIV",{class:!0});var Bn=s(se);k(De.$$.fragment,Bn),Qo=c(Bn),Xt=o(Bn,"P",{});var ur=s(Xt);Zo=l(ur,"Reset the special tokens to the source lang setting. No prefix and suffix=[eos, src_lang_code]."),ur.forEach(n),Bn.forEach(n),es=c(q),re=o(q,"DIV",{class:!0});var In=s(re);k(Be.$$.fragment,In),ts=c(In),Kt=o(In,"P",{});var gr=s(Kt);ns=l(gr,"Reset the special tokens to the target language setting. No prefix and suffix=[eos, tgt_lang_code]."),gr.forEach(n),In.forEach(n),q.forEach(n),this.h()},h(){d(g,"name","hf:doc:metadata"),d(g,"content",JSON.stringify(zr)),d(u,"id","nllb"),d(u,"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"),d(u,"href","#nllb"),d($,"class","relative group"),d(ce,"href","https://github.com/huggingface/transformers/issues/new?assignees=&labels=bug&template=bug-report.yml"),d(ce,"rel","nofollow"),d(X,"id","overview-of-nllb"),d(X,"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"),d(X,"href","#overview-of-nllb"),d(B,"class","relative group"),d(he,"href","https://arxiv.org/abs/2207.04672"),d(he,"rel","nofollow"),d(pe,"href","https://huggingface.co/lysandre"),d(pe,"rel","nofollow"),d(fe,"href","https://github.com/facebookresearch/fairseq/tree/nllb"),d(fe,"rel","nofollow"),d(V,"id","generating-with-nllb"),d(V,"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"),d(V,"href","#generating-with-nllb"),d(I,"class","relative group"),d(ge,"href","https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200"),d(ge,"rel","nofollow"),d(Y,"id","generating-from-any-other-language-than-english"),d(Y,"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"),d(Y,"href","#generating-from-any-other-language-than-english"),d(O,"class","relative group"),d(Q,"id","documentation-resources"),d(Q,"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"),d(Q,"href","#documentation-resources"),d(G,"class","relative group"),d(Xe,"href","./tasks/translation"),d(Ke,"href","./tasks/summarization"),d(ee,"id","transformers.NllbTokenizer"),d(ee,"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"),d(ee,"href","#transformers.NllbTokenizer"),d(H,"class","relative group"),d(Ve,"href","/docs/transformers/v4.27.1/en/model_doc/roberta#transformers.RobertaTokenizer"),d(Ye,"href","/docs/transformers/v4.27.1/en/model_doc/xlnet#transformers.XLNetTokenizer"),d(ye,"href","https://github.com/google/sentencepiece"),d(ye,"rel","nofollow"),d(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ne,"id","transformers.NllbTokenizerFast"),d(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"),d(ne,"href","#transformers.NllbTokenizerFast"),d(R,"class","relative group"),d(Le,"href","https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models"),d(Le,"rel","nofollow"),d(Qe,"href","/docs/transformers/v4.27.1/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),d(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,h){e(document.head,g),p(t,x,h),p(t,$,h),e($,u),e(u,T),b(f,T,null),e($,E),e($,rt),e(rt,Gn),p(t,Qt,h),p(t,D,h),e(D,lt),e(lt,Hn),e(D,Un),e(D,ce),e(ce,Rn),e(D,Wn),p(t,Zt,h),p(t,B,h),e(B,X),e(X,it),b(de,it,null),e(B,Jn),e(B,ct),e(ct,Xn),p(t,en,h),p(t,K,h),e(K,Kn),e(K,he),e(he,Vn),e(K,Yn),p(t,tn,h),p(t,Ue,h),e(Ue,Qn),p(t,nn,h),p(t,Re,h),e(Re,dt),e(dt,Zn),p(t,an,h),p(t,We,h),e(We,ea),p(t,on,h),p(t,A,h),e(A,ta),e(A,pe),e(pe,na),e(A,aa),e(A,fe),e(fe,oa),e(A,sa),p(t,sn,h),p(t,I,h),e(I,V),e(V,ht),b(ue,ht,null),e(I,ra),e(I,pt),e(pt,la),p(t,rn,h),p(t,P,h),e(P,ia),e(P,ft),e(ft,ca),e(P,da),e(P,ut),e(ut,ha),e(P,pa),p(t,ln,h),p(t,F,h),e(F,fa),e(F,gt),e(gt,ua),e(F,ga),e(F,ge),e(ge,ma),e(F,_a),p(t,cn,h),b(me,t,h),p(t,dn,h),p(t,O,h),e(O,Y),e(Y,mt),b(_e,mt,null),e(O,ka),e(O,_t),e(_t,ba),p(t,hn,h),p(t,M,h),e(M,va),e(M,kt),e(kt,wa),e(M,ya),e(M,bt),e(bt,$a),e(M,qa),p(t,pn,h),p(t,Je,h),e(Je,Ea),p(t,fn,h),b(ke,t,h),p(t,un,h),p(t,G,h),e(G,Q),e(Q,vt),b(be,vt,null),e(G,za),e(G,wt),e(wt,Ta),p(t,gn,h),p(t,Z,h),e(Z,yt),e(yt,Xe),e(Xe,Na),e(Z,xa),e(Z,$t),e($t,Ke),e(Ke,La),p(t,mn,h),p(t,H,h),e(H,ee),e(ee,qt),b(ve,qt,null),e(H,Sa),e(H,Et),e(Et,ja),p(t,_n,h),p(t,z,h),b(we,z,null),e(z,Aa),e(z,zt),e(zt,Pa),e(z,Fa),e(z,j),e(j,Ma),e(j,Ve),e(Ve,Ca),e(j,Da),e(j,Ye),e(Ye,Ba),e(j,Ia),e(j,ye),e(ye,Oa),e(j,Ga),e(z,Ha),e(z,U),e(U,Ua),e(U,Tt),e(Tt,Ra),e(U,Wa),e(U,Nt),e(Nt,Ja),e(U,Xa),e(z,Ka),b(te,z,null),e(z,Va),e(z,L),b($e,L,null),e(L,Ya),e(L,qe),e(qe,Qa),e(qe,xt),e(xt,Za),e(qe,eo),e(L,to),e(L,Ee),e(Ee,ze),e(ze,Lt),e(Lt,no),e(ze,ao),e(ze,St),e(St,oo),e(Ee,so),e(Ee,Te),e(Te,jt),e(jt,ro),e(Te,lo),e(Te,At),e(At,io),e(L,co),e(L,Pt),e(Pt,ho),p(t,kn,h),p(t,R,h),e(R,ne),e(ne,Ft),b(Ne,Ft,null),e(R,po),e(R,Mt),e(Mt,fo),p(t,bn,h),p(t,m,h),b(xe,m,null),e(m,uo),e(m,W),e(W,go),e(W,Ct),e(Ct,mo),e(W,_o),e(W,Le),e(Le,ko),e(W,bo),e(m,vo),e(m,Se),e(Se,wo),e(Se,Qe),e(Qe,yo),e(Se,$o),e(m,qo),e(m,J),e(J,Eo),e(J,Dt),e(Dt,zo),e(J,To),e(J,Bt),e(Bt,No),e(J,xo),e(m,Lo),b(ae,m,null),e(m,So),e(m,N),b(je,N,null),e(N,jo),e(N,It),e(It,Ao),e(N,Po),e(N,Ae),e(Ae,Fo),e(Ae,Ot),e(Ot,Mo),e(Ae,Co),e(N,Do),e(N,Pe),e(Pe,Fe),e(Fe,Gt),e(Gt,Bo),e(Fe,Io),e(Fe,Ht),e(Ht,Oo),e(Pe,Go),e(Pe,Me),e(Me,Ut),e(Ut,Ho),e(Me,Uo),e(Me,Rt),e(Rt,Ro),e(N,Wo),e(N,Wt),e(Wt,Jo),e(m,Xo),e(m,oe),b(Ce,oe,null),e(oe,Ko),e(oe,Jt),e(Jt,Vo),e(m,Yo),e(m,se),b(De,se,null),e(se,Qo),e(se,Xt),e(Xt,Zo),e(m,es),e(m,re),b(Be,re,null),e(re,ts),e(re,Kt),e(Kt,ns),vn=!0},p(t,[h]){const Ie={};h&2&&(Ie.$$scope={dirty:h,ctx:t}),te.$set(Ie);const Vt={};h&2&&(Vt.$$scope={dirty:h,ctx:t}),ae.$set(Vt)},i(t){vn||(v(f.$$.fragment,t),v(de.$$.fragment,t),v(ue.$$.fragment,t),v(me.$$.fragment,t),v(_e.$$.fragment,t),v(ke.$$.fragment,t),v(be.$$.fragment,t),v(ve.$$.fragment,t),v(we.$$.fragment,t),v(te.$$.fragment,t),v($e.$$.fragment,t),v(Ne.$$.fragment,t),v(xe.$$.fragment,t),v(ae.$$.fragment,t),v(je.$$.fragment,t),v(Ce.$$.fragment,t),v(De.$$.fragment,t),v(Be.$$.fragment,t),vn=!0)},o(t){w(f.$$.fragment,t),w(de.$$.fragment,t),w(ue.$$.fragment,t),w(me.$$.fragment,t),w(_e.$$.fragment,t),w(ke.$$.fragment,t),w(be.$$.fragment,t),w(ve.$$.fragment,t),w(we.$$.fragment,t),w(te.$$.fragment,t),w($e.$$.fragment,t),w(Ne.$$.fragment,t),w(xe.$$.fragment,t),w(ae.$$.fragment,t),w(je.$$.fragment,t),w(Ce.$$.fragment,t),w(De.$$.fragment,t),w(Be.$$.fragment,t),vn=!1},d(t){n(g),t&&n(x),t&&n($),y(f),t&&n(Qt),t&&n(D),t&&n(Zt),t&&n(B),y(de),t&&n(en),t&&n(K),t&&n(tn),t&&n(Ue),t&&n(nn),t&&n(Re),t&&n(an),t&&n(We),t&&n(on),t&&n(A),t&&n(sn),t&&n(I),y(ue),t&&n(rn),t&&n(P),t&&n(ln),t&&n(F),t&&n(cn),y(me,t),t&&n(dn),t&&n(O),y(_e),t&&n(hn),t&&n(M),t&&n(pn),t&&n(Je),t&&n(fn),y(ke,t),t&&n(un),t&&n(G),y(be),t&&n(gn),t&&n(Z),t&&n(mn),t&&n(H),y(ve),t&&n(_n),t&&n(z),y(we),y(te),y($e),t&&n(kn),t&&n(R),y(Ne),t&&n(bn),t&&n(m),y(xe),y(ae),y(je),y(Ce),y(De),y(Be)}}}const zr={local:"nllb",sections:[{local:"overview-of-nllb",title:"Overview of NLLB"},{local:"generating-with-nllb",sections:[{local:"generating-from-any-other-language-than-english",title:"Generating from any other language than English"}],title:"Generating with NLLB"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.NllbTokenizer",title:"NllbTokenizer"},{local:"transformers.NllbTokenizerFast",title:"NllbTokenizerFast"}],title:"NLLB"};function Tr(He){return yr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ar extends kr{constructor(g){super();br(this,g,Tr,Er,vr,{})}}export{Ar as default,zr as metadata};
