import{S as sd,i as rd,s as id,e as n,k as d,w as _,t as r,M as ld,c as a,d as o,m as c,a as s,x as v,h as i,b as l,G as e,g as p,y as k,q as b,o as y,B as w,v as dd,L as la}from"../../chunks/vendor-hf-doc-builder.js";import{T as xi}from"../../chunks/Tip-hf-doc-builder.js";import{D as C}from"../../chunks/Docstring-hf-doc-builder.js";import{C as po}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ie}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ia}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function cd(F){let h,L;return h=new po({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExsYW1hTW9kZWwlMkMlMjBMbGFtYUNvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBMTGFNQSUyMGxsYW1hLTdiJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMExsYW1hQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwbGxhbWEtN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMExsYW1hTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LlamaModel, LlamaConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a LLaMA llama-7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = LlamaConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the llama-7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LlamaModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){_(h.$$.fragment)},l(f){v(h.$$.fragment,f)},m(f,g){k(h,f,g),L=!0},p:la,i(f){L||(b(h.$$.fragment,f),L=!0)},o(f){y(h.$$.fragment,f),L=!1},d(f){w(h,f)}}}function md(F){let h,L,f,g,$;return g=new po({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(){h=n("p"),L=r("sequence pair mask has the following format:"),f=d(),_(g.$$.fragment)},l(u){h=a(u,"P",{});var T=s(h);L=i(T,"sequence pair mask has the following format:"),T.forEach(o),f=c(u),v(g.$$.fragment,u)},m(u,T){p(u,h,T),e(h,L),p(u,f,T),k(g,u,T),$=!0},p:la,i(u){$||(b(g.$$.fragment,u),$=!0)},o(u){y(g.$$.fragment,u),$=!1},d(u){u&&o(h),u&&o(f),w(g,u)}}}function hd(F){let h,L;return h=new po({props:{code:"JTBBJTVCMSUyQyUyMDE1MDQzJTJDJTIwNDQ1JTJDJTIwMzM4JTJDJTIwMjYzJTJDJTIwMTI0MyU1RA==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LlamaTokenizerFast

tokenizer = LlaTokenizerFast.from_pretrained(&quot;hf-internal-testing/llama-tokenizer&quot;)
tokenizer.encode(&quot;Hello this is a test&quot;)
&gt;&gt;&gt; [<span class="hljs-number">1</span>, <span class="hljs-number">15043</span>, <span class="hljs-number">445</span>, <span class="hljs-number">338</span>, <span class="hljs-number">263</span>, <span class="hljs-number">1243</span>]`}}),{c(){_(h.$$.fragment)},l(f){v(h.$$.fragment,f)},m(f,g){k(h,f,g),L=!0},p:la,i(f){L||(b(h.$$.fragment,f),L=!0)},o(f){y(h.$$.fragment,f),L=!1},d(f){w(h,f)}}}function pd(F){let h,L,f,g,$;return{c(){h=n("p"),L=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),g=r("Module"),$=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){h=a(u,"P",{});var T=s(h);L=i(T,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a(T,"CODE",{});var q=s(f);g=i(q,"Module"),q.forEach(o),$=i(T,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),T.forEach(o)},m(u,T){p(u,h,T),e(h,L),e(h,f),e(f,g),e(h,$)},d(u){u&&o(h)}}}function fd(F){let h,L,f,g,$;return{c(){h=n("p"),L=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),g=r("Module"),$=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){h=a(u,"P",{});var T=s(h);L=i(T,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a(T,"CODE",{});var q=s(f);g=i(q,"Module"),q.forEach(o),$=i(T,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),T.forEach(o)},m(u,T){p(u,h,T),e(h,L),e(h,f),e(f,g),e(h,$)},d(u){u&&o(h)}}}function ud(F){let h,L,f,g,$;return g=new po({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBMbGFtYUZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBMbGFtYUZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChQQVRIX1RPX0NPTlZFUlRFRF9XRUlHSFRTKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKFBBVEhfVE9fQ09OVkVSVEVEX1RPS0VOSVpFUiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJIZXklMkMlMjBhcmUlMjB5b3UlMjBjb25zY2lvdXMlM0YlMjBDYW4lMjB5b3UlMjB0YWxrJTIwdG8lMjBtZSUzRiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQSUyMyUyMEdlbmVyYXRlJTBBZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzLmlucHV0X2lkcyUyQyUyMG1heF9sZW5ndGglM0QzMCklMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlJTJDJTIwY2xlYW5fdXBfdG9rZW5pemF0aW9uX3NwYWNlcyUzREZhbHNlKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LlamaForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = LlamaForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Hey, are you conscious? Can you talk to me?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(inputs.input_ids, max_length=<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>]
<span class="hljs-string">&quot;Hey, are you conscious? Can you talk to me?\\nI&#x27;m not conscious, but I can talk to you.&quot;</span>`}}),{c(){h=n("p"),L=r("Example:"),f=d(),_(g.$$.fragment)},l(u){h=a(u,"P",{});var T=s(h);L=i(T,"Example:"),T.forEach(o),f=c(u),v(g.$$.fragment,u)},m(u,T){p(u,h,T),e(h,L),p(u,f,T),k(g,u,T),$=!0},p:la,i(u){$||(b(g.$$.fragment,u),$=!0)},o(u){y(g.$$.fragment,u),$=!1},d(u){u&&o(h),u&&o(f),w(g,u)}}}function gd(F){let h,L,f,g,$;return{c(){h=n("p"),L=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),g=r("Module"),$=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){h=a(u,"P",{});var T=s(h);L=i(T,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a(T,"CODE",{});var q=s(f);g=i(q,"Module"),q.forEach(o),$=i(T,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),T.forEach(o)},m(u,T){p(u,h,T),e(h,L),e(h,f),e(f,g),e(h,$)},d(u){u&&o(h)}}}function _d(F){let h,L,f,g,$,u,T,q,da,hn,H,ce,fo,je,ca,uo,ma,pn,me,ha,Ne,pa,fa,fn,Ft,ua,un,At,go,ga,gn,qt,_a,_n,he,Pt,va,Se,ka,ba,Ue,ya,We,wa,Ta,vn,Be,kn,It,_o,La,bn,De,yn,jt,$a,wn,Nt,Je,Ma,Oe,za,Ea,Tn,P,Ca,Ge,xa,Fa,Re,Aa,qa,Ve,Pa,Ia,Ze,ja,Na,Ln,St,Sa,$n,Ut,pe,vo,Ua,Wa,Wt,Ba,Da,Mn,Y,fe,ko,Xe,Ja,bo,Oa,zn,j,He,Ga,Ye,Ra,Bt,Va,Za,Xa,Q,Ha,Dt,Ya,Qa,Jt,Ka,es,ts,ue,En,K,ge,yo,Qe,os,wo,ns,Cn,x,Ke,as,To,ss,rs,Ot,et,is,_e,tt,ls,ot,ds,Lo,cs,ms,hs,U,nt,ps,$o,fs,us,ve,gs,Mo,_s,vs,ke,at,ks,zo,bs,xn,ee,be,Eo,st,ys,Co,ws,Fn,M,rt,Ts,xo,Ls,$s,Fo,Ms,zs,ye,Es,N,Cs,Ao,xs,Fs,qo,As,qs,Po,Ps,Is,it,js,Ns,Ss,lt,Us,Gt,Ws,Bs,Ds,D,dt,Js,Io,Os,Gs,jo,Rs,Vs,we,ct,Zs,te,Xs,No,Hs,Ys,So,Qs,Ks,er,J,mt,tr,Rt,or,Vt,nr,ar,Uo,sr,rr,Te,ht,ir,oe,lr,Wo,dr,cr,Bo,mr,hr,pr,Zt,pt,An,ne,Le,Do,ft,fr,Jo,ur,qn,A,ut,gr,gt,_r,Xt,vr,kr,br,_t,yr,vt,wr,Tr,Lr,$e,$r,Oo,Mr,zr,Go,Er,Cr,O,kt,xr,ae,Fr,Ht,Ar,qr,Ro,Pr,Ir,jr,Me,Pn,se,ze,Vo,bt,Nr,Zo,Sr,In,re,yt,Ur,W,wt,Wr,ie,Br,Yt,Dr,Jr,Xo,Or,Gr,Rr,Ee,Vr,Ce,jn,le,xe,Ho,Tt,Zr,Yo,Xr,Nn,E,Lt,Hr,Qo,Yr,Qr,Qt,Kt,Kr,ei,ti,S,oi,Ko,ni,ai,en,si,ri,tn,ii,li,on,di,ci,mi,$t,hi,eo,pi,fi,ui,Mt,gi,zt,_i,vi,ki,G,Et,bi,de,yi,to,wi,Ti,nn,Li,$i,Mi,Fe,Sn;return u=new Ie({}),je=new Ie({}),Be=new po({props:{code:"cHl0aG9uJTIwc3JjJTJGdHJhbnNmb3JtZXJzJTJGbW9kZWxzJTJGbGxhbWElMkZjb252ZXJ0X2xsYW1hX3dlaWdodHNfdG9faGYucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLWlucHV0X2RpciUyMCUyRnBhdGglMkZ0byUyRmRvd25sb2FkZWQlMkZsbGFtYSUyRndlaWdodHMlMjAtLW1vZGVsX3NpemUlMjA3QiUyMC0tb3V0cHV0X2RpciUyMCUyRm91dHB1dCUyRnBhdGg=",highlighted:`python src/transformers/models/llama/convert_llama_weights_to_hf.py \\
    --input_dir /path/to/downloaded/llama/weights --model_size 7B --output_dir /output/path`}}),De=new po({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExsYW1hRm9yQ2F1c2FsTE0lMkMlMjBMbGFtYVRva2VuaXplciUwQSUwQXRva2VuaXplciUyMCUzRCUyMExsYW1hVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjIlMkZvdXRwdXQlMkZwYXRoJTIyKSUwQW1vZGVsJTIwJTNEJTIwTGxhbWFGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyJTJGb3V0cHV0JTJGcGF0aCUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LlamaForCausalLM, LlamaTokenizer

tokenizer = LlamaTokenizer.from_pretrained(<span class="hljs-string">&quot;/output/path&quot;</span>)
model = LlamaForCausalLM.from_pretrained(<span class="hljs-string">&quot;/output/path&quot;</span>)`}}),Xe=new Ie({}),He=new C({props:{name:"class transformers.LlamaConfig",anchor:"transformers.LlamaConfig",parameters:[{name:"vocab_size",val:" = 32000"},{name:"hidden_size",val:" = 4096"},{name:"intermediate_size",val:" = 11008"},{name:"num_hidden_layers",val:" = 32"},{name:"num_attention_heads",val:" = 32"},{name:"num_key_value_heads",val:" = None"},{name:"hidden_act",val:" = 'silu'"},{name:"max_position_embeddings",val:" = 2048"},{name:"initializer_range",val:" = 0.02"},{name:"rms_norm_eps",val:" = 1e-06"},{name:"use_cache",val:" = True"},{name:"pad_token_id",val:" = 0"},{name:"bos_token_id",val:" = 1"},{name:"eos_token_id",val:" = 2"},{name:"pretraining_tp",val:" = 1"},{name:"tie_word_embeddings",val:" = False"},{name:"rope_scaling",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LlamaConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32000) &#x2014;
Vocabulary size of the LLaMA model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaModel">LlamaModel</a>`,name:"vocab_size"},{anchor:"transformers.LlamaConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.LlamaConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 11008) &#x2014;
Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.LlamaConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.LlamaConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.LlamaConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>) &#x2014;
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
<code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if
<code>num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group. For more details checkout [this paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to </code>num_attention_heads\`.`,name:"num_key_value_heads"},{anchor:"transformers.LlamaConfig.pretraining_tp",description:`<strong>pretraining_tp</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to <a href="https://huggingface.co/docs/transformers/parallelism" rel="nofollow">this
document</a> to understand more about it. This value is
necessary to ensure exact reproducibility of the pretraining results. Please refer to <a href="https://github.com/pytorch/pytorch/issues/76232" rel="nofollow">this
issue</a>.`,name:"pretraining_tp"},{anchor:"transformers.LlamaConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the decoder.`,name:"hidden_act"},{anchor:"transformers.LlamaConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.LlamaConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.LlamaConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.LlamaConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.LlamaConfig.tie_word_embeddings(bool,",description:`<strong>tie_word_embeddings(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to tie weight embeddings`,name:"tie_word_embeddings(bool,"},{anchor:"transformers.LlamaConfig.rope_scaling",description:`<strong>rope_scaling</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports three scaling
strategies: linear and dynamic. Their scaling factor must be an float greater than 1. The expected format
is <code>{&quot;type&quot;: strategy name, &quot;factor&quot;: scaling factor}</code>. When using this flag, don&#x2019;t update
<code>max_position_embeddings</code> to the expected new maximum. See the following thread for more information on how
these scaling strategies behave:
<a href="https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/" rel="nofollow">https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/</a>. This is an
experimental feature, subject to breaking API changes in future versions.</p>
<p>Example &#x2014;`,name:"rope_scaling"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/configuration_llama.py#L31"}}),ue=new ia({props:{anchor:"transformers.LlamaConfig.example",$$slots:{default:[cd]},$$scope:{ctx:F}}}),Qe=new Ie({}),Ke=new C({props:{name:"class transformers.LlamaTokenizer",anchor:"transformers.LlamaTokenizer",parameters:[{name:"vocab_file",val:""},{name:"unk_token",val:" = '<unk>'"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"pad_token",val:" = None"},{name:"sp_model_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"add_bos_token",val:" = True"},{name:"add_eos_token",val:" = False"},{name:"clean_up_tokenization_spaces",val:" = False"},{name:"legacy",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LlamaTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.LlamaTokenizer.legacy",description:`<strong>legacy</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the <code>legacy</code> behaviour of the tokenizer should be used. Legacy is before the merge of #24622
which includes fixes to properly handle tokens that appear after special tokens. A simple example:</p>
<ul>
<li><code>legacy=True</code>:</li>
</ul>`,name:"legacy"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama.py#L65"}}),et=new C({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.LlamaTokenizer.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:""},{name:"token_ids_1",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama.py#L253"}}),tt=new C({props:{name:"get_special_tokens_mask",anchor:"transformers.LlamaTokenizer.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.LlamaTokenizer.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.LlamaTokenizer.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.LlamaTokenizer.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/llama/tokenization_llama.py#L264",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>
`}}),nt=new C({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.LlamaTokenizer.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.LlamaTokenizer.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.LlamaTokenizer.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/llama/tokenization_llama.py#L301",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>
`}}),ve=new ia({props:{anchor:"transformers.LlamaTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[md]},$$scope:{ctx:F}}}),at=new C({props:{name:"save_vocabulary",anchor:"transformers.LlamaTokenizer.save_vocabulary",parameters:[{name:"save_directory",val:""},{name:"filename_prefix",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"transformers.LlamaTokenizer.save_vocabulary.save_directory",description:`<strong>save_directory</strong> (<code>str</code>) &#x2014;
The directory in which to save the vocabulary.`,name:"save_directory"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama.py#L226",returnDescription:`
<p>Paths to the files saved.</p>
`,returnType:`
<p><code>Tuple(str)</code></p>
`}}),st=new Ie({}),rt=new C({props:{name:"class transformers.LlamaTokenizerFast",anchor:"transformers.LlamaTokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"clean_up_tokenization_spaces",val:" = False"},{name:"unk_token",val:" = '<unk>'"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"add_bos_token",val:" = True"},{name:"add_eos_token",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LlamaTokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
<a href="https://github.com/google/sentencepiece" rel="nofollow">SentencePiece</a> file (generally has a .model extension) that
contains the vocabulary necessary to instantiate a tokenizer.`,name:"vocab_file"},{anchor:"transformers.LlamaTokenizerFast.tokenizer_file",description:`<strong>tokenizer_file</strong> (<code>str</code>) &#x2014;
<a href="https://github.com/huggingface/tokenizers" rel="nofollow">tokenizers</a> file (generally has a .json extension) that
contains everything needed to load the tokenizer.`,name:"tokenizer_file"},{anchor:"transformers.LlamaTokenizerFast.clean_up_tokenization_spaces",description:`<strong>clean_up_tokenization_spaces</strong> (<code>str</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Wether to cleanup spaces after decoding, cleanup consists in removing potential artifacts like extra
spaces.`,name:"clean_up_tokenization_spaces"},{anchor:"transformers.LlamaTokenizerFast.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.`,name:"bos_token"},{anchor:"transformers.LlamaTokenizerFast.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.`,name:"eos_token"},{anchor:"transformers.LlamaTokenizerFast.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"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama_fast.py#L52"}}),ye=new ia({props:{anchor:"transformers.LlamaTokenizerFast.example",$$slots:{default:[hd]},$$scope:{ctx:F}}}),dt=new C({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.LlamaTokenizerFast.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.LlamaTokenizerFast.build_inputs_with_special_tokens.token_ids_0",description:"<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014; The first tokenized sequence.",name:"token_ids_0"},{anchor:"transformers.LlamaTokenizerFast.build_inputs_with_special_tokens.token_ids_1",description:"<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014; The second tokenized sequence.",name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/tokenization_utils_base.py#L3096",returnDescription:`
<p>The model input with special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ct=new C({props:{name:"get_special_tokens_mask",anchor:"transformers.LlamaTokenizerFast.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.LlamaTokenizerFast.get_special_tokens_mask.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of ids of the first sequence.`,name:"token_ids_0"},{anchor:"transformers.LlamaTokenizerFast.get_special_tokens_mask.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
List of ids of the second sequence.`,name:"token_ids_1"},{anchor:"transformers.LlamaTokenizerFast.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/tokenization_utils_base.py#L3541",returnDescription:`
<p>1 for a special token, 0 for a sequence token.</p>
`,returnType:`
<p>A list of integers in the range [0, 1]</p>
`}}),mt=new C({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.LlamaTokenizerFast.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.LlamaTokenizerFast.create_token_type_ids_from_sequences.token_ids_0",description:"<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014; The first tokenized sequence.",name:"token_ids_0"},{anchor:"transformers.LlamaTokenizerFast.create_token_type_ids_from_sequences.token_ids_1",description:"<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014; The second tokenized sequence.",name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/tokenization_utils_base.py#L3076",returnDescription:`
<p>The token type ids.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ht=new C({props:{name:"update_post_processor",anchor:"transformers.LlamaTokenizerFast.update_post_processor",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama_fast.py#L131"}}),pt=new C({props:{name:"save_vocabulary",anchor:"transformers.LlamaTokenizerFast.save_vocabulary",parameters:[{name:"save_directory",val:": str"},{name:"filename_prefix",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/tokenization_llama_fast.py#L171"}}),ft=new Ie({}),ut=new C({props:{name:"class transformers.LlamaModel",anchor:"transformers.LlamaModel",parameters:[{name:"config",val:": LlamaConfig"}],parametersDescription:[{anchor:"transformers.LlamaModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaConfig">LlamaConfig</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.
config &#x2014; LlamaConfig`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L547"}}),kt=new C({props:{name:"forward",anchor:"transformers.LlamaModel.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.LlamaModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LlamaModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.LlamaModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LlamaModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.LlamaModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LlamaModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.LlamaModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LlamaModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.LlamaModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L598"}}),Me=new xi({props:{$$slots:{default:[pd]},$$scope:{ctx:F}}}),bt=new Ie({}),yt=new C({props:{name:"class transformers.LlamaForCausalLM",anchor:"transformers.LlamaForCausalLM",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L727"}}),wt=new C({props:{name:"forward",anchor:"transformers.LlamaForCausalLM.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.LlamaForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LlamaForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.LlamaForCausalLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LlamaForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.LlamaForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LlamaForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.LlamaForCausalLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LlamaForCausalLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.LlamaForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p>
<p>Args &#x2014;
labels (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>):
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L758",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast"
>transformers.modeling_outputs.CausalLMOutputWithPast</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaConfig"
>LlamaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast"
>transformers.modeling_outputs.CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ee=new xi({props:{$$slots:{default:[fd]},$$scope:{ctx:F}}}),Ce=new ia({props:{anchor:"transformers.LlamaForCausalLM.forward.example",$$slots:{default:[ud]},$$scope:{ctx:F}}}),Tt=new Ie({}),Lt=new C({props:{name:"class transformers.LlamaForSequenceClassification",anchor:"transformers.LlamaForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LlamaForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaConfig">LlamaConfig</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L907"}}),Et=new C({props:{name:"forward",anchor:"transformers.LlamaForSequenceClassification.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.LlamaForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LlamaForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.LlamaForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LlamaForSequenceClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.LlamaForSequenceClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LlamaForSequenceClassification.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.LlamaForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LlamaForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.LlamaForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.LlamaForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/llama/modeling_llama.py#L923"}}),Fe=new xi({props:{$$slots:{default:[gd]},$$scope:{ctx:F}}}),{c(){h=n("meta"),L=d(),f=n("h1"),g=n("a"),$=n("span"),_(u.$$.fragment),T=d(),q=n("span"),da=r("LLaMA"),hn=d(),H=n("h2"),ce=n("a"),fo=n("span"),_(je.$$.fragment),ca=d(),uo=n("span"),ma=r("Overview"),pn=d(),me=n("p"),ha=r("The LLaMA model was proposed in "),Ne=n("a"),pa=r("LLaMA: Open and Efficient Foundation Language Models"),fa=r(" by Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timoth\xE9e Lacroix, Baptiste Rozi\xE8re, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample. It is a collection of foundation language models ranging from 7B to 65B parameters."),fn=d(),Ft=n("p"),ua=r("The abstract from the paper is the following:"),un=d(),At=n("p"),go=n("em"),ga=r("We introduce LLaMA, a collection of foundation language models ranging from 7B to 65B parameters. We train our models on trillions of tokens, and show that it is possible to train state-of-the-art models using publicly available datasets exclusively, without resorting to proprietary and inaccessible datasets. In particular, LLaMA-13B outperforms GPT-3 (175B) on most benchmarks, and LLaMA-65B is competitive with the best models, Chinchilla-70B and PaLM-540B. We release all our models to the research community."),gn=d(),qt=n("p"),_a=r("Tips:"),_n=d(),he=n("ul"),Pt=n("li"),va=r("Weights for the LLaMA models can be obtained from by filling out "),Se=n("a"),ka=r("this form"),ba=d(),Ue=n("li"),ya=r("After downloading the weights, they will need to be converted to the Hugging Face Transformers format using the "),We=n("a"),wa=r("conversion script"),Ta=r(". The script can be called with the following (example) command:"),vn=d(),_(Be.$$.fragment),kn=d(),It=n("ul"),_o=n("li"),La=r("After conversion, the model and tokenizer can be loaded via:"),bn=d(),_(De.$$.fragment),yn=d(),jt=n("p"),$a=r(`Note that executing the script requires enough CPU RAM to host the whole model in float16 precision (even if the biggest versions
come in several checkpoints they each contain a part of each weight of the model, so we need to load them all in RAM). For the 65B model, it\u2019s thus 130GB of RAM needed.`),wn=d(),Nt=n("ul"),Je=n("li"),Ma=r("The LLaMA tokenizer is a BPE model based on "),Oe=n("a"),za=r("sentencepiece"),Ea=r(". One quirk of sentencepiece is that when decoding a sequence, if the first token is the start of the word (e.g. \u201CBanana\u201D), the tokenizer does not prepend the prefix space to the string."),Tn=d(),P=n("p"),Ca=r("This model was contributed by "),Ge=n("a"),xa=r("zphang"),Fa=r(" with contributions from "),Re=n("a"),Aa=r("BlackSamorez"),qa=r(". The code of the implementation in Hugging Face is based on GPT-NeoX "),Ve=n("a"),Pa=r("here"),Ia=r(". The original code of the authors can be found "),Ze=n("a"),ja=r("here"),Na=r("."),Ln=d(),St=n("p"),Sa=r("Based on the original LLaMA model, Meta AI has released some follow-up works:"),$n=d(),Ut=n("ul"),pe=n("li"),vo=n("strong"),Ua=r("Llama2"),Wa=r(": Llama2 is an improved version of Llama with some architectural tweaks (Grouped Query Attention), and is pre-trained on 2Trillion tokens. Refer to the documentation of Llama2 which can be found "),Wt=n("a"),Ba=r("here"),Da=r("."),Mn=d(),Y=n("h2"),fe=n("a"),ko=n("span"),_(Xe.$$.fragment),Ja=d(),bo=n("span"),Oa=r("LlamaConfig"),zn=d(),j=n("div"),_(He.$$.fragment),Ga=d(),Ye=n("p"),Ra=r("This is the configuration class to store the configuration of a "),Bt=n("a"),Va=r("LlamaModel"),Za=r(`. It is used to instantiate an LLaMA
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the LLaMA-7B.`),Xa=d(),Q=n("p"),Ha=r("Configuration objects inherit from "),Dt=n("a"),Ya=r("PretrainedConfig"),Qa=r(` and can be used to control the model outputs. Read the
documentation from `),Jt=n("a"),Ka=r("PretrainedConfig"),es=r(" for more information."),ts=d(),_(ue.$$.fragment),En=d(),K=n("h2"),ge=n("a"),yo=n("span"),_(Qe.$$.fragment),os=d(),wo=n("span"),ns=r("LlamaTokenizer"),Cn=d(),x=n("div"),_(Ke.$$.fragment),as=d(),To=n("p"),ss=r(`Construct a Llama tokenizer. Based on byte-level Byte-Pair-Encoding. The default padding token is unset as there is
no padding token in the original model.`),rs=d(),Ot=n("div"),_(et.$$.fragment),is=d(),_e=n("div"),_(tt.$$.fragment),ls=d(),ot=n("p"),ds=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 `),Lo=n("code"),cs=r("prepare_for_model"),ms=r(" method."),hs=d(),U=n("div"),_(nt.$$.fragment),ps=d(),$o=n("p"),fs=r("Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT"),us=d(),_(ve.$$.fragment),gs=d(),Mo=n("p"),_s=r("if token_ids_1 is None, only returns the first portion of the mask (0s)."),vs=d(),ke=n("div"),_(at.$$.fragment),ks=d(),zo=n("p"),bs=r("Save the vocabulary and special tokens file to a directory."),xn=d(),ee=n("h2"),be=n("a"),Eo=n("span"),_(st.$$.fragment),ys=d(),Co=n("span"),ws=r("LlamaTokenizerFast"),Fn=d(),M=n("div"),_(rt.$$.fragment),Ts=d(),xo=n("p"),Ls=r("Construct a Llama tokenizer. Based on byte-level Byte-Pair-Encoding."),$s=d(),Fo=n("p"),Ms=r("This uses notably ByteFallback and no normalization."),zs=d(),_(ye.$$.fragment),Es=d(),N=n("p"),Cs=r("If you want to change the "),Ao=n("code"),xs=r("bos_token"),Fs=r(" or the "),qo=n("code"),As=r("eos_token"),qs=r(`, make sure to specify them when initializing the model, or
call `),Po=n("code"),Ps=r("tokenizer.update_post_processor()"),Is=r(` to make sure that the post-processing is correctly done (otherwise the
values of the first token and final token of an encoded sequence will not be correct). For more details, checkout
[post-processors] (`),it=n("a"),js=r("https://huggingface.co/docs/tokenizers/api/post-processors"),Ns=r(") documentation."),Ss=d(),lt=n("p"),Us=r("This tokenizer inherits from "),Gt=n("a"),Ws=r("PreTrainedTokenizerFast"),Bs=r(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Ds=d(),D=n("div"),_(dt.$$.fragment),Js=d(),Io=n("p"),Os=r(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens.`),Gs=d(),jo=n("p"),Rs=r("This implementation does not add special tokens and this method should be overridden in a subclass."),Vs=d(),we=n("div"),_(ct.$$.fragment),Zs=d(),te=n("p"),Xs=r(`Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),No=n("code"),Hs=r("prepare_for_model"),Ys=r(" or "),So=n("code"),Qs=r("encode_plus"),Ks=r(" methods."),er=d(),J=n("div"),_(mt.$$.fragment),tr=d(),Rt=n("p"),or=r("Create the token type IDs corresponding to the sequences passed. "),Vt=n("a"),nr=r(`What are token type
IDs?`),ar=d(),Uo=n("p"),sr=r("Should be overridden in a subclass if the model has a special way of building those."),rr=d(),Te=n("div"),_(ht.$$.fragment),ir=d(),oe=n("p"),lr=r("Updates the underlying post processor with the current "),Wo=n("code"),dr=r("bos_token"),cr=r(" and "),Bo=n("code"),mr=r("eos_token"),hr=r("."),pr=d(),Zt=n("div"),_(pt.$$.fragment),An=d(),ne=n("h2"),Le=n("a"),Do=n("span"),_(ft.$$.fragment),fr=d(),Jo=n("span"),ur=r("LlamaModel"),qn=d(),A=n("div"),_(ut.$$.fragment),gr=d(),gt=n("p"),_r=r(`The bare LLaMA Model outputting raw hidden-states without any specific head on top.
This model inherits from `),Xt=n("a"),vr=r("PreTrainedModel"),kr=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),br=d(),_t=n("p"),yr=r("This model is also a PyTorch "),vt=n("a"),wr=r("torch.nn.Module"),Tr=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Lr=d(),$e=n("p"),$r=r("Transformer decoder consisting of "),Oo=n("em"),Mr=r("config.num_hidden_layers"),zr=r(" layers. Each layer is a "),Go=n("code"),Er=r("LlamaDecoderLayer"),Cr=d(),O=n("div"),_(kt.$$.fragment),xr=d(),ae=n("p"),Fr=r("The "),Ht=n("a"),Ar=r("LlamaModel"),qr=r(" forward method, overrides the "),Ro=n("code"),Pr=r("__call__"),Ir=r(" special method."),jr=d(),_(Me.$$.fragment),Pn=d(),se=n("h2"),ze=n("a"),Vo=n("span"),_(bt.$$.fragment),Nr=d(),Zo=n("span"),Sr=r("LlamaForCausalLM"),In=d(),re=n("div"),_(yt.$$.fragment),Ur=d(),W=n("div"),_(wt.$$.fragment),Wr=d(),ie=n("p"),Br=r("The "),Yt=n("a"),Dr=r("LlamaForCausalLM"),Jr=r(" forward method, overrides the "),Xo=n("code"),Or=r("__call__"),Gr=r(" special method."),Rr=d(),_(Ee.$$.fragment),Vr=d(),_(Ce.$$.fragment),jn=d(),le=n("h2"),xe=n("a"),Ho=n("span"),_(Tt.$$.fragment),Zr=d(),Yo=n("span"),Xr=r("LlamaForSequenceClassification"),Nn=d(),E=n("div"),_(Lt.$$.fragment),Hr=d(),Qo=n("p"),Yr=r("The LLaMa Model transformer with a sequence classification head on top (linear layer)."),Qr=d(),Qt=n("p"),Kt=n("a"),Kr=r("LlamaForSequenceClassification"),ei=r(` uses the last token in order to do the classification, as other causal models
(e.g. GPT-2) do.`),ti=d(),S=n("p"),oi=r(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Ko=n("code"),ni=r("pad_token_id"),ai=r(` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),en=n("code"),si=r("pad_token_id"),ri=r(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),tn=n("code"),ii=r("inputs_embeds"),li=r(" are passed instead of "),on=n("code"),di=r("input_ids"),ci=r(`, it does the same (take the last value in
each row of the batch).`),mi=d(),$t=n("p"),hi=r("This model inherits from "),eo=n("a"),pi=r("PreTrainedModel"),fi=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ui=d(),Mt=n("p"),gi=r("This model is also a PyTorch "),zt=n("a"),_i=r("torch.nn.Module"),vi=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ki=d(),G=n("div"),_(Et.$$.fragment),bi=d(),de=n("p"),yi=r("The "),to=n("a"),wi=r("LlamaForSequenceClassification"),Ti=r(" forward method, overrides the "),nn=n("code"),Li=r("__call__"),$i=r(" special method."),Mi=d(),_(Fe.$$.fragment),this.h()},l(t){const m=ld('[data-svelte="svelte-1phssyn"]',document.head);h=a(m,"META",{name:!0,content:!0}),m.forEach(o),L=c(t),f=a(t,"H1",{class:!0});var Ct=s(f);g=a(Ct,"A",{id:!0,class:!0,href:!0});var an=s(g);$=a(an,"SPAN",{});var sn=s($);v(u.$$.fragment,sn),sn.forEach(o),an.forEach(o),T=c(Ct),q=a(Ct,"SPAN",{});var rn=s(q);da=i(rn,"LLaMA"),rn.forEach(o),Ct.forEach(o),hn=c(t),H=a(t,"H2",{class:!0});var xt=s(H);ce=a(xt,"A",{id:!0,class:!0,href:!0});var ln=s(ce);fo=a(ln,"SPAN",{});var dn=s(fo);v(je.$$.fragment,dn),dn.forEach(o),ln.forEach(o),ca=c(xt),uo=a(xt,"SPAN",{});var Fi=s(uo);ma=i(Fi,"Overview"),Fi.forEach(o),xt.forEach(o),pn=c(t),me=a(t,"P",{});var Un=s(me);ha=i(Un,"The LLaMA model was proposed in "),Ne=a(Un,"A",{href:!0,rel:!0});var Ai=s(Ne);pa=i(Ai,"LLaMA: Open and Efficient Foundation Language Models"),Ai.forEach(o),fa=i(Un," by Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timoth\xE9e Lacroix, Baptiste Rozi\xE8re, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample. It is a collection of foundation language models ranging from 7B to 65B parameters."),Un.forEach(o),fn=c(t),Ft=a(t,"P",{});var qi=s(Ft);ua=i(qi,"The abstract from the paper is the following:"),qi.forEach(o),un=c(t),At=a(t,"P",{});var Pi=s(At);go=a(Pi,"EM",{});var Ii=s(go);ga=i(Ii,"We introduce LLaMA, a collection of foundation language models ranging from 7B to 65B parameters. We train our models on trillions of tokens, and show that it is possible to train state-of-the-art models using publicly available datasets exclusively, without resorting to proprietary and inaccessible datasets. In particular, LLaMA-13B outperforms GPT-3 (175B) on most benchmarks, and LLaMA-65B is competitive with the best models, Chinchilla-70B and PaLM-540B. We release all our models to the research community."),Ii.forEach(o),Pi.forEach(o),gn=c(t),qt=a(t,"P",{});var ji=s(qt);_a=i(ji,"Tips:"),ji.forEach(o),_n=c(t),he=a(t,"UL",{});var Wn=s(he);Pt=a(Wn,"LI",{});var zi=s(Pt);va=i(zi,"Weights for the LLaMA models can be obtained from by filling out "),Se=a(zi,"A",{href:!0,rel:!0});var Ni=s(Se);ka=i(Ni,"this form"),Ni.forEach(o),zi.forEach(o),ba=c(Wn),Ue=a(Wn,"LI",{});var Bn=s(Ue);ya=i(Bn,"After downloading the weights, they will need to be converted to the Hugging Face Transformers format using the "),We=a(Bn,"A",{href:!0,rel:!0});var Si=s(We);wa=i(Si,"conversion script"),Si.forEach(o),Ta=i(Bn,". The script can be called with the following (example) command:"),Bn.forEach(o),Wn.forEach(o),vn=c(t),v(Be.$$.fragment,t),kn=c(t),It=a(t,"UL",{});var Ui=s(It);_o=a(Ui,"LI",{});var Wi=s(_o);La=i(Wi,"After conversion, the model and tokenizer can be loaded via:"),Wi.forEach(o),Ui.forEach(o),bn=c(t),v(De.$$.fragment,t),yn=c(t),jt=a(t,"P",{});var Bi=s(jt);$a=i(Bi,`Note that executing the script requires enough CPU RAM to host the whole model in float16 precision (even if the biggest versions
come in several checkpoints they each contain a part of each weight of the model, so we need to load them all in RAM). For the 65B model, it\u2019s thus 130GB of RAM needed.`),Bi.forEach(o),wn=c(t),Nt=a(t,"UL",{});var Di=s(Nt);Je=a(Di,"LI",{});var Dn=s(Je);Ma=i(Dn,"The LLaMA tokenizer is a BPE model based on "),Oe=a(Dn,"A",{href:!0,rel:!0});var Ji=s(Oe);za=i(Ji,"sentencepiece"),Ji.forEach(o),Ea=i(Dn,". One quirk of sentencepiece is that when decoding a sequence, if the first token is the start of the word (e.g. \u201CBanana\u201D), the tokenizer does not prepend the prefix space to the string."),Dn.forEach(o),Di.forEach(o),Tn=c(t),P=a(t,"P",{});var R=s(P);Ca=i(R,"This model was contributed by "),Ge=a(R,"A",{href:!0,rel:!0});var Oi=s(Ge);xa=i(Oi,"zphang"),Oi.forEach(o),Fa=i(R," with contributions from "),Re=a(R,"A",{href:!0,rel:!0});var Gi=s(Re);Aa=i(Gi,"BlackSamorez"),Gi.forEach(o),qa=i(R,". The code of the implementation in Hugging Face is based on GPT-NeoX "),Ve=a(R,"A",{href:!0,rel:!0});var Ri=s(Ve);Pa=i(Ri,"here"),Ri.forEach(o),Ia=i(R,". The original code of the authors can be found "),Ze=a(R,"A",{href:!0,rel:!0});var Vi=s(Ze);ja=i(Vi,"here"),Vi.forEach(o),Na=i(R,"."),R.forEach(o),Ln=c(t),St=a(t,"P",{});var Zi=s(St);Sa=i(Zi,"Based on the original LLaMA model, Meta AI has released some follow-up works:"),Zi.forEach(o),$n=c(t),Ut=a(t,"UL",{});var Xi=s(Ut);pe=a(Xi,"LI",{});var cn=s(pe);vo=a(cn,"STRONG",{});var Hi=s(vo);Ua=i(Hi,"Llama2"),Hi.forEach(o),Wa=i(cn,": Llama2 is an improved version of Llama with some architectural tweaks (Grouped Query Attention), and is pre-trained on 2Trillion tokens. Refer to the documentation of Llama2 which can be found "),Wt=a(cn,"A",{href:!0});var Yi=s(Wt);Ba=i(Yi,"here"),Yi.forEach(o),Da=i(cn,"."),cn.forEach(o),Xi.forEach(o),Mn=c(t),Y=a(t,"H2",{class:!0});var Jn=s(Y);fe=a(Jn,"A",{id:!0,class:!0,href:!0});var Qi=s(fe);ko=a(Qi,"SPAN",{});var Ki=s(ko);v(Xe.$$.fragment,Ki),Ki.forEach(o),Qi.forEach(o),Ja=c(Jn),bo=a(Jn,"SPAN",{});var el=s(bo);Oa=i(el,"LlamaConfig"),el.forEach(o),Jn.forEach(o),zn=c(t),j=a(t,"DIV",{class:!0});var Ae=s(j);v(He.$$.fragment,Ae),Ga=c(Ae),Ye=a(Ae,"P",{});var On=s(Ye);Ra=i(On,"This is the configuration class to store the configuration of a "),Bt=a(On,"A",{href:!0});var tl=s(Bt);Va=i(tl,"LlamaModel"),tl.forEach(o),Za=i(On,`. It is used to instantiate an LLaMA
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the LLaMA-7B.`),On.forEach(o),Xa=c(Ae),Q=a(Ae,"P",{});var oo=s(Q);Ha=i(oo,"Configuration objects inherit from "),Dt=a(oo,"A",{href:!0});var ol=s(Dt);Ya=i(ol,"PretrainedConfig"),ol.forEach(o),Qa=i(oo,` and can be used to control the model outputs. Read the
documentation from `),Jt=a(oo,"A",{href:!0});var nl=s(Jt);Ka=i(nl,"PretrainedConfig"),nl.forEach(o),es=i(oo," for more information."),oo.forEach(o),ts=c(Ae),v(ue.$$.fragment,Ae),Ae.forEach(o),En=c(t),K=a(t,"H2",{class:!0});var Gn=s(K);ge=a(Gn,"A",{id:!0,class:!0,href:!0});var al=s(ge);yo=a(al,"SPAN",{});var sl=s(yo);v(Qe.$$.fragment,sl),sl.forEach(o),al.forEach(o),os=c(Gn),wo=a(Gn,"SPAN",{});var rl=s(wo);ns=i(rl,"LlamaTokenizer"),rl.forEach(o),Gn.forEach(o),Cn=c(t),x=a(t,"DIV",{class:!0});var B=s(x);v(Ke.$$.fragment,B),as=c(B),To=a(B,"P",{});var il=s(To);ss=i(il,`Construct a Llama tokenizer. Based on byte-level Byte-Pair-Encoding. The default padding token is unset as there is
no padding token in the original model.`),il.forEach(o),rs=c(B),Ot=a(B,"DIV",{class:!0});var ll=s(Ot);v(et.$$.fragment,ll),ll.forEach(o),is=c(B),_e=a(B,"DIV",{class:!0});var Rn=s(_e);v(tt.$$.fragment,Rn),ls=c(Rn),ot=a(Rn,"P",{});var Vn=s(ot);ds=i(Vn,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),Lo=a(Vn,"CODE",{});var dl=s(Lo);cs=i(dl,"prepare_for_model"),dl.forEach(o),ms=i(Vn," method."),Vn.forEach(o),Rn.forEach(o),hs=c(B),U=a(B,"DIV",{class:!0});var qe=s(U);v(nt.$$.fragment,qe),ps=c(qe),$o=a(qe,"P",{});var cl=s($o);fs=i(cl,"Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT"),cl.forEach(o),us=c(qe),v(ve.$$.fragment,qe),gs=c(qe),Mo=a(qe,"P",{});var ml=s(Mo);_s=i(ml,"if token_ids_1 is None, only returns the first portion of the mask (0s)."),ml.forEach(o),qe.forEach(o),vs=c(B),ke=a(B,"DIV",{class:!0});var Zn=s(ke);v(at.$$.fragment,Zn),ks=c(Zn),zo=a(Zn,"P",{});var hl=s(zo);bs=i(hl,"Save the vocabulary and special tokens file to a directory."),hl.forEach(o),Zn.forEach(o),B.forEach(o),xn=c(t),ee=a(t,"H2",{class:!0});var Xn=s(ee);be=a(Xn,"A",{id:!0,class:!0,href:!0});var pl=s(be);Eo=a(pl,"SPAN",{});var fl=s(Eo);v(st.$$.fragment,fl),fl.forEach(o),pl.forEach(o),ys=c(Xn),Co=a(Xn,"SPAN",{});var ul=s(Co);ws=i(ul,"LlamaTokenizerFast"),ul.forEach(o),Xn.forEach(o),Fn=c(t),M=a(t,"DIV",{class:!0});var z=s(M);v(rt.$$.fragment,z),Ts=c(z),xo=a(z,"P",{});var gl=s(xo);Ls=i(gl,"Construct a Llama tokenizer. Based on byte-level Byte-Pair-Encoding."),gl.forEach(o),$s=c(z),Fo=a(z,"P",{});var _l=s(Fo);Ms=i(_l,"This uses notably ByteFallback and no normalization."),_l.forEach(o),zs=c(z),v(ye.$$.fragment,z),Es=c(z),N=a(z,"P",{});var V=s(N);Cs=i(V,"If you want to change the "),Ao=a(V,"CODE",{});var vl=s(Ao);xs=i(vl,"bos_token"),vl.forEach(o),Fs=i(V," or the "),qo=a(V,"CODE",{});var kl=s(qo);As=i(kl,"eos_token"),kl.forEach(o),qs=i(V,`, make sure to specify them when initializing the model, or
call `),Po=a(V,"CODE",{});var bl=s(Po);Ps=i(bl,"tokenizer.update_post_processor()"),bl.forEach(o),Is=i(V,` to make sure that the post-processing is correctly done (otherwise the
values of the first token and final token of an encoded sequence will not be correct). For more details, checkout
[post-processors] (`),it=a(V,"A",{href:!0,rel:!0});var yl=s(it);js=i(yl,"https://huggingface.co/docs/tokenizers/api/post-processors"),yl.forEach(o),Ns=i(V,") documentation."),V.forEach(o),Ss=c(z),lt=a(z,"P",{});var Hn=s(lt);Us=i(Hn,"This tokenizer inherits from "),Gt=a(Hn,"A",{href:!0});var wl=s(Gt);Ws=i(wl,"PreTrainedTokenizerFast"),wl.forEach(o),Bs=i(Hn,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Hn.forEach(o),Ds=c(z),D=a(z,"DIV",{class:!0});var no=s(D);v(dt.$$.fragment,no),Js=c(no),Io=a(no,"P",{});var Tl=s(Io);Os=i(Tl,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens.`),Tl.forEach(o),Gs=c(no),jo=a(no,"P",{});var Ll=s(jo);Rs=i(Ll,"This implementation does not add special tokens and this method should be overridden in a subclass."),Ll.forEach(o),no.forEach(o),Vs=c(z),we=a(z,"DIV",{class:!0});var Yn=s(we);v(ct.$$.fragment,Yn),Zs=c(Yn),te=a(Yn,"P",{});var ao=s(te);Xs=i(ao,`Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),No=a(ao,"CODE",{});var $l=s(No);Hs=i($l,"prepare_for_model"),$l.forEach(o),Ys=i(ao," or "),So=a(ao,"CODE",{});var Ml=s(So);Qs=i(Ml,"encode_plus"),Ml.forEach(o),Ks=i(ao," methods."),ao.forEach(o),Yn.forEach(o),er=c(z),J=a(z,"DIV",{class:!0});var so=s(J);v(mt.$$.fragment,so),tr=c(so),Rt=a(so,"P",{});var Ei=s(Rt);or=i(Ei,"Create the token type IDs corresponding to the sequences passed. "),Vt=a(Ei,"A",{href:!0});var zl=s(Vt);nr=i(zl,`What are token type
IDs?`),zl.forEach(o),Ei.forEach(o),ar=c(so),Uo=a(so,"P",{});var El=s(Uo);sr=i(El,"Should be overridden in a subclass if the model has a special way of building those."),El.forEach(o),so.forEach(o),rr=c(z),Te=a(z,"DIV",{class:!0});var Qn=s(Te);v(ht.$$.fragment,Qn),ir=c(Qn),oe=a(Qn,"P",{});var ro=s(oe);lr=i(ro,"Updates the underlying post processor with the current "),Wo=a(ro,"CODE",{});var Cl=s(Wo);dr=i(Cl,"bos_token"),Cl.forEach(o),cr=i(ro," and "),Bo=a(ro,"CODE",{});var xl=s(Bo);mr=i(xl,"eos_token"),xl.forEach(o),hr=i(ro,"."),ro.forEach(o),Qn.forEach(o),pr=c(z),Zt=a(z,"DIV",{class:!0});var Fl=s(Zt);v(pt.$$.fragment,Fl),Fl.forEach(o),z.forEach(o),An=c(t),ne=a(t,"H2",{class:!0});var Kn=s(ne);Le=a(Kn,"A",{id:!0,class:!0,href:!0});var Al=s(Le);Do=a(Al,"SPAN",{});var ql=s(Do);v(ft.$$.fragment,ql),ql.forEach(o),Al.forEach(o),fr=c(Kn),Jo=a(Kn,"SPAN",{});var Pl=s(Jo);ur=i(Pl,"LlamaModel"),Pl.forEach(o),Kn.forEach(o),qn=c(t),A=a(t,"DIV",{class:!0});var Z=s(A);v(ut.$$.fragment,Z),gr=c(Z),gt=a(Z,"P",{});var ea=s(gt);_r=i(ea,`The bare LLaMA Model outputting raw hidden-states without any specific head on top.
This model inherits from `),Xt=a(ea,"A",{href:!0});var Il=s(Xt);vr=i(Il,"PreTrainedModel"),Il.forEach(o),kr=i(ea,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ea.forEach(o),br=c(Z),_t=a(Z,"P",{});var ta=s(_t);yr=i(ta,"This model is also a PyTorch "),vt=a(ta,"A",{href:!0,rel:!0});var jl=s(vt);wr=i(jl,"torch.nn.Module"),jl.forEach(o),Tr=i(ta,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ta.forEach(o),Lr=c(Z),$e=a(Z,"P",{});var mn=s($e);$r=i(mn,"Transformer decoder consisting of "),Oo=a(mn,"EM",{});var Nl=s(Oo);Mr=i(Nl,"config.num_hidden_layers"),Nl.forEach(o),zr=i(mn," layers. Each layer is a "),Go=a(mn,"CODE",{});var Sl=s(Go);Er=i(Sl,"LlamaDecoderLayer"),Sl.forEach(o),mn.forEach(o),Cr=c(Z),O=a(Z,"DIV",{class:!0});var io=s(O);v(kt.$$.fragment,io),xr=c(io),ae=a(io,"P",{});var lo=s(ae);Fr=i(lo,"The "),Ht=a(lo,"A",{href:!0});var Ul=s(Ht);Ar=i(Ul,"LlamaModel"),Ul.forEach(o),qr=i(lo," forward method, overrides the "),Ro=a(lo,"CODE",{});var Wl=s(Ro);Pr=i(Wl,"__call__"),Wl.forEach(o),Ir=i(lo," special method."),lo.forEach(o),jr=c(io),v(Me.$$.fragment,io),io.forEach(o),Z.forEach(o),Pn=c(t),se=a(t,"H2",{class:!0});var oa=s(se);ze=a(oa,"A",{id:!0,class:!0,href:!0});var Bl=s(ze);Vo=a(Bl,"SPAN",{});var Dl=s(Vo);v(bt.$$.fragment,Dl),Dl.forEach(o),Bl.forEach(o),Nr=c(oa),Zo=a(oa,"SPAN",{});var Jl=s(Zo);Sr=i(Jl,"LlamaForCausalLM"),Jl.forEach(o),oa.forEach(o),In=c(t),re=a(t,"DIV",{class:!0});var na=s(re);v(yt.$$.fragment,na),Ur=c(na),W=a(na,"DIV",{class:!0});var Pe=s(W);v(wt.$$.fragment,Pe),Wr=c(Pe),ie=a(Pe,"P",{});var co=s(ie);Br=i(co,"The "),Yt=a(co,"A",{href:!0});var Ol=s(Yt);Dr=i(Ol,"LlamaForCausalLM"),Ol.forEach(o),Jr=i(co," forward method, overrides the "),Xo=a(co,"CODE",{});var Gl=s(Xo);Or=i(Gl,"__call__"),Gl.forEach(o),Gr=i(co," special method."),co.forEach(o),Rr=c(Pe),v(Ee.$$.fragment,Pe),Vr=c(Pe),v(Ce.$$.fragment,Pe),Pe.forEach(o),na.forEach(o),jn=c(t),le=a(t,"H2",{class:!0});var aa=s(le);xe=a(aa,"A",{id:!0,class:!0,href:!0});var Rl=s(xe);Ho=a(Rl,"SPAN",{});var Vl=s(Ho);v(Tt.$$.fragment,Vl),Vl.forEach(o),Rl.forEach(o),Zr=c(aa),Yo=a(aa,"SPAN",{});var Zl=s(Yo);Xr=i(Zl,"LlamaForSequenceClassification"),Zl.forEach(o),aa.forEach(o),Nn=c(t),E=a(t,"DIV",{class:!0});var I=s(E);v(Lt.$$.fragment,I),Hr=c(I),Qo=a(I,"P",{});var Xl=s(Qo);Yr=i(Xl,"The LLaMa Model transformer with a sequence classification head on top (linear layer)."),Xl.forEach(o),Qr=c(I),Qt=a(I,"P",{});var Ci=s(Qt);Kt=a(Ci,"A",{href:!0});var Hl=s(Kt);Kr=i(Hl,"LlamaForSequenceClassification"),Hl.forEach(o),ei=i(Ci,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-2) do.`),Ci.forEach(o),ti=c(I),S=a(I,"P",{});var X=s(S);oi=i(X,`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Ko=a(X,"CODE",{});var Yl=s(Ko);ni=i(Yl,"pad_token_id"),Yl.forEach(o),ai=i(X,` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),en=a(X,"CODE",{});var Ql=s(en);si=i(Ql,"pad_token_id"),Ql.forEach(o),ri=i(X,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),tn=a(X,"CODE",{});var Kl=s(tn);ii=i(Kl,"inputs_embeds"),Kl.forEach(o),li=i(X," are passed instead of "),on=a(X,"CODE",{});var ed=s(on);di=i(ed,"input_ids"),ed.forEach(o),ci=i(X,`, it does the same (take the last value in
each row of the batch).`),X.forEach(o),mi=c(I),$t=a(I,"P",{});var sa=s($t);hi=i(sa,"This model inherits from "),eo=a(sa,"A",{href:!0});var td=s(eo);pi=i(td,"PreTrainedModel"),td.forEach(o),fi=i(sa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),sa.forEach(o),ui=c(I),Mt=a(I,"P",{});var ra=s(Mt);gi=i(ra,"This model is also a PyTorch "),zt=a(ra,"A",{href:!0,rel:!0});var od=s(zt);_i=i(od,"torch.nn.Module"),od.forEach(o),vi=i(ra,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ra.forEach(o),ki=c(I),G=a(I,"DIV",{class:!0});var mo=s(G);v(Et.$$.fragment,mo),bi=c(mo),de=a(mo,"P",{});var ho=s(de);yi=i(ho,"The "),to=a(ho,"A",{href:!0});var nd=s(to);wi=i(nd,"LlamaForSequenceClassification"),nd.forEach(o),Ti=i(ho," forward method, overrides the "),nn=a(ho,"CODE",{});var ad=s(nn);Li=i(ad,"__call__"),ad.forEach(o),$i=i(ho," special method."),ho.forEach(o),Mi=c(mo),v(Fe.$$.fragment,mo),mo.forEach(o),I.forEach(o),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(vd)),l(g,"id","llama"),l(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(g,"href","#llama"),l(f,"class","relative group"),l(ce,"id","overview"),l(ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ce,"href","#overview"),l(H,"class","relative group"),l(Ne,"href","https://arxiv.org/abs/2302.13971"),l(Ne,"rel","nofollow"),l(Se,"href","https://docs.google.com/forms/d/e/1FAIpQLSfqNECQnMkycAp2jP4Z9TFX0cGR4uf7b_fBxjY_OjhJILlKGA/viewform?usp=send_form"),l(Se,"rel","nofollow"),l(We,"href","https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py"),l(We,"rel","nofollow"),l(Oe,"href","https://github.com/google/sentencepiece"),l(Oe,"rel","nofollow"),l(Ge,"href","https://huggingface.co/zphang"),l(Ge,"rel","nofollow"),l(Re,"href","https://huggingface.co/BlackSamorez"),l(Re,"rel","nofollow"),l(Ve,"href","https://github.com/EleutherAI/gpt-neox"),l(Ve,"rel","nofollow"),l(Ze,"href","https://github.com/facebookresearch/llama"),l(Ze,"rel","nofollow"),l(Wt,"href","llama2"),l(fe,"id","transformers.LlamaConfig"),l(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(fe,"href","#transformers.LlamaConfig"),l(Y,"class","relative group"),l(Bt,"href","/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaModel"),l(Dt,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(Jt,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ge,"id","transformers.LlamaTokenizer"),l(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ge,"href","#transformers.LlamaTokenizer"),l(K,"class","relative group"),l(Ot,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(be,"id","transformers.LlamaTokenizerFast"),l(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(be,"href","#transformers.LlamaTokenizerFast"),l(ee,"class","relative group"),l(it,"href","https://huggingface.co/docs/tokenizers/api/post-processors"),l(it,"rel","nofollow"),l(Gt,"href","/docs/transformers/v4.31.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),l(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Vt,"href","../glossary#token-type-ids"),l(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Zt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Le,"id","transformers.LlamaModel"),l(Le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Le,"href","#transformers.LlamaModel"),l(ne,"class","relative group"),l(Xt,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),l(vt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(vt,"rel","nofollow"),l(Ht,"href","/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaModel"),l(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ze,"id","transformers.LlamaForCausalLM"),l(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ze,"href","#transformers.LlamaForCausalLM"),l(se,"class","relative group"),l(Yt,"href","/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaForCausalLM"),l(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(xe,"id","transformers.LlamaForSequenceClassification"),l(xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(xe,"href","#transformers.LlamaForSequenceClassification"),l(le,"class","relative group"),l(Kt,"href","/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaForSequenceClassification"),l(eo,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),l(zt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(zt,"rel","nofollow"),l(to,"href","/docs/transformers/v4.31.0/en/model_doc/llama#transformers.LlamaForSequenceClassification"),l(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,m){e(document.head,h),p(t,L,m),p(t,f,m),e(f,g),e(g,$),k(u,$,null),e(f,T),e(f,q),e(q,da),p(t,hn,m),p(t,H,m),e(H,ce),e(ce,fo),k(je,fo,null),e(H,ca),e(H,uo),e(uo,ma),p(t,pn,m),p(t,me,m),e(me,ha),e(me,Ne),e(Ne,pa),e(me,fa),p(t,fn,m),p(t,Ft,m),e(Ft,ua),p(t,un,m),p(t,At,m),e(At,go),e(go,ga),p(t,gn,m),p(t,qt,m),e(qt,_a),p(t,_n,m),p(t,he,m),e(he,Pt),e(Pt,va),e(Pt,Se),e(Se,ka),e(he,ba),e(he,Ue),e(Ue,ya),e(Ue,We),e(We,wa),e(Ue,Ta),p(t,vn,m),k(Be,t,m),p(t,kn,m),p(t,It,m),e(It,_o),e(_o,La),p(t,bn,m),k(De,t,m),p(t,yn,m),p(t,jt,m),e(jt,$a),p(t,wn,m),p(t,Nt,m),e(Nt,Je),e(Je,Ma),e(Je,Oe),e(Oe,za),e(Je,Ea),p(t,Tn,m),p(t,P,m),e(P,Ca),e(P,Ge),e(Ge,xa),e(P,Fa),e(P,Re),e(Re,Aa),e(P,qa),e(P,Ve),e(Ve,Pa),e(P,Ia),e(P,Ze),e(Ze,ja),e(P,Na),p(t,Ln,m),p(t,St,m),e(St,Sa),p(t,$n,m),p(t,Ut,m),e(Ut,pe),e(pe,vo),e(vo,Ua),e(pe,Wa),e(pe,Wt),e(Wt,Ba),e(pe,Da),p(t,Mn,m),p(t,Y,m),e(Y,fe),e(fe,ko),k(Xe,ko,null),e(Y,Ja),e(Y,bo),e(bo,Oa),p(t,zn,m),p(t,j,m),k(He,j,null),e(j,Ga),e(j,Ye),e(Ye,Ra),e(Ye,Bt),e(Bt,Va),e(Ye,Za),e(j,Xa),e(j,Q),e(Q,Ha),e(Q,Dt),e(Dt,Ya),e(Q,Qa),e(Q,Jt),e(Jt,Ka),e(Q,es),e(j,ts),k(ue,j,null),p(t,En,m),p(t,K,m),e(K,ge),e(ge,yo),k(Qe,yo,null),e(K,os),e(K,wo),e(wo,ns),p(t,Cn,m),p(t,x,m),k(Ke,x,null),e(x,as),e(x,To),e(To,ss),e(x,rs),e(x,Ot),k(et,Ot,null),e(x,is),e(x,_e),k(tt,_e,null),e(_e,ls),e(_e,ot),e(ot,ds),e(ot,Lo),e(Lo,cs),e(ot,ms),e(x,hs),e(x,U),k(nt,U,null),e(U,ps),e(U,$o),e($o,fs),e(U,us),k(ve,U,null),e(U,gs),e(U,Mo),e(Mo,_s),e(x,vs),e(x,ke),k(at,ke,null),e(ke,ks),e(ke,zo),e(zo,bs),p(t,xn,m),p(t,ee,m),e(ee,be),e(be,Eo),k(st,Eo,null),e(ee,ys),e(ee,Co),e(Co,ws),p(t,Fn,m),p(t,M,m),k(rt,M,null),e(M,Ts),e(M,xo),e(xo,Ls),e(M,$s),e(M,Fo),e(Fo,Ms),e(M,zs),k(ye,M,null),e(M,Es),e(M,N),e(N,Cs),e(N,Ao),e(Ao,xs),e(N,Fs),e(N,qo),e(qo,As),e(N,qs),e(N,Po),e(Po,Ps),e(N,Is),e(N,it),e(it,js),e(N,Ns),e(M,Ss),e(M,lt),e(lt,Us),e(lt,Gt),e(Gt,Ws),e(lt,Bs),e(M,Ds),e(M,D),k(dt,D,null),e(D,Js),e(D,Io),e(Io,Os),e(D,Gs),e(D,jo),e(jo,Rs),e(M,Vs),e(M,we),k(ct,we,null),e(we,Zs),e(we,te),e(te,Xs),e(te,No),e(No,Hs),e(te,Ys),e(te,So),e(So,Qs),e(te,Ks),e(M,er),e(M,J),k(mt,J,null),e(J,tr),e(J,Rt),e(Rt,or),e(Rt,Vt),e(Vt,nr),e(J,ar),e(J,Uo),e(Uo,sr),e(M,rr),e(M,Te),k(ht,Te,null),e(Te,ir),e(Te,oe),e(oe,lr),e(oe,Wo),e(Wo,dr),e(oe,cr),e(oe,Bo),e(Bo,mr),e(oe,hr),e(M,pr),e(M,Zt),k(pt,Zt,null),p(t,An,m),p(t,ne,m),e(ne,Le),e(Le,Do),k(ft,Do,null),e(ne,fr),e(ne,Jo),e(Jo,ur),p(t,qn,m),p(t,A,m),k(ut,A,null),e(A,gr),e(A,gt),e(gt,_r),e(gt,Xt),e(Xt,vr),e(gt,kr),e(A,br),e(A,_t),e(_t,yr),e(_t,vt),e(vt,wr),e(_t,Tr),e(A,Lr),e(A,$e),e($e,$r),e($e,Oo),e(Oo,Mr),e($e,zr),e($e,Go),e(Go,Er),e(A,Cr),e(A,O),k(kt,O,null),e(O,xr),e(O,ae),e(ae,Fr),e(ae,Ht),e(Ht,Ar),e(ae,qr),e(ae,Ro),e(Ro,Pr),e(ae,Ir),e(O,jr),k(Me,O,null),p(t,Pn,m),p(t,se,m),e(se,ze),e(ze,Vo),k(bt,Vo,null),e(se,Nr),e(se,Zo),e(Zo,Sr),p(t,In,m),p(t,re,m),k(yt,re,null),e(re,Ur),e(re,W),k(wt,W,null),e(W,Wr),e(W,ie),e(ie,Br),e(ie,Yt),e(Yt,Dr),e(ie,Jr),e(ie,Xo),e(Xo,Or),e(ie,Gr),e(W,Rr),k(Ee,W,null),e(W,Vr),k(Ce,W,null),p(t,jn,m),p(t,le,m),e(le,xe),e(xe,Ho),k(Tt,Ho,null),e(le,Zr),e(le,Yo),e(Yo,Xr),p(t,Nn,m),p(t,E,m),k(Lt,E,null),e(E,Hr),e(E,Qo),e(Qo,Yr),e(E,Qr),e(E,Qt),e(Qt,Kt),e(Kt,Kr),e(Qt,ei),e(E,ti),e(E,S),e(S,oi),e(S,Ko),e(Ko,ni),e(S,ai),e(S,en),e(en,si),e(S,ri),e(S,tn),e(tn,ii),e(S,li),e(S,on),e(on,di),e(S,ci),e(E,mi),e(E,$t),e($t,hi),e($t,eo),e(eo,pi),e($t,fi),e(E,ui),e(E,Mt),e(Mt,gi),e(Mt,zt),e(zt,_i),e(Mt,vi),e(E,ki),e(E,G),k(Et,G,null),e(G,bi),e(G,de),e(de,yi),e(de,to),e(to,wi),e(de,Ti),e(de,nn),e(nn,Li),e(de,$i),e(G,Mi),k(Fe,G,null),Sn=!0},p(t,[m]){const Ct={};m&2&&(Ct.$$scope={dirty:m,ctx:t}),ue.$set(Ct);const an={};m&2&&(an.$$scope={dirty:m,ctx:t}),ve.$set(an);const sn={};m&2&&(sn.$$scope={dirty:m,ctx:t}),ye.$set(sn);const rn={};m&2&&(rn.$$scope={dirty:m,ctx:t}),Me.$set(rn);const xt={};m&2&&(xt.$$scope={dirty:m,ctx:t}),Ee.$set(xt);const ln={};m&2&&(ln.$$scope={dirty:m,ctx:t}),Ce.$set(ln);const dn={};m&2&&(dn.$$scope={dirty:m,ctx:t}),Fe.$set(dn)},i(t){Sn||(b(u.$$.fragment,t),b(je.$$.fragment,t),b(Be.$$.fragment,t),b(De.$$.fragment,t),b(Xe.$$.fragment,t),b(He.$$.fragment,t),b(ue.$$.fragment,t),b(Qe.$$.fragment,t),b(Ke.$$.fragment,t),b(et.$$.fragment,t),b(tt.$$.fragment,t),b(nt.$$.fragment,t),b(ve.$$.fragment,t),b(at.$$.fragment,t),b(st.$$.fragment,t),b(rt.$$.fragment,t),b(ye.$$.fragment,t),b(dt.$$.fragment,t),b(ct.$$.fragment,t),b(mt.$$.fragment,t),b(ht.$$.fragment,t),b(pt.$$.fragment,t),b(ft.$$.fragment,t),b(ut.$$.fragment,t),b(kt.$$.fragment,t),b(Me.$$.fragment,t),b(bt.$$.fragment,t),b(yt.$$.fragment,t),b(wt.$$.fragment,t),b(Ee.$$.fragment,t),b(Ce.$$.fragment,t),b(Tt.$$.fragment,t),b(Lt.$$.fragment,t),b(Et.$$.fragment,t),b(Fe.$$.fragment,t),Sn=!0)},o(t){y(u.$$.fragment,t),y(je.$$.fragment,t),y(Be.$$.fragment,t),y(De.$$.fragment,t),y(Xe.$$.fragment,t),y(He.$$.fragment,t),y(ue.$$.fragment,t),y(Qe.$$.fragment,t),y(Ke.$$.fragment,t),y(et.$$.fragment,t),y(tt.$$.fragment,t),y(nt.$$.fragment,t),y(ve.$$.fragment,t),y(at.$$.fragment,t),y(st.$$.fragment,t),y(rt.$$.fragment,t),y(ye.$$.fragment,t),y(dt.$$.fragment,t),y(ct.$$.fragment,t),y(mt.$$.fragment,t),y(ht.$$.fragment,t),y(pt.$$.fragment,t),y(ft.$$.fragment,t),y(ut.$$.fragment,t),y(kt.$$.fragment,t),y(Me.$$.fragment,t),y(bt.$$.fragment,t),y(yt.$$.fragment,t),y(wt.$$.fragment,t),y(Ee.$$.fragment,t),y(Ce.$$.fragment,t),y(Tt.$$.fragment,t),y(Lt.$$.fragment,t),y(Et.$$.fragment,t),y(Fe.$$.fragment,t),Sn=!1},d(t){o(h),t&&o(L),t&&o(f),w(u),t&&o(hn),t&&o(H),w(je),t&&o(pn),t&&o(me),t&&o(fn),t&&o(Ft),t&&o(un),t&&o(At),t&&o(gn),t&&o(qt),t&&o(_n),t&&o(he),t&&o(vn),w(Be,t),t&&o(kn),t&&o(It),t&&o(bn),w(De,t),t&&o(yn),t&&o(jt),t&&o(wn),t&&o(Nt),t&&o(Tn),t&&o(P),t&&o(Ln),t&&o(St),t&&o($n),t&&o(Ut),t&&o(Mn),t&&o(Y),w(Xe),t&&o(zn),t&&o(j),w(He),w(ue),t&&o(En),t&&o(K),w(Qe),t&&o(Cn),t&&o(x),w(Ke),w(et),w(tt),w(nt),w(ve),w(at),t&&o(xn),t&&o(ee),w(st),t&&o(Fn),t&&o(M),w(rt),w(ye),w(dt),w(ct),w(mt),w(ht),w(pt),t&&o(An),t&&o(ne),w(ft),t&&o(qn),t&&o(A),w(ut),w(kt),w(Me),t&&o(Pn),t&&o(se),w(bt),t&&o(In),t&&o(re),w(yt),w(wt),w(Ee),w(Ce),t&&o(jn),t&&o(le),w(Tt),t&&o(Nn),t&&o(E),w(Lt),w(Et),w(Fe)}}}const vd={local:"llama",sections:[{local:"overview",title:"Overview"},{local:"transformers.LlamaConfig",title:"LlamaConfig"},{local:"transformers.LlamaTokenizer",title:"LlamaTokenizer"},{local:"transformers.LlamaTokenizerFast",title:"LlamaTokenizerFast"},{local:"transformers.LlamaModel",title:"LlamaModel"},{local:"transformers.LlamaForCausalLM",title:"LlamaForCausalLM"},{local:"transformers.LlamaForSequenceClassification",title:"LlamaForSequenceClassification"}],title:"LLaMA"};function kd(F){return dd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Md extends sd{constructor(h){super();rd(this,h,kd,_d,id,{})}}export{Md as default,vd as metadata};
