import{S as $o,i as xo,s as Io,e as s,k as c,w as _,t as r,M as Vo,c as n,d as o,m as d,a,x as k,h as i,b as p,G as t,g as h,y as b,L as Co,q as v,o as y,B as T,v as Wo}from"../../chunks/vendor-hf-doc-builder.js";import{D as Re}from"../../chunks/Docstring-hf-doc-builder.js";import{C as jo}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as eo}from"../../chunks/IconCopyLink-hf-doc-builder.js";function Lo(to){let w,Je,B,J,me,x,et,ue,tt,qe,M,q,fe,I,ot,ge,st,Ee,E,nt,V,at,rt,Ae,K,it,Ue,ee,_e,lt,je,te,pt,$e,C,xe,oe,ct,Ie,se,W,dt,ne,ht,mt,Ve,L,Ce,ae,ke,ut,We,f,ft,Z,gt,_t,P,kt,bt,Le,z,A,be,X,vt,ve,yt,Ze,m,S,Tt,R,wt,re,Bt,Mt,F,zt,Rt,Jt,N,qt,ie,Et,At,Ut,g,Q,jt,ye,$t,xt,H,le,It,Te,Vt,Ct,pe,Wt,we,Lt,Zt,U,D,Pt,Be,Xt,St,j,G,Ft,Me,Nt,Qt,$,Y,Ht,O,Dt,ze,Gt,Yt,Pe;return x=new eo({}),I=new eo({}),C=new jo({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQWJhcnRwaG8lMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnZpbmFpJTJGYmFydHBoby1zeWxsYWJsZSUyMiklMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ2aW5haSUyRmJhcnRwaG8tc3lsbGFibGUlMjIpJTBBJTBBbGluZSUyMCUzRCUyMCUyMkNoJUMzJUJBbmclMjB0JUMzJUI0aSUyMGwlQzMlQTAlMjBuaCVFMSVCQiVBRm5nJTIwbmdoaSVDMyVBQW4lMjBjJUUxJUJCJUE5dSUyMHZpJUMzJUFBbi4lMjIlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIobGluZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGZlYXR1cmVzJTIwJTNEJTIwYmFydHBobygqKmlucHV0X2lkcyklMjAlMjAlMjMlMjBNb2RlbHMlMjBvdXRwdXRzJTIwYXJlJTIwbm93JTIwdHVwbGVzJTBBJTBBJTIzJTIwV2l0aCUyMFRlbnNvckZsb3clMjAyLjAlMkIlM0ElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVEZBdXRvTW9kZWwlMEElMEFiYXJ0cGhvJTIwJTNEJTIwVEZBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnZpbmFpJTJGYmFydHBoby1zeWxsYWJsZSUyMiklMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIobGluZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBZmVhdHVyZXMlMjAlM0QlMjBiYXJ0cGhvKCoqaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>bartpho = AutoModel.from_pretrained(<span class="hljs-string">&quot;vinai/bartpho-syllable&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;vinai/bartpho-syllable&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>line = <span class="hljs-string">&quot;Ch\xFAng t\xF4i l\xE0 nh\u1EEFng nghi\xEAn c\u1EE9u vi\xEAn.&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(line, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    features = bartpho(**input_ids)  <span class="hljs-comment"># Models outputs are now tuples</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># With TensorFlow 2.0+:</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>bartpho = TFAutoModel.from_pretrained(<span class="hljs-string">&quot;vinai/bartpho-syllable&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(line, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>features = bartpho(**input_ids)`}}),L=new jo({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME1CYXJ0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBYmFydHBobyUyMCUzRCUyME1CYXJ0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJ2aW5haSUyRmJhcnRwaG8tc3lsbGFibGUlMjIpJTBBVFhUJTIwJTNEJTIwJTIyQ2glQzMlQkFuZyUyMHQlQzMlQjRpJTIwbCVDMyVBMCUyMCUzQ21hc2slM0UlMjBuZ2hpJUMzJUFBbiUyMGMlRTElQkIlQTl1JTIwdmklQzMlQUFuLiUyMiUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglNUJUWFQlNUQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQWxvZ2l0cyUyMCUzRCUyMGJhcnRwaG8oaW5wdXRfaWRzKS5sb2dpdHMlMEFtYXNrZWRfaW5kZXglMjAlM0QlMjAoaW5wdXRfaWRzJTVCMCU1RCUyMCUzRCUzRCUyMHRva2VuaXplci5tYXNrX3Rva2VuX2lkKS5ub256ZXJvKCkuaXRlbSgpJTBBcHJvYnMlMjAlM0QlMjBsb2dpdHMlNUIwJTJDJTIwbWFza2VkX2luZGV4JTVELnNvZnRtYXgoZGltJTNEMCklMEF2YWx1ZXMlMkMlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMHByb2JzLnRvcGsoNSklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKHByZWRpY3Rpb25zKS5zcGxpdCgpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MBartForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>bartpho = MBartForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;vinai/bartpho-syllable&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>TXT = <span class="hljs-string">&quot;Ch\xFAng t\xF4i l\xE0 &lt;mask&gt; nghi\xEAn c\u1EE9u vi\xEAn.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer([TXT], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = bartpho(input_ids).logits
<span class="hljs-meta">&gt;&gt;&gt; </span>masked_index = (input_ids[<span class="hljs-number">0</span>] == tokenizer.mask_token_id).nonzero().item()
<span class="hljs-meta">&gt;&gt;&gt; </span>probs = logits[<span class="hljs-number">0</span>, masked_index].softmax(dim=<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>values, predictions = probs.topk(<span class="hljs-number">5</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.decode(predictions).split())`}}),X=new eo({}),S=new Re({props:{name:"class transformers.BartphoTokenizer",anchor:"transformers.BartphoTokenizer",parameters:[{name:"vocab_file",val:""},{name:"monolingual_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:"sp_model_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.BartphoTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file. This vocabulary is the pre-trained SentencePiece model available from the
multilingual XLM-RoBERTa, also used in mBART, consisting of 250K types.`,name:"vocab_file"},{anchor:"transformers.BartphoTokenizer.monolingual_vocab_file",description:`<strong>monolingual_vocab_file</strong> (<code>str</code>) &#x2014;
Path to the monolingual vocabulary file. This monolingual vocabulary consists of Vietnamese-specialized
types extracted from the multilingual vocabulary vocab_file of 250K types.`,name:"monolingual_vocab_file"},{anchor:"transformers.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.additional_special_tokens",description:`<strong>additional_special_tokens</strong> (<code>List[str]</code>, <em>optional</em>, defaults to <code>[&quot;&lt;s&gt;NOTUSED&quot;, &quot;&lt;/s&gt;NOTUSED&quot;]</code>) &#x2014;
Additional special tokens used by the tokenizer.`,name:"additional_special_tokens"},{anchor:"transformers.BartphoTokenizer.sp_model_kwargs",description:`<strong>sp_model_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Will be passed to the <code>SentencePieceProcessor.__init__()</code> method. The <a href="https://github.com/google/sentencepiece/tree/master/python" rel="nofollow">Python wrapper for
SentencePiece</a> can be used, among other things,
to set:</p>
<ul>
<li>
<p><code>enable_sampling</code>: Enable subword regularization.</p>
</li>
<li>
<p><code>nbest_size</code>: Sampling parameters for unigram. Invalid for BPE-Dropout.</p>
<ul>
<li><code>nbest_size = {0,1}</code>: No sampling is performed.</li>
<li><code>nbest_size &gt; 1</code>: samples from the nbest_size results.</li>
<li><code>nbest_size &lt; 0</code>: assuming that nbest_size is infinite and samples from the all hypothesis (lattice)
using forward-filtering-and-backward-sampling algorithm.</li>
</ul>
</li>
<li>
<p><code>alpha</code>: Smoothing parameter for unigram sampling, and dropout probability of merge operations for
BPE-dropout.</p>
</li>
</ul>`,name:"sp_model_kwargs"},{anchor:"transformers.BartphoTokenizer.sp_model",description:`<strong>sp_model</strong> (<code>SentencePieceProcessor</code>) &#x2014;
The <em>SentencePiece</em> processor that is used for every conversion (string, tokens and IDs).`,name:"sp_model"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/bartpho/tokenization_bartpho.py#L46"}}),Q=new Re({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.31.0/src/transformers/models/bartpho/tokenization_bartpho.py#L193",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>
`}}),D=new Re({props:{name:"convert_tokens_to_string",anchor:"transformers.BartphoTokenizer.convert_tokens_to_string",parameters:[{name:"tokens",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/bartpho/tokenization_bartpho.py#L295"}}),G=new Re({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.BartphoTokenizer.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.BartphoTokenizer.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.BartphoTokenizer.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.31.0/src/transformers/models/bartpho/tokenization_bartpho.py#L247",returnDescription:`
<p>List of zeros.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),Y=new Re({props:{name:"get_special_tokens_mask",anchor:"transformers.BartphoTokenizer.get_special_tokens_mask",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"},{name:"already_has_special_tokens",val:": bool = False"}],parametersDescription:[{anchor:"transformers.BartphoTokenizer.get_special_tokens_mask.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.BartphoTokenizer.get_special_tokens_mask.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"},{anchor:"transformers.BartphoTokenizer.get_special_tokens_mask.already_has_special_tokens",description:`<strong>already_has_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the token list is already formatted with special tokens for the model.`,name:"already_has_special_tokens"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/bartpho/tokenization_bartpho.py#L219",returnDescription:`
<p>A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),{c(){w=s("meta"),Je=c(),B=s("h1"),J=s("a"),me=s("span"),_(x.$$.fragment),et=c(),ue=s("span"),tt=r("BARTpho"),qe=c(),M=s("h2"),q=s("a"),fe=s("span"),_(I.$$.fragment),ot=c(),ge=s("span"),st=r("Overview"),Ee=c(),E=s("p"),nt=r("The BARTpho model was proposed in "),V=s("a"),at=r("BARTpho: Pre-trained Sequence-to-Sequence Models for Vietnamese"),rt=r(" by Nguyen Luong Tran, Duong Minh Le and Dat Quoc Nguyen."),Ae=c(),K=s("p"),it=r("The abstract from the paper is the following:"),Ue=c(),ee=s("p"),_e=s("em"),lt=r(`We present BARTpho with two versions \u2014 BARTpho_word and BARTpho_syllable \u2014 the first public large-scale monolingual
sequence-to-sequence models pre-trained for Vietnamese. Our BARTpho uses the \u201Clarge\u201D architecture and pre-training
scheme of the sequence-to-sequence denoising model BART, thus especially suitable for generative NLP tasks. Experiments
on a downstream task of Vietnamese text summarization show that in both automatic and human evaluations, our BARTpho
outperforms the strong baseline mBART and improves the state-of-the-art. We release BARTpho to facilitate future
research and applications of generative Vietnamese NLP tasks.`),je=c(),te=s("p"),pt=r("Example of use:"),$e=c(),_(C.$$.fragment),xe=c(),oe=s("p"),ct=r("Tips:"),Ie=c(),se=s("ul"),W=s("li"),dt=r(`Following mBART, BARTpho uses the \u201Clarge\u201D architecture of BART with an additional layer-normalization layer on top of
both the encoder and decoder. Thus, usage examples in the `),ne=s("a"),ht=r("documentation of BART"),mt=r(`, when adapting to use
with BARTpho, should be adjusted by replacing the BART-specialized classes with the mBART-specialized counterparts.
For example:`),Ve=c(),_(L.$$.fragment),Ce=c(),ae=s("ul"),ke=s("li"),ut=r(`This implementation is only for tokenization: \u201Cmonolingual_vocab_file\u201D consists of Vietnamese-specialized types
extracted from the pre-trained SentencePiece model \u201Cvocab_file\u201D that is available from the multilingual XLM-RoBERTa.
Other languages, if employing this pre-trained multilingual SentencePiece model \u201Cvocab_file\u201D for subword
segmentation, can reuse BartphoTokenizer with their own language-specialized \u201Cmonolingual_vocab_file\u201D.`),We=c(),f=s("p"),ft=r("This model was contributed by "),Z=s("a"),gt=r("dqnguyen"),_t=r(". The original code can be found "),P=s("a"),kt=r("here"),bt=r("."),Le=c(),z=s("h2"),A=s("a"),be=s("span"),_(X.$$.fragment),vt=c(),ve=s("span"),yt=r("BartphoTokenizer"),Ze=c(),m=s("div"),_(S.$$.fragment),Tt=c(),R=s("p"),wt=r("Adapted from "),re=s("a"),Bt=r("XLMRobertaTokenizer"),Mt=r(". Based on "),F=s("a"),zt=r("SentencePiece"),Rt=r("."),Jt=c(),N=s("p"),qt=r("This tokenizer inherits from "),ie=s("a"),Et=r("PreTrainedTokenizer"),At=r(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Ut=c(),g=s("div"),_(Q.$$.fragment),jt=c(),ye=s("p"),$t=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An BARTPho sequence has the following format:`),xt=c(),H=s("ul"),le=s("li"),It=r("single sequence: "),Te=s("code"),Vt=r("<s> X </s>"),Ct=c(),pe=s("li"),Wt=r("pair of sequences: "),we=s("code"),Lt=r("<s> A </s></s> B </s>"),Zt=c(),U=s("div"),_(D.$$.fragment),Pt=c(),Be=s("p"),Xt=r("Converts a sequence of tokens (strings for sub-words) in a single string."),St=c(),j=s("div"),_(G.$$.fragment),Ft=c(),Me=s("p"),Nt=r(`Create a mask from the two sequences passed to be used in a sequence-pair classification task. BARTPho does not
make use of token type ids, therefore a list of zeros is returned.`),Qt=c(),$=s("div"),_(Y.$$.fragment),Ht=c(),O=s("p"),Dt=r(`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),ze=s("code"),Gt=r("prepare_for_model"),Yt=r(" method."),this.h()},l(e){const l=Vo('[data-svelte="svelte-1phssyn"]',document.head);w=n(l,"META",{name:!0,content:!0}),l.forEach(o),Je=d(e),B=n(e,"H1",{class:!0});var Xe=a(B);J=n(Xe,"A",{id:!0,class:!0,href:!0});var oo=a(J);me=n(oo,"SPAN",{});var so=a(me);k(x.$$.fragment,so),so.forEach(o),oo.forEach(o),et=d(Xe),ue=n(Xe,"SPAN",{});var no=a(ue);tt=i(no,"BARTpho"),no.forEach(o),Xe.forEach(o),qe=d(e),M=n(e,"H2",{class:!0});var Se=a(M);q=n(Se,"A",{id:!0,class:!0,href:!0});var ao=a(q);fe=n(ao,"SPAN",{});var ro=a(fe);k(I.$$.fragment,ro),ro.forEach(o),ao.forEach(o),ot=d(Se),ge=n(Se,"SPAN",{});var io=a(ge);st=i(io,"Overview"),io.forEach(o),Se.forEach(o),Ee=d(e),E=n(e,"P",{});var Fe=a(E);nt=i(Fe,"The BARTpho model was proposed in "),V=n(Fe,"A",{href:!0,rel:!0});var lo=a(V);at=i(lo,"BARTpho: Pre-trained Sequence-to-Sequence Models for Vietnamese"),lo.forEach(o),rt=i(Fe," by Nguyen Luong Tran, Duong Minh Le and Dat Quoc Nguyen."),Fe.forEach(o),Ae=d(e),K=n(e,"P",{});var po=a(K);it=i(po,"The abstract from the paper is the following:"),po.forEach(o),Ue=d(e),ee=n(e,"P",{});var co=a(ee);_e=n(co,"EM",{});var ho=a(_e);lt=i(ho,`We present BARTpho with two versions \u2014 BARTpho_word and BARTpho_syllable \u2014 the first public large-scale monolingual
sequence-to-sequence models pre-trained for Vietnamese. Our BARTpho uses the \u201Clarge\u201D architecture and pre-training
scheme of the sequence-to-sequence denoising model BART, thus especially suitable for generative NLP tasks. Experiments
on a downstream task of Vietnamese text summarization show that in both automatic and human evaluations, our BARTpho
outperforms the strong baseline mBART and improves the state-of-the-art. We release BARTpho to facilitate future
research and applications of generative Vietnamese NLP tasks.`),ho.forEach(o),co.forEach(o),je=d(e),te=n(e,"P",{});var mo=a(te);pt=i(mo,"Example of use:"),mo.forEach(o),$e=d(e),k(C.$$.fragment,e),xe=d(e),oe=n(e,"P",{});var uo=a(oe);ct=i(uo,"Tips:"),uo.forEach(o),Ie=d(e),se=n(e,"UL",{});var fo=a(se);W=n(fo,"LI",{});var Ne=a(W);dt=i(Ne,`Following mBART, BARTpho uses the \u201Clarge\u201D architecture of BART with an additional layer-normalization layer on top of
both the encoder and decoder. Thus, usage examples in the `),ne=n(Ne,"A",{href:!0});var go=a(ne);ht=i(go,"documentation of BART"),go.forEach(o),mt=i(Ne,`, when adapting to use
with BARTpho, should be adjusted by replacing the BART-specialized classes with the mBART-specialized counterparts.
For example:`),Ne.forEach(o),fo.forEach(o),Ve=d(e),k(L.$$.fragment,e),Ce=d(e),ae=n(e,"UL",{});var _o=a(ae);ke=n(_o,"LI",{});var ko=a(ke);ut=i(ko,`This implementation is only for tokenization: \u201Cmonolingual_vocab_file\u201D consists of Vietnamese-specialized types
extracted from the pre-trained SentencePiece model \u201Cvocab_file\u201D that is available from the multilingual XLM-RoBERTa.
Other languages, if employing this pre-trained multilingual SentencePiece model \u201Cvocab_file\u201D for subword
segmentation, can reuse BartphoTokenizer with their own language-specialized \u201Cmonolingual_vocab_file\u201D.`),ko.forEach(o),_o.forEach(o),We=d(e),f=n(e,"P",{});var ce=a(f);ft=i(ce,"This model was contributed by "),Z=n(ce,"A",{href:!0,rel:!0});var bo=a(Z);gt=i(bo,"dqnguyen"),bo.forEach(o),_t=i(ce,". The original code can be found "),P=n(ce,"A",{href:!0,rel:!0});var vo=a(P);kt=i(vo,"here"),vo.forEach(o),bt=i(ce,"."),ce.forEach(o),Le=d(e),z=n(e,"H2",{class:!0});var Qe=a(z);A=n(Qe,"A",{id:!0,class:!0,href:!0});var yo=a(A);be=n(yo,"SPAN",{});var To=a(be);k(X.$$.fragment,To),To.forEach(o),yo.forEach(o),vt=d(Qe),ve=n(Qe,"SPAN",{});var wo=a(ve);yt=i(wo,"BartphoTokenizer"),wo.forEach(o),Qe.forEach(o),Ze=d(e),m=n(e,"DIV",{class:!0});var u=a(m);k(S.$$.fragment,u),Tt=d(u),R=n(u,"P",{});var de=a(R);wt=i(de,"Adapted from "),re=n(de,"A",{href:!0});var Bo=a(re);Bt=i(Bo,"XLMRobertaTokenizer"),Bo.forEach(o),Mt=i(de,". Based on "),F=n(de,"A",{href:!0,rel:!0});var Mo=a(F);zt=i(Mo,"SentencePiece"),Mo.forEach(o),Rt=i(de,"."),de.forEach(o),Jt=d(u),N=n(u,"P",{});var He=a(N);qt=i(He,"This tokenizer inherits from "),ie=n(He,"A",{href:!0});var zo=a(ie);Et=i(zo,"PreTrainedTokenizer"),zo.forEach(o),At=i(He,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),He.forEach(o),Ut=d(u),g=n(u,"DIV",{class:!0});var he=a(g);k(Q.$$.fragment,he),jt=d(he),ye=n(he,"P",{});var Ro=a(ye);$t=i(Ro,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An BARTPho sequence has the following format:`),Ro.forEach(o),xt=d(he),H=n(he,"UL",{});var De=a(H);le=n(De,"LI",{});var Ot=a(le);It=i(Ot,"single sequence: "),Te=n(Ot,"CODE",{});var Jo=a(Te);Vt=i(Jo,"<s> X </s>"),Jo.forEach(o),Ot.forEach(o),Ct=d(De),pe=n(De,"LI",{});var Kt=a(pe);Wt=i(Kt,"pair of sequences: "),we=n(Kt,"CODE",{});var qo=a(we);Lt=i(qo,"<s> A </s></s> B </s>"),qo.forEach(o),Kt.forEach(o),De.forEach(o),he.forEach(o),Zt=d(u),U=n(u,"DIV",{class:!0});var Ge=a(U);k(D.$$.fragment,Ge),Pt=d(Ge),Be=n(Ge,"P",{});var Eo=a(Be);Xt=i(Eo,"Converts a sequence of tokens (strings for sub-words) in a single string."),Eo.forEach(o),Ge.forEach(o),St=d(u),j=n(u,"DIV",{class:!0});var Ye=a(j);k(G.$$.fragment,Ye),Ft=d(Ye),Me=n(Ye,"P",{});var Ao=a(Me);Nt=i(Ao,`Create a mask from the two sequences passed to be used in a sequence-pair classification task. BARTPho does not
make use of token type ids, therefore a list of zeros is returned.`),Ao.forEach(o),Ye.forEach(o),Qt=d(u),$=n(u,"DIV",{class:!0});var Oe=a($);k(Y.$$.fragment,Oe),Ht=d(Oe),O=n(Oe,"P",{});var Ke=a(O);Dt=i(Ke,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),ze=n(Ke,"CODE",{});var Uo=a(ze);Gt=i(Uo,"prepare_for_model"),Uo.forEach(o),Yt=i(Ke," method."),Ke.forEach(o),Oe.forEach(o),u.forEach(o),this.h()},h(){p(w,"name","hf:doc:metadata"),p(w,"content",JSON.stringify(Zo)),p(J,"id","bartpho"),p(J,"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"),p(J,"href","#bartpho"),p(B,"class","relative group"),p(q,"id","overview"),p(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"),p(q,"href","#overview"),p(M,"class","relative group"),p(V,"href","https://arxiv.org/abs/2109.09701"),p(V,"rel","nofollow"),p(ne,"href","bart"),p(Z,"href","https://huggingface.co/dqnguyen"),p(Z,"rel","nofollow"),p(P,"href","https://github.com/VinAIResearch/BARTpho"),p(P,"rel","nofollow"),p(A,"id","transformers.BartphoTokenizer"),p(A,"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"),p(A,"href","#transformers.BartphoTokenizer"),p(z,"class","relative group"),p(re,"href","/docs/transformers/v4.31.0/en/model_doc/xlm-roberta#transformers.XLMRobertaTokenizer"),p(F,"href","https://github.com/google/sentencepiece"),p(F,"rel","nofollow"),p(ie,"href","/docs/transformers/v4.31.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),p(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(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(e,l){t(document.head,w),h(e,Je,l),h(e,B,l),t(B,J),t(J,me),b(x,me,null),t(B,et),t(B,ue),t(ue,tt),h(e,qe,l),h(e,M,l),t(M,q),t(q,fe),b(I,fe,null),t(M,ot),t(M,ge),t(ge,st),h(e,Ee,l),h(e,E,l),t(E,nt),t(E,V),t(V,at),t(E,rt),h(e,Ae,l),h(e,K,l),t(K,it),h(e,Ue,l),h(e,ee,l),t(ee,_e),t(_e,lt),h(e,je,l),h(e,te,l),t(te,pt),h(e,$e,l),b(C,e,l),h(e,xe,l),h(e,oe,l),t(oe,ct),h(e,Ie,l),h(e,se,l),t(se,W),t(W,dt),t(W,ne),t(ne,ht),t(W,mt),h(e,Ve,l),b(L,e,l),h(e,Ce,l),h(e,ae,l),t(ae,ke),t(ke,ut),h(e,We,l),h(e,f,l),t(f,ft),t(f,Z),t(Z,gt),t(f,_t),t(f,P),t(P,kt),t(f,bt),h(e,Le,l),h(e,z,l),t(z,A),t(A,be),b(X,be,null),t(z,vt),t(z,ve),t(ve,yt),h(e,Ze,l),h(e,m,l),b(S,m,null),t(m,Tt),t(m,R),t(R,wt),t(R,re),t(re,Bt),t(R,Mt),t(R,F),t(F,zt),t(R,Rt),t(m,Jt),t(m,N),t(N,qt),t(N,ie),t(ie,Et),t(N,At),t(m,Ut),t(m,g),b(Q,g,null),t(g,jt),t(g,ye),t(ye,$t),t(g,xt),t(g,H),t(H,le),t(le,It),t(le,Te),t(Te,Vt),t(H,Ct),t(H,pe),t(pe,Wt),t(pe,we),t(we,Lt),t(m,Zt),t(m,U),b(D,U,null),t(U,Pt),t(U,Be),t(Be,Xt),t(m,St),t(m,j),b(G,j,null),t(j,Ft),t(j,Me),t(Me,Nt),t(m,Qt),t(m,$),b(Y,$,null),t($,Ht),t($,O),t(O,Dt),t(O,ze),t(ze,Gt),t(O,Yt),Pe=!0},p:Co,i(e){Pe||(v(x.$$.fragment,e),v(I.$$.fragment,e),v(C.$$.fragment,e),v(L.$$.fragment,e),v(X.$$.fragment,e),v(S.$$.fragment,e),v(Q.$$.fragment,e),v(D.$$.fragment,e),v(G.$$.fragment,e),v(Y.$$.fragment,e),Pe=!0)},o(e){y(x.$$.fragment,e),y(I.$$.fragment,e),y(C.$$.fragment,e),y(L.$$.fragment,e),y(X.$$.fragment,e),y(S.$$.fragment,e),y(Q.$$.fragment,e),y(D.$$.fragment,e),y(G.$$.fragment,e),y(Y.$$.fragment,e),Pe=!1},d(e){o(w),e&&o(Je),e&&o(B),T(x),e&&o(qe),e&&o(M),T(I),e&&o(Ee),e&&o(E),e&&o(Ae),e&&o(K),e&&o(Ue),e&&o(ee),e&&o(je),e&&o(te),e&&o($e),T(C,e),e&&o(xe),e&&o(oe),e&&o(Ie),e&&o(se),e&&o(Ve),T(L,e),e&&o(Ce),e&&o(ae),e&&o(We),e&&o(f),e&&o(Le),e&&o(z),T(X),e&&o(Ze),e&&o(m),T(S),T(Q),T(D),T(G),T(Y)}}}const Zo={local:"bartpho",sections:[{local:"overview",title:"Overview"},{local:"transformers.BartphoTokenizer",title:"BartphoTokenizer"}],title:"BARTpho"};function Po(to){return Wo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qo extends $o{constructor(w){super();xo(this,w,Po,Lo,Io,{})}}export{Qo as default,Zo as metadata};
