import{S as ws,i as $s,s as ys,e as s,k as p,w as v,t as r,M as Cs,c as a,d as n,m as c,a as o,x as b,h as i,b as m,G as e,g as h,y as w,q as $,o as y,B as C,v as Ts,L as vs}from"../../chunks/vendor-hf-doc-builder.js";import{D as R}from"../../chunks/Docstring-hf-doc-builder.js";import{C as bs}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as vt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ks}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Es(ue){let u,M,_,f,T;return f=new bs({props:{code:"MCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMEElN0MlMjBmaXJzdCUyMHNlcXVlbmNlJTIwJTIwJTIwJTIwJTdDJTIwc2Vjb25kJTIwc2VxdWVuY2UlMjAlN0M=",highlighted:`0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1 1
| first sequence    | second sequence |`}}),{c(){u=s("p"),M=r("sequence pair mask has the following format:"),_=p(),v(f.$$.fragment)},l(l){u=a(l,"P",{});var g=o(u);M=i(g,"sequence pair mask has the following format:"),g.forEach(n),_=c(l),b(f.$$.fragment,l)},m(l,g){h(l,u,g),e(u,M),h(l,_,g),w(f,l,g),T=!0},p:vs,i(l){T||($(f.$$.fragment,l),T=!0)},o(l){y(f.$$.fragment,l),T=!1},d(l){l&&n(u),l&&n(_),C(f,l)}}}function Ms(ue){let u,M,_,f,T;return f=new bs({props:{code:"MCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMEElN0MlMjBmaXJzdCUyMHNlcXVlbmNlJTIwJTIwJTIwJTIwJTdDJTIwc2Vjb25kJTIwc2VxdWVuY2UlMjAlN0M=",highlighted:`0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1 1
| first sequence    | second sequence |`}}),{c(){u=s("p"),M=r("sequence pair mask has the following format:"),_=p(),v(f.$$.fragment)},l(l){u=a(l,"P",{});var g=o(u);M=i(g,"sequence pair mask has the following format:"),g.forEach(n),_=c(l),b(f.$$.fragment,l)},m(l,g){h(l,u,g),e(u,M),h(l,_,g),w(f,l,g),T=!0},p:vs,i(l){T||($(f.$$.fragment,l),T=!0)},o(l){y(f.$$.fragment,l),T=!1},d(l){l&&n(u),l&&n(_),C(f,l)}}}function Ls(ue){let u,M,_,f,T,l,g,Me,bt,Ke,D,S,Le,W,wt,Pe,$t,et,G,yt,Q,Ct,Tt,tt,_e,Et,nt,ge,qe,Mt,st,A,Lt,K,Pt,qt,ee,zt,at,ke,It,ot,x,F,ze,te,Dt,Ie,At,rt,k,ne,xt,De,Nt,Jt,z,se,jt,Ae,St,Gt,ae,ve,Ft,xe,Ot,Ut,be,Xt,Ne,Ht,Bt,O,oe,Vt,Je,Zt,Yt,L,re,Rt,je,Wt,Qt,U,Kt,N,en,Se,tn,nn,Ge,sn,an,on,X,ie,rn,le,ln,Fe,pn,cn,it,J,H,Oe,pe,mn,Ue,dn,lt,E,ce,hn,Xe,fn,un,I,me,_n,He,gn,kn,de,we,vn,Be,bn,wn,$e,$n,Ve,yn,Cn,P,he,Tn,Ze,En,Mn,B,Ln,j,Pn,Ye,qn,zn,Re,In,Dn,pt;return l=new vt({}),W=new vt({}),te=new vt({}),ne=new R({props:{name:"class transformers.CpmTokenizer",anchor:"transformers.CpmTokenizer",parameters:[{name:"vocab_file",val:""},{name:"do_lower_case",val:" = False"},{name:"remove_space",val:" = True"},{name:"keep_accents",val:" = False"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"unk_token",val:" = '<unk>'"},{name:"sep_token",val:" = '<sep>'"},{name:"pad_token",val:" = '<pad>'"},{name:"cls_token",val:" = '<cls>'"},{name:"mask_token",val:" = '<mask>'"},{name:"additional_special_tokens",val:" = ['<eop>', '<eod>']"},{name:"sp_model_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/cpm/tokenization_cpm.py#L38"}}),se=new R({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.CpmTokenizer.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.CpmTokenizer.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.CpmTokenizer.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/main/src/transformers/models/cpm/tokenization_cpm.py#L242",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>
`}}),oe=new R({props:{name:"convert_tokens_to_string",anchor:"transformers.CpmTokenizer.convert_tokens_to_string",parameters:[{name:"tokens",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/cpm/tokenization_cpm.py#L236"}}),re=new R({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.CpmTokenizer.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.CpmTokenizer.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.CpmTokenizer.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/main/src/transformers/models/cpm/tokenization_cpm.py#L297",returnDescription:`
<p>List of <a href="../glossary#token-type-ids">token type IDs</a> according to the given sequence(s).</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),U=new ks({props:{anchor:"transformers.CpmTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[Es]},$$scope:{ctx:ue}}}),ie=new R({props:{name:"get_special_tokens_mask",anchor:"transformers.CpmTokenizer.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.CpmTokenizer.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.CpmTokenizer.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.CpmTokenizer.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/main/src/transformers/models/cpm/tokenization_cpm.py#L268",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>
`}}),pe=new vt({}),ce=new R({props:{name:"class transformers.CpmTokenizerFast",anchor:"transformers.CpmTokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"do_lower_case",val:" = False"},{name:"remove_space",val:" = True"},{name:"keep_accents",val:" = False"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"unk_token",val:" = '<unk>'"},{name:"sep_token",val:" = '<sep>'"},{name:"pad_token",val:" = '<pad>'"},{name:"cls_token",val:" = '<cls>'"},{name:"mask_token",val:" = '<mask>'"},{name:"additional_special_tokens",val:" = ['<eop>', '<eod>']"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/cpm/tokenization_cpm_fast.py#L38"}}),me=new R({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.CpmTokenizerFast.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.CpmTokenizerFast.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.CpmTokenizerFast.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/main/src/transformers/models/cpm/tokenization_cpm_fast.py#L157",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>
`}}),he=new R({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.CpmTokenizerFast.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.CpmTokenizerFast.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.CpmTokenizerFast.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/main/src/transformers/models/cpm/tokenization_cpm_fast.py#L183",returnDescription:`
<p>List of <a href="../glossary#token-type-ids">token type IDs</a> according to the given sequence(s).</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),B=new ks({props:{anchor:"transformers.CpmTokenizerFast.create_token_type_ids_from_sequences.example",$$slots:{default:[Ms]},$$scope:{ctx:ue}}}),{c(){u=s("meta"),M=p(),_=s("h1"),f=s("a"),T=s("span"),v(l.$$.fragment),g=p(),Me=s("span"),bt=r("CPM"),Ke=p(),D=s("h2"),S=s("a"),Le=s("span"),v(W.$$.fragment),wt=p(),Pe=s("span"),$t=r("Overview"),et=p(),G=s("p"),yt=r("The CPM model was proposed in "),Q=s("a"),Ct=r("CPM: A Large-scale Generative Chinese Pre-trained Language Model"),Tt=r(` by Zhengyan Zhang, Xu Han, Hao Zhou, Pei Ke, Yuxian Gu, Deming Ye, Yujia Qin,
Yusheng Su, Haozhe Ji, Jian Guan, Fanchao Qi, Xiaozhi Wang, Yanan Zheng, Guoyang Zeng, Huanqi Cao, Shengqi Chen,
Daixuan Li, Zhenbo Sun, Zhiyuan Liu, Minlie Huang, Wentao Han, Jie Tang, Juanzi Li, Xiaoyan Zhu, Maosong Sun.`),tt=p(),_e=s("p"),Et=r("The abstract from the paper is the following:"),nt=p(),ge=s("p"),qe=s("em"),Mt=r(`Pre-trained Language Models (PLMs) have proven to be beneficial for various downstream NLP tasks. Recently, GPT-3,
with 175 billion parameters and 570GB training data, drew a lot of attention due to the capacity of few-shot (even
zero-shot) learning. However, applying GPT-3 to address Chinese NLP tasks is still challenging, as the training corpus
of GPT-3 is primarily English, and the parameters are not publicly available. In this technical report, we release the
Chinese Pre-trained Language Model (CPM) with generative pre-training on large-scale Chinese training data. To the best
of our knowledge, CPM, with 2.6 billion parameters and 100GB Chinese training data, is the largest Chinese pre-trained
language model, which could facilitate several downstream Chinese NLP tasks, such as conversation, essay generation,
cloze test, and language understanding. Extensive experiments demonstrate that CPM achieves strong performance on many
NLP tasks in the settings of few-shot (even zero-shot) learning.`),st=p(),A=s("p"),Lt=r("This model was contributed by "),K=s("a"),Pt=r("canwenxu"),qt=r(`. The original implementation can be found
here: `),ee=s("a"),zt=r("https://github.com/TsinghuaAI/CPM-Generate"),at=p(),ke=s("p"),It=r("Note: We only have a tokenizer here, since the model architecture is the same as GPT-2."),ot=p(),x=s("h2"),F=s("a"),ze=s("span"),v(te.$$.fragment),Dt=p(),Ie=s("span"),At=r("CpmTokenizer"),rt=p(),k=s("div"),v(ne.$$.fragment),xt=p(),De=s("p"),Nt=r("Runs pre-tokenization with Jieba segmentation tool. It is used in CPM models."),Jt=p(),z=s("div"),v(se.$$.fragment),jt=p(),Ae=s("p"),St=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format:`),Gt=p(),ae=s("ul"),ve=s("li"),Ft=r("single sequence: "),xe=s("code"),Ot=r("X <sep> <cls>"),Ut=p(),be=s("li"),Xt=r("pair of sequences: "),Ne=s("code"),Ht=r("A <sep> B <sep> <cls>"),Bt=p(),O=s("div"),v(oe.$$.fragment),Vt=p(),Je=s("p"),Zt=r("Converts a sequence of tokens (strings for sub-words) in a single string."),Yt=p(),L=s("div"),v(re.$$.fragment),Rt=p(),je=s("p"),Wt=r("Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet"),Qt=p(),v(U.$$.fragment),Kt=p(),N=s("p"),en=r("If "),Se=s("code"),tn=r("token_ids_1"),nn=r(" is "),Ge=s("code"),sn=r("None"),an=r(", this method only returns the first portion of the mask (0s)."),on=p(),X=s("div"),v(ie.$$.fragment),rn=p(),le=s("p"),ln=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 `),Fe=s("code"),pn=r("prepare_for_model"),cn=r(" method."),it=p(),J=s("h2"),H=s("a"),Oe=s("span"),v(pe.$$.fragment),mn=p(),Ue=s("span"),dn=r("CpmTokenizerFast"),lt=p(),E=s("div"),v(ce.$$.fragment),hn=p(),Xe=s("p"),fn=r("Runs pre-tokenization with Jieba segmentation tool. It is used in CPM models."),un=p(),I=s("div"),v(me.$$.fragment),_n=p(),He=s("p"),gn=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format:`),kn=p(),de=s("ul"),we=s("li"),vn=r("single sequence: "),Be=s("code"),bn=r("X <sep> <cls>"),wn=p(),$e=s("li"),$n=r("pair of sequences: "),Ve=s("code"),yn=r("A <sep> B <sep> <cls>"),Cn=p(),P=s("div"),v(he.$$.fragment),Tn=p(),Ze=s("p"),En=r("Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet"),Mn=p(),v(B.$$.fragment),Ln=p(),j=s("p"),Pn=r("If "),Ye=s("code"),qn=r("token_ids_1"),zn=r(" is "),Re=s("code"),In=r("None"),Dn=r(", this method only returns the first portion of the mask (0s)."),this.h()},l(t){const d=Cs('[data-svelte="svelte-1phssyn"]',document.head);u=a(d,"META",{name:!0,content:!0}),d.forEach(n),M=c(t),_=a(t,"H1",{class:!0});var fe=o(_);f=a(fe,"A",{id:!0,class:!0,href:!0});var We=o(f);T=a(We,"SPAN",{});var jn=o(T);b(l.$$.fragment,jn),jn.forEach(n),We.forEach(n),g=c(fe),Me=a(fe,"SPAN",{});var Sn=o(Me);bt=i(Sn,"CPM"),Sn.forEach(n),fe.forEach(n),Ke=c(t),D=a(t,"H2",{class:!0});var ct=o(D);S=a(ct,"A",{id:!0,class:!0,href:!0});var Gn=o(S);Le=a(Gn,"SPAN",{});var Fn=o(Le);b(W.$$.fragment,Fn),Fn.forEach(n),Gn.forEach(n),wt=c(ct),Pe=a(ct,"SPAN",{});var On=o(Pe);$t=i(On,"Overview"),On.forEach(n),ct.forEach(n),et=c(t),G=a(t,"P",{});var mt=o(G);yt=i(mt,"The CPM model was proposed in "),Q=a(mt,"A",{href:!0,rel:!0});var Un=o(Q);Ct=i(Un,"CPM: A Large-scale Generative Chinese Pre-trained Language Model"),Un.forEach(n),Tt=i(mt,` by Zhengyan Zhang, Xu Han, Hao Zhou, Pei Ke, Yuxian Gu, Deming Ye, Yujia Qin,
Yusheng Su, Haozhe Ji, Jian Guan, Fanchao Qi, Xiaozhi Wang, Yanan Zheng, Guoyang Zeng, Huanqi Cao, Shengqi Chen,
Daixuan Li, Zhenbo Sun, Zhiyuan Liu, Minlie Huang, Wentao Han, Jie Tang, Juanzi Li, Xiaoyan Zhu, Maosong Sun.`),mt.forEach(n),tt=c(t),_e=a(t,"P",{});var Xn=o(_e);Et=i(Xn,"The abstract from the paper is the following:"),Xn.forEach(n),nt=c(t),ge=a(t,"P",{});var Hn=o(ge);qe=a(Hn,"EM",{});var Bn=o(qe);Mt=i(Bn,`Pre-trained Language Models (PLMs) have proven to be beneficial for various downstream NLP tasks. Recently, GPT-3,
with 175 billion parameters and 570GB training data, drew a lot of attention due to the capacity of few-shot (even
zero-shot) learning. However, applying GPT-3 to address Chinese NLP tasks is still challenging, as the training corpus
of GPT-3 is primarily English, and the parameters are not publicly available. In this technical report, we release the
Chinese Pre-trained Language Model (CPM) with generative pre-training on large-scale Chinese training data. To the best
of our knowledge, CPM, with 2.6 billion parameters and 100GB Chinese training data, is the largest Chinese pre-trained
language model, which could facilitate several downstream Chinese NLP tasks, such as conversation, essay generation,
cloze test, and language understanding. Extensive experiments demonstrate that CPM achieves strong performance on many
NLP tasks in the settings of few-shot (even zero-shot) learning.`),Bn.forEach(n),Hn.forEach(n),st=c(t),A=a(t,"P",{});var Qe=o(A);Lt=i(Qe,"This model was contributed by "),K=a(Qe,"A",{href:!0,rel:!0});var Vn=o(K);Pt=i(Vn,"canwenxu"),Vn.forEach(n),qt=i(Qe,`. The original implementation can be found
here: `),ee=a(Qe,"A",{href:!0,rel:!0});var Zn=o(ee);zt=i(Zn,"https://github.com/TsinghuaAI/CPM-Generate"),Zn.forEach(n),Qe.forEach(n),at=c(t),ke=a(t,"P",{});var Yn=o(ke);It=i(Yn,"Note: We only have a tokenizer here, since the model architecture is the same as GPT-2."),Yn.forEach(n),ot=c(t),x=a(t,"H2",{class:!0});var dt=o(x);F=a(dt,"A",{id:!0,class:!0,href:!0});var Rn=o(F);ze=a(Rn,"SPAN",{});var Wn=o(ze);b(te.$$.fragment,Wn),Wn.forEach(n),Rn.forEach(n),Dt=c(dt),Ie=a(dt,"SPAN",{});var Qn=o(Ie);At=i(Qn,"CpmTokenizer"),Qn.forEach(n),dt.forEach(n),rt=c(t),k=a(t,"DIV",{class:!0});var q=o(k);b(ne.$$.fragment,q),xt=c(q),De=a(q,"P",{});var Kn=o(De);Nt=i(Kn,"Runs pre-tokenization with Jieba segmentation tool. It is used in CPM models."),Kn.forEach(n),Jt=c(q),z=a(q,"DIV",{class:!0});var ye=o(z);b(se.$$.fragment,ye),jt=c(ye),Ae=a(ye,"P",{});var es=o(Ae);St=i(es,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format:`),es.forEach(n),Gt=c(ye),ae=a(ye,"UL",{});var ht=o(ae);ve=a(ht,"LI",{});var An=o(ve);Ft=i(An,"single sequence: "),xe=a(An,"CODE",{});var ts=o(xe);Ot=i(ts,"X <sep> <cls>"),ts.forEach(n),An.forEach(n),Ut=c(ht),be=a(ht,"LI",{});var xn=o(be);Xt=i(xn,"pair of sequences: "),Ne=a(xn,"CODE",{});var ns=o(Ne);Ht=i(ns,"A <sep> B <sep> <cls>"),ns.forEach(n),xn.forEach(n),ht.forEach(n),ye.forEach(n),Bt=c(q),O=a(q,"DIV",{class:!0});var ft=o(O);b(oe.$$.fragment,ft),Vt=c(ft),Je=a(ft,"P",{});var ss=o(Je);Zt=i(ss,"Converts a sequence of tokens (strings for sub-words) in a single string."),ss.forEach(n),ft.forEach(n),Yt=c(q),L=a(q,"DIV",{class:!0});var V=o(L);b(re.$$.fragment,V),Rt=c(V),je=a(V,"P",{});var as=o(je);Wt=i(as,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet"),as.forEach(n),Qt=c(V),b(U.$$.fragment,V),Kt=c(V),N=a(V,"P",{});var Ce=o(N);en=i(Ce,"If "),Se=a(Ce,"CODE",{});var os=o(Se);tn=i(os,"token_ids_1"),os.forEach(n),nn=i(Ce," is "),Ge=a(Ce,"CODE",{});var rs=o(Ge);sn=i(rs,"None"),rs.forEach(n),an=i(Ce,", this method only returns the first portion of the mask (0s)."),Ce.forEach(n),V.forEach(n),on=c(q),X=a(q,"DIV",{class:!0});var ut=o(X);b(ie.$$.fragment,ut),rn=c(ut),le=a(ut,"P",{});var _t=o(le);ln=i(_t,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),Fe=a(_t,"CODE",{});var is=o(Fe);pn=i(is,"prepare_for_model"),is.forEach(n),cn=i(_t," method."),_t.forEach(n),ut.forEach(n),q.forEach(n),it=c(t),J=a(t,"H2",{class:!0});var gt=o(J);H=a(gt,"A",{id:!0,class:!0,href:!0});var ls=o(H);Oe=a(ls,"SPAN",{});var ps=o(Oe);b(pe.$$.fragment,ps),ps.forEach(n),ls.forEach(n),mn=c(gt),Ue=a(gt,"SPAN",{});var cs=o(Ue);dn=i(cs,"CpmTokenizerFast"),cs.forEach(n),gt.forEach(n),lt=c(t),E=a(t,"DIV",{class:!0});var Z=o(E);b(ce.$$.fragment,Z),hn=c(Z),Xe=a(Z,"P",{});var ms=o(Xe);fn=i(ms,"Runs pre-tokenization with Jieba segmentation tool. It is used in CPM models."),ms.forEach(n),un=c(Z),I=a(Z,"DIV",{class:!0});var Te=o(I);b(me.$$.fragment,Te),_n=c(Te),He=a(Te,"P",{});var ds=o(He);gn=i(ds,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format:`),ds.forEach(n),kn=c(Te),de=a(Te,"UL",{});var kt=o(de);we=a(kt,"LI",{});var Nn=o(we);vn=i(Nn,"single sequence: "),Be=a(Nn,"CODE",{});var hs=o(Be);bn=i(hs,"X <sep> <cls>"),hs.forEach(n),Nn.forEach(n),wn=c(kt),$e=a(kt,"LI",{});var Jn=o($e);$n=i(Jn,"pair of sequences: "),Ve=a(Jn,"CODE",{});var fs=o(Ve);yn=i(fs,"A <sep> B <sep> <cls>"),fs.forEach(n),Jn.forEach(n),kt.forEach(n),Te.forEach(n),Cn=c(Z),P=a(Z,"DIV",{class:!0});var Y=o(P);b(he.$$.fragment,Y),Tn=c(Y),Ze=a(Y,"P",{});var us=o(Ze);En=i(us,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet"),us.forEach(n),Mn=c(Y),b(B.$$.fragment,Y),Ln=c(Y),j=a(Y,"P",{});var Ee=o(j);Pn=i(Ee,"If "),Ye=a(Ee,"CODE",{});var _s=o(Ye);qn=i(_s,"token_ids_1"),_s.forEach(n),zn=i(Ee," is "),Re=a(Ee,"CODE",{});var gs=o(Re);In=i(gs,"None"),gs.forEach(n),Dn=i(Ee,", this method only returns the first portion of the mask (0s)."),Ee.forEach(n),Y.forEach(n),Z.forEach(n),this.h()},h(){m(u,"name","hf:doc:metadata"),m(u,"content",JSON.stringify(Ps)),m(f,"id","cpm"),m(f,"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"),m(f,"href","#cpm"),m(_,"class","relative group"),m(S,"id","overview"),m(S,"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"),m(S,"href","#overview"),m(D,"class","relative group"),m(Q,"href","https://arxiv.org/abs/2012.00413"),m(Q,"rel","nofollow"),m(K,"href","https://huggingface.co/canwenxu"),m(K,"rel","nofollow"),m(ee,"href","https://github.com/TsinghuaAI/CPM-Generate"),m(ee,"rel","nofollow"),m(F,"id","transformers.CpmTokenizer"),m(F,"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"),m(F,"href","#transformers.CpmTokenizer"),m(x,"class","relative group"),m(z,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(H,"id","transformers.CpmTokenizerFast"),m(H,"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"),m(H,"href","#transformers.CpmTokenizerFast"),m(J,"class","relative group"),m(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(P,"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,"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,d){e(document.head,u),h(t,M,d),h(t,_,d),e(_,f),e(f,T),w(l,T,null),e(_,g),e(_,Me),e(Me,bt),h(t,Ke,d),h(t,D,d),e(D,S),e(S,Le),w(W,Le,null),e(D,wt),e(D,Pe),e(Pe,$t),h(t,et,d),h(t,G,d),e(G,yt),e(G,Q),e(Q,Ct),e(G,Tt),h(t,tt,d),h(t,_e,d),e(_e,Et),h(t,nt,d),h(t,ge,d),e(ge,qe),e(qe,Mt),h(t,st,d),h(t,A,d),e(A,Lt),e(A,K),e(K,Pt),e(A,qt),e(A,ee),e(ee,zt),h(t,at,d),h(t,ke,d),e(ke,It),h(t,ot,d),h(t,x,d),e(x,F),e(F,ze),w(te,ze,null),e(x,Dt),e(x,Ie),e(Ie,At),h(t,rt,d),h(t,k,d),w(ne,k,null),e(k,xt),e(k,De),e(De,Nt),e(k,Jt),e(k,z),w(se,z,null),e(z,jt),e(z,Ae),e(Ae,St),e(z,Gt),e(z,ae),e(ae,ve),e(ve,Ft),e(ve,xe),e(xe,Ot),e(ae,Ut),e(ae,be),e(be,Xt),e(be,Ne),e(Ne,Ht),e(k,Bt),e(k,O),w(oe,O,null),e(O,Vt),e(O,Je),e(Je,Zt),e(k,Yt),e(k,L),w(re,L,null),e(L,Rt),e(L,je),e(je,Wt),e(L,Qt),w(U,L,null),e(L,Kt),e(L,N),e(N,en),e(N,Se),e(Se,tn),e(N,nn),e(N,Ge),e(Ge,sn),e(N,an),e(k,on),e(k,X),w(ie,X,null),e(X,rn),e(X,le),e(le,ln),e(le,Fe),e(Fe,pn),e(le,cn),h(t,it,d),h(t,J,d),e(J,H),e(H,Oe),w(pe,Oe,null),e(J,mn),e(J,Ue),e(Ue,dn),h(t,lt,d),h(t,E,d),w(ce,E,null),e(E,hn),e(E,Xe),e(Xe,fn),e(E,un),e(E,I),w(me,I,null),e(I,_n),e(I,He),e(He,gn),e(I,kn),e(I,de),e(de,we),e(we,vn),e(we,Be),e(Be,bn),e(de,wn),e(de,$e),e($e,$n),e($e,Ve),e(Ve,yn),e(E,Cn),e(E,P),w(he,P,null),e(P,Tn),e(P,Ze),e(Ze,En),e(P,Mn),w(B,P,null),e(P,Ln),e(P,j),e(j,Pn),e(j,Ye),e(Ye,qn),e(j,zn),e(j,Re),e(Re,In),e(j,Dn),pt=!0},p(t,[d]){const fe={};d&2&&(fe.$$scope={dirty:d,ctx:t}),U.$set(fe);const We={};d&2&&(We.$$scope={dirty:d,ctx:t}),B.$set(We)},i(t){pt||($(l.$$.fragment,t),$(W.$$.fragment,t),$(te.$$.fragment,t),$(ne.$$.fragment,t),$(se.$$.fragment,t),$(oe.$$.fragment,t),$(re.$$.fragment,t),$(U.$$.fragment,t),$(ie.$$.fragment,t),$(pe.$$.fragment,t),$(ce.$$.fragment,t),$(me.$$.fragment,t),$(he.$$.fragment,t),$(B.$$.fragment,t),pt=!0)},o(t){y(l.$$.fragment,t),y(W.$$.fragment,t),y(te.$$.fragment,t),y(ne.$$.fragment,t),y(se.$$.fragment,t),y(oe.$$.fragment,t),y(re.$$.fragment,t),y(U.$$.fragment,t),y(ie.$$.fragment,t),y(pe.$$.fragment,t),y(ce.$$.fragment,t),y(me.$$.fragment,t),y(he.$$.fragment,t),y(B.$$.fragment,t),pt=!1},d(t){n(u),t&&n(M),t&&n(_),C(l),t&&n(Ke),t&&n(D),C(W),t&&n(et),t&&n(G),t&&n(tt),t&&n(_e),t&&n(nt),t&&n(ge),t&&n(st),t&&n(A),t&&n(at),t&&n(ke),t&&n(ot),t&&n(x),C(te),t&&n(rt),t&&n(k),C(ne),C(se),C(oe),C(re),C(U),C(ie),t&&n(it),t&&n(J),C(pe),t&&n(lt),t&&n(E),C(ce),C(me),C(he),C(B)}}}const Ps={local:"cpm",sections:[{local:"overview",title:"Overview"},{local:"transformers.CpmTokenizer",title:"CpmTokenizer"},{local:"transformers.CpmTokenizerFast",title:"CpmTokenizerFast"}],title:"CPM"};function qs(ue){return Ts(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ns extends ws{constructor(u){super();$s(this,u,qs,Ls,ys,{})}}export{Ns as default,Ps as metadata};
