import{S as sd,i as rd,s as id,e as n,k as d,w as g,t as r,M as ld,c as a,d as o,m as c,a as s,x as k,h as i,b as l,G as e,g as p,y as b,q as v,o as y,B as w,v as dd,L as la}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ci}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}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(){g(h.$$.fragment)},l(f){k(h.$$.fragment,f)},m(f,_){b(h,f,_),L=!0},p:la,i(f){L||(v(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,_,$;return _=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),k(_.$$.fragment,u)},m(u,T){p(u,h,T),e(h,L),p(u,f,T),b(_,u,T),$=!0},p:la,i(u){$||(v(_.$$.fragment,u),$=!0)},o(u){y(_.$$.fragment,u),$=!1},d(u){u&&o(h),u&&o(f),w(_,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 = LlamaTokenizerFast.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(){g(h.$$.fragment)},l(f){k(h.$$.fragment,f)},m(f,_){b(h,f,_),L=!0},p:la,i(f){L||(v(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,_,$;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"),_=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);_=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,_),e(h,$)},d(u){u&&o(h)}}}function fd(F){let h,L,f,_,$;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"),_=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);_=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,_),e(h,$)},d(u){u&&o(h)}}}function ud(F){let h,L,f,_,$;return _=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),k(_.$$.fragment,u)},m(u,T){p(u,h,T),e(h,L),p(u,f,T),b(_,u,T),$=!0},p:la,i(u){$||(v(_.$$.fragment,u),$=!0)},o(u){y(_.$$.fragment,u),$=!1},d(u){u&&o(h),u&&o(f),w(_,u)}}}function _d(F){let h,L,f,_,$;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"),_=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);_=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,_),e(h,$)},d(u){u&&o(h)}}}function gd(F){let h,L,f,_,$,u,T,q,da,hn,H,ce,fo,je,ca,uo,ma,pn,me,ha,Be,pa,fa,fn,Ft,ua,un,At,_o,_a,_n,qt,ga,gn,he,Pt,ka,Ne,ba,va,Se,ya,Ue,wa,Ta,kn,De,bn,It,go,La,vn,We,yn,jt,$a,wn,Bt,Je,Ma,Oe,za,Ea,Tn,P,xa,Ge,Ca,Fa,Re,Aa,qa,Ve,Pa,Ia,Ze,ja,Ba,Ln,Nt,Na,$n,St,pe,ko,Sa,Ua,Ut,Da,Wa,Mn,Y,fe,bo,Xe,Ja,vo,Oa,zn,j,He,Ga,Ye,Ra,Dt,Va,Za,Xa,Q,Ha,Wt,Ya,Qa,Jt,Ka,es,ts,ue,En,K,_e,yo,Qe,os,wo,ns,xn,C,Ke,as,To,ss,rs,Ot,et,is,ge,tt,ls,ot,ds,Lo,cs,ms,hs,S,nt,ps,$o,fs,us,ke,_s,Mo,gs,ks,be,at,bs,zo,vs,Cn,ee,ve,Eo,st,ys,xo,ws,Fn,M,rt,Ts,Co,Ls,$s,Fo,Ms,zs,ye,Es,B,xs,Ao,Cs,Fs,qo,As,qs,Po,Ps,Is,it,js,Bs,Ns,lt,Ss,Gt,Us,Ds,Ws,W,dt,Js,Io,Os,Gs,jo,Rs,Vs,we,ct,Zs,te,Xs,Bo,Hs,Ys,No,Qs,Ks,er,J,mt,tr,Rt,or,Vt,nr,ar,So,sr,rr,Te,ht,ir,oe,lr,Uo,dr,cr,Do,mr,hr,pr,Zt,pt,An,ne,Le,Wo,ft,fr,Jo,ur,qn,A,ut,_r,_t,gr,Xt,kr,br,vr,gt,yr,kt,wr,Tr,Lr,$e,$r,Oo,Mr,zr,Go,Er,xr,O,bt,Cr,ae,Fr,Ht,Ar,qr,Ro,Pr,Ir,jr,Me,Pn,se,ze,Vo,vt,Br,Zo,Nr,In,re,yt,Sr,U,wt,Ur,ie,Dr,Yt,Wr,Jr,Xo,Or,Gr,Rr,Ee,Vr,xe,jn,le,Ce,Ho,Tt,Zr,Yo,Xr,Bn,E,Lt,Hr,Qo,Yr,Qr,Qt,Kt,Kr,ei,ti,N,oi,Ko,ni,ai,en,si,ri,tn,ii,li,on,di,ci,mi,$t,hi,eo,pi,fi,ui,Mt,_i,zt,gi,ki,bi,G,Et,vi,de,yi,to,wi,Ti,nn,Li,$i,Mi,Fe,Nn;return u=new Ie({}),je=new Ie({}),De=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`}}),We=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 x({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:" = None"},{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_theta",val:" = 10000.0"},{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/main/en/model_doc/llama2#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. Llama 1 supports up to 2048 tokens,
Llama 2 up to 4096, CodeLlama up to 16384.`,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_theta",description:`<strong>rope_theta</strong> (<code>float</code>, <em>optional</em>, defaults to 10000.0) &#x2014;
The base period of the RoPE embeddings.`,name:"rope_theta"},{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 two 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/main/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 x({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:"use_default_system_prompt",val:" = True"},{name:"spaces_between_special_tokens",val:" = False"},{name:"legacy",val:" = None"},{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>) &#x2014;
Whether or not the <code>legacy</code> behavior of the tokenizer should be used. Legacy is before the merge of #24622
and #25224 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/main/src/transformers/models/llama/tokenization_llama.py#L67"}}),et=new x({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/main/src/transformers/models/llama/tokenization_llama.py#L297"}}),tt=new x({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/main/src/transformers/models/llama/tokenization_llama.py#L308",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 x({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/main/src/transformers/models/llama/tokenization_llama.py#L345",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>
`}}),ke=new ia({props:{anchor:"transformers.LlamaTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[md]},$$scope:{ctx:F}}}),at=new x({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/main/src/transformers/models/llama/tokenization_llama.py#L270",returnDescription:`
<p>Paths to the files saved.</p>
`,returnType:`
<p><code>Tuple(str)</code></p>
`}}),st=new Ie({}),rt=new x({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:"use_default_system_prompt",val:" = True"},{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/main/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 x({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/main/src/transformers/tokenization_utils_base.py#L3121",returnDescription:`
<p>The model input with special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ct=new x({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/main/src/transformers/tokenization_utils_base.py#L3566",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 x({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/main/src/transformers/tokenization_utils_base.py#L3101",returnDescription:`
<p>The token type ids.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ht=new x({props:{name:"update_post_processor",anchor:"transformers.LlamaTokenizerFast.update_post_processor",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/tokenization_llama_fast.py#L133"}}),pt=new x({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/main/src/transformers/models/llama/tokenization_llama_fast.py#L173"}}),ft=new Ie({}),ut=new x({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/main/en/model_doc/llama2#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/main/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/main/src/transformers/models/llama/modeling_llama.py#L563"}}),bt=new x({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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py#L614"}}),Me=new Ci({props:{$$slots:{default:[pd]},$$scope:{ctx:F}}}),vt=new Ie({}),yt=new x({props:{name:"class transformers.LlamaForCausalLM",anchor:"transformers.LlamaForCausalLM",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py#L742"}}),wt=new x({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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/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/main/src/transformers/models/llama/modeling_llama.py#L772",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/llama2#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/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast"
>transformers.modeling_outputs.CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ee=new Ci({props:{$$slots:{default:[fd]},$$scope:{ctx:F}}}),xe=new ia({props:{anchor:"transformers.LlamaForCausalLM.forward.example",$$slots:{default:[ud]},$$scope:{ctx:F}}}),Tt=new Ie({}),Lt=new x({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/main/en/model_doc/llama2#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/main/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/main/src/transformers/models/llama/modeling_llama.py#L921"}}),Et=new x({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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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/main/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/main/src/transformers/models/llama/modeling_llama.py#L937"}}),Fe=new Ci({props:{$$slots:{default:[_d]},$$scope:{ctx:F}}}),{c(){h=n("meta"),L=d(),f=n("h1"),_=n("a"),$=n("span"),g(u.$$.fragment),T=d(),q=n("span"),da=r("LLaMA"),hn=d(),H=n("h2"),ce=n("a"),fo=n("span"),g(je.$$.fragment),ca=d(),uo=n("span"),ma=r("Overview"),pn=d(),me=n("p"),ha=r("The LLaMA model was proposed in "),Be=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"),_o=n("em"),_a=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."),_n=d(),qt=n("p"),ga=r("Tips:"),gn=d(),he=n("ul"),Pt=n("li"),ka=r("Weights for the LLaMA models can be obtained from by filling out "),Ne=n("a"),ba=r("this form"),va=d(),Se=n("li"),ya=r("After downloading the weights, they will need to be converted to the Hugging Face Transformers format using the "),Ue=n("a"),wa=r("conversion script"),Ta=r(". The script can be called with the following (example) command:"),kn=d(),g(De.$$.fragment),bn=d(),It=n("ul"),go=n("li"),La=r("After conversion, the model and tokenizer can be loaded via:"),vn=d(),g(We.$$.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(),Bt=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"),xa=r("This model was contributed by "),Ge=n("a"),Ca=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"),Ba=r("."),Ln=d(),Nt=n("p"),Na=r("Based on the original LLaMA model, Meta AI has released some follow-up works:"),$n=d(),St=n("ul"),pe=n("li"),ko=n("strong"),Sa=r("Llama2"),Ua=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 "),Ut=n("a"),Da=r("here"),Wa=r("."),Mn=d(),Y=n("h2"),fe=n("a"),bo=n("span"),g(Xe.$$.fragment),Ja=d(),vo=n("span"),Oa=r("LlamaConfig"),zn=d(),j=n("div"),g(He.$$.fragment),Ga=d(),Ye=n("p"),Ra=r("This is the configuration class to store the configuration of a "),Dt=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 "),Wt=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(),g(ue.$$.fragment),En=d(),K=n("h2"),_e=n("a"),yo=n("span"),g(Qe.$$.fragment),os=d(),wo=n("span"),ns=r("LlamaTokenizer"),xn=d(),C=n("div"),g(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"),g(et.$$.fragment),is=d(),ge=n("div"),g(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(),S=n("div"),g(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(),g(ke.$$.fragment),_s=d(),Mo=n("p"),gs=r("if token_ids_1 is None, only returns the first portion of the mask (0s)."),ks=d(),be=n("div"),g(at.$$.fragment),bs=d(),zo=n("p"),vs=r("Save the vocabulary and special tokens file to a directory."),Cn=d(),ee=n("h2"),ve=n("a"),Eo=n("span"),g(st.$$.fragment),ys=d(),xo=n("span"),ws=r("LlamaTokenizerFast"),Fn=d(),M=n("div"),g(rt.$$.fragment),Ts=d(),Co=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(),g(ye.$$.fragment),Es=d(),B=n("p"),xs=r("If you want to change the "),Ao=n("code"),Cs=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"),Bs=r(") documentation."),Ns=d(),lt=n("p"),Ss=r("This tokenizer inherits from "),Gt=n("a"),Us=r("PreTrainedTokenizerFast"),Ds=r(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Ws=d(),W=n("div"),g(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"),g(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 `),Bo=n("code"),Hs=r("prepare_for_model"),Ys=r(" or "),No=n("code"),Qs=r("encode_plus"),Ks=r(" methods."),er=d(),J=n("div"),g(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(),So=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"),g(ht.$$.fragment),ir=d(),oe=n("p"),lr=r("Updates the underlying post processor with the current "),Uo=n("code"),dr=r("bos_token"),cr=r(" and "),Do=n("code"),mr=r("eos_token"),hr=r("."),pr=d(),Zt=n("div"),g(pt.$$.fragment),An=d(),ne=n("h2"),Le=n("a"),Wo=n("span"),g(ft.$$.fragment),fr=d(),Jo=n("span"),ur=r("LlamaModel"),qn=d(),A=n("div"),g(ut.$$.fragment),_r=d(),_t=n("p"),gr=r(`The bare LLaMA Model outputting raw hidden-states without any specific head on top.
This model inherits from `),Xt=n("a"),kr=r("PreTrainedModel"),br=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.)`),vr=d(),gt=n("p"),yr=r("This model is also a PyTorch "),kt=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"),xr=d(),O=n("div"),g(bt.$$.fragment),Cr=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(),g(Me.$$.fragment),Pn=d(),se=n("h2"),ze=n("a"),Vo=n("span"),g(vt.$$.fragment),Br=d(),Zo=n("span"),Nr=r("LlamaForCausalLM"),In=d(),re=n("div"),g(yt.$$.fragment),Sr=d(),U=n("div"),g(wt.$$.fragment),Ur=d(),ie=n("p"),Dr=r("The "),Yt=n("a"),Wr=r("LlamaForCausalLM"),Jr=r(" forward method, overrides the "),Xo=n("code"),Or=r("__call__"),Gr=r(" special method."),Rr=d(),g(Ee.$$.fragment),Vr=d(),g(xe.$$.fragment),jn=d(),le=n("h2"),Ce=n("a"),Ho=n("span"),g(Tt.$$.fragment),Zr=d(),Yo=n("span"),Xr=r("LlamaForSequenceClassification"),Bn=d(),E=n("div"),g(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(),N=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"),_i=r("This model is also a PyTorch "),zt=n("a"),gi=r("torch.nn.Module"),ki=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bi=d(),G=n("div"),g(Et.$$.fragment),vi=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(),g(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 xt=s(f);_=a(xt,"A",{id:!0,class:!0,href:!0});var an=s(_);$=a(an,"SPAN",{});var sn=s($);k(u.$$.fragment,sn),sn.forEach(o),an.forEach(o),T=c(xt),q=a(xt,"SPAN",{});var rn=s(q);da=i(rn,"LLaMA"),rn.forEach(o),xt.forEach(o),hn=c(t),H=a(t,"H2",{class:!0});var Ct=s(H);ce=a(Ct,"A",{id:!0,class:!0,href:!0});var ln=s(ce);fo=a(ln,"SPAN",{});var dn=s(fo);k(je.$$.fragment,dn),dn.forEach(o),ln.forEach(o),ca=c(Ct),uo=a(Ct,"SPAN",{});var Fi=s(uo);ma=i(Fi,"Overview"),Fi.forEach(o),Ct.forEach(o),pn=c(t),me=a(t,"P",{});var Sn=s(me);ha=i(Sn,"The LLaMA model was proposed in "),Be=a(Sn,"A",{href:!0,rel:!0});var Ai=s(Be);pa=i(Ai,"LLaMA: Open and Efficient Foundation Language Models"),Ai.forEach(o),fa=i(Sn," 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."),Sn.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);_o=a(Pi,"EM",{});var Ii=s(_o);_a=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),_n=c(t),qt=a(t,"P",{});var ji=s(qt);ga=i(ji,"Tips:"),ji.forEach(o),gn=c(t),he=a(t,"UL",{});var Un=s(he);Pt=a(Un,"LI",{});var zi=s(Pt);ka=i(zi,"Weights for the LLaMA models can be obtained from by filling out "),Ne=a(zi,"A",{href:!0,rel:!0});var Bi=s(Ne);ba=i(Bi,"this form"),Bi.forEach(o),zi.forEach(o),va=c(Un),Se=a(Un,"LI",{});var Dn=s(Se);ya=i(Dn,"After downloading the weights, they will need to be converted to the Hugging Face Transformers format using the "),Ue=a(Dn,"A",{href:!0,rel:!0});var Ni=s(Ue);wa=i(Ni,"conversion script"),Ni.forEach(o),Ta=i(Dn,". The script can be called with the following (example) command:"),Dn.forEach(o),Un.forEach(o),kn=c(t),k(De.$$.fragment,t),bn=c(t),It=a(t,"UL",{});var Si=s(It);go=a(Si,"LI",{});var Ui=s(go);La=i(Ui,"After conversion, the model and tokenizer can be loaded via:"),Ui.forEach(o),Si.forEach(o),vn=c(t),k(We.$$.fragment,t),yn=c(t),jt=a(t,"P",{});var Di=s(jt);$a=i(Di,`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.`),Di.forEach(o),wn=c(t),Bt=a(t,"UL",{});var Wi=s(Bt);Je=a(Wi,"LI",{});var Wn=s(Je);Ma=i(Wn,"The LLaMA tokenizer is a BPE model based on "),Oe=a(Wn,"A",{href:!0,rel:!0});var Ji=s(Oe);za=i(Ji,"sentencepiece"),Ji.forEach(o),Ea=i(Wn,". 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."),Wn.forEach(o),Wi.forEach(o),Tn=c(t),P=a(t,"P",{});var R=s(P);xa=i(R,"This model was contributed by "),Ge=a(R,"A",{href:!0,rel:!0});var Oi=s(Ge);Ca=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),Ba=i(R,"."),R.forEach(o),Ln=c(t),Nt=a(t,"P",{});var Zi=s(Nt);Na=i(Zi,"Based on the original LLaMA model, Meta AI has released some follow-up works:"),Zi.forEach(o),$n=c(t),St=a(t,"UL",{});var Xi=s(St);pe=a(Xi,"LI",{});var cn=s(pe);ko=a(cn,"STRONG",{});var Hi=s(ko);Sa=i(Hi,"Llama2"),Hi.forEach(o),Ua=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 "),Ut=a(cn,"A",{href:!0});var Yi=s(Ut);Da=i(Yi,"here"),Yi.forEach(o),Wa=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);bo=a(Qi,"SPAN",{});var Ki=s(bo);k(Xe.$$.fragment,Ki),Ki.forEach(o),Qi.forEach(o),Ja=c(Jn),vo=a(Jn,"SPAN",{});var el=s(vo);Oa=i(el,"LlamaConfig"),el.forEach(o),Jn.forEach(o),zn=c(t),j=a(t,"DIV",{class:!0});var Ae=s(j);k(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 "),Dt=a(On,"A",{href:!0});var tl=s(Dt);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 "),Wt=a(oo,"A",{href:!0});var ol=s(Wt);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),k(ue.$$.fragment,Ae),Ae.forEach(o),En=c(t),K=a(t,"H2",{class:!0});var Gn=s(K);_e=a(Gn,"A",{id:!0,class:!0,href:!0});var al=s(_e);yo=a(al,"SPAN",{});var sl=s(yo);k(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),xn=c(t),C=a(t,"DIV",{class:!0});var D=s(C);k(Ke.$$.fragment,D),as=c(D),To=a(D,"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(D),Ot=a(D,"DIV",{class:!0});var ll=s(Ot);k(et.$$.fragment,ll),ll.forEach(o),is=c(D),ge=a(D,"DIV",{class:!0});var Rn=s(ge);k(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(D),S=a(D,"DIV",{class:!0});var qe=s(S);k(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),k(ke.$$.fragment,qe),_s=c(qe),Mo=a(qe,"P",{});var ml=s(Mo);gs=i(ml,"if token_ids_1 is None, only returns the first portion of the mask (0s)."),ml.forEach(o),qe.forEach(o),ks=c(D),be=a(D,"DIV",{class:!0});var Zn=s(be);k(at.$$.fragment,Zn),bs=c(Zn),zo=a(Zn,"P",{});var hl=s(zo);vs=i(hl,"Save the vocabulary and special tokens file to a directory."),hl.forEach(o),Zn.forEach(o),D.forEach(o),Cn=c(t),ee=a(t,"H2",{class:!0});var Xn=s(ee);ve=a(Xn,"A",{id:!0,class:!0,href:!0});var pl=s(ve);Eo=a(pl,"SPAN",{});var fl=s(Eo);k(st.$$.fragment,fl),fl.forEach(o),pl.forEach(o),ys=c(Xn),xo=a(Xn,"SPAN",{});var ul=s(xo);ws=i(ul,"LlamaTokenizerFast"),ul.forEach(o),Xn.forEach(o),Fn=c(t),M=a(t,"DIV",{class:!0});var z=s(M);k(rt.$$.fragment,z),Ts=c(z),Co=a(z,"P",{});var _l=s(Co);Ls=i(_l,"Construct a Llama tokenizer. Based on byte-level Byte-Pair-Encoding."),_l.forEach(o),$s=c(z),Fo=a(z,"P",{});var gl=s(Fo);Ms=i(gl,"This uses notably ByteFallback and no normalization."),gl.forEach(o),zs=c(z),k(ye.$$.fragment,z),Es=c(z),B=a(z,"P",{});var V=s(B);xs=i(V,"If you want to change the "),Ao=a(V,"CODE",{});var kl=s(Ao);Cs=i(kl,"bos_token"),kl.forEach(o),Fs=i(V," or the "),qo=a(V,"CODE",{});var bl=s(qo);As=i(bl,"eos_token"),bl.forEach(o),qs=i(V,`, make sure to specify them when initializing the model, or
call `),Po=a(V,"CODE",{});var vl=s(Po);Ps=i(vl,"tokenizer.update_post_processor()"),vl.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),Bs=i(V,") documentation."),V.forEach(o),Ns=c(z),lt=a(z,"P",{});var Hn=s(lt);Ss=i(Hn,"This tokenizer inherits from "),Gt=a(Hn,"A",{href:!0});var wl=s(Gt);Us=i(wl,"PreTrainedTokenizerFast"),wl.forEach(o),Ds=i(Hn,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Hn.forEach(o),Ws=c(z),W=a(z,"DIV",{class:!0});var no=s(W);k(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);k(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 `),Bo=a(ao,"CODE",{});var $l=s(Bo);Hs=i($l,"prepare_for_model"),$l.forEach(o),Ys=i(ao," or "),No=a(ao,"CODE",{});var Ml=s(No);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);k(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),So=a(so,"P",{});var El=s(So);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);k(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 "),Uo=a(ro,"CODE",{});var xl=s(Uo);dr=i(xl,"bos_token"),xl.forEach(o),cr=i(ro," and "),Do=a(ro,"CODE",{});var Cl=s(Do);mr=i(Cl,"eos_token"),Cl.forEach(o),hr=i(ro,"."),ro.forEach(o),Qn.forEach(o),pr=c(z),Zt=a(z,"DIV",{class:!0});var Fl=s(Zt);k(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);Wo=a(Al,"SPAN",{});var ql=s(Wo);k(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);k(ut.$$.fragment,Z),_r=c(Z),_t=a(Z,"P",{});var ea=s(_t);gr=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);kr=i(Il,"PreTrainedModel"),Il.forEach(o),br=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),vr=c(Z),gt=a(Z,"P",{});var ta=s(gt);yr=i(ta,"This model is also a PyTorch "),kt=a(ta,"A",{href:!0,rel:!0});var jl=s(kt);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 Bl=s(Oo);Mr=i(Bl,"config.num_hidden_layers"),Bl.forEach(o),zr=i(mn," layers. Each layer is a "),Go=a(mn,"CODE",{});var Nl=s(Go);Er=i(Nl,"LlamaDecoderLayer"),Nl.forEach(o),mn.forEach(o),xr=c(Z),O=a(Z,"DIV",{class:!0});var io=s(O);k(bt.$$.fragment,io),Cr=c(io),ae=a(io,"P",{});var lo=s(ae);Fr=i(lo,"The "),Ht=a(lo,"A",{href:!0});var Sl=s(Ht);Ar=i(Sl,"LlamaModel"),Sl.forEach(o),qr=i(lo," forward method, overrides the "),Ro=a(lo,"CODE",{});var Ul=s(Ro);Pr=i(Ul,"__call__"),Ul.forEach(o),Ir=i(lo," special method."),lo.forEach(o),jr=c(io),k(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 Dl=s(ze);Vo=a(Dl,"SPAN",{});var Wl=s(Vo);k(vt.$$.fragment,Wl),Wl.forEach(o),Dl.forEach(o),Br=c(oa),Zo=a(oa,"SPAN",{});var Jl=s(Zo);Nr=i(Jl,"LlamaForCausalLM"),Jl.forEach(o),oa.forEach(o),In=c(t),re=a(t,"DIV",{class:!0});var na=s(re);k(yt.$$.fragment,na),Sr=c(na),U=a(na,"DIV",{class:!0});var Pe=s(U);k(wt.$$.fragment,Pe),Ur=c(Pe),ie=a(Pe,"P",{});var co=s(ie);Dr=i(co,"The "),Yt=a(co,"A",{href:!0});var Ol=s(Yt);Wr=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),k(Ee.$$.fragment,Pe),Vr=c(Pe),k(xe.$$.fragment,Pe),Pe.forEach(o),na.forEach(o),jn=c(t),le=a(t,"H2",{class:!0});var aa=s(le);Ce=a(aa,"A",{id:!0,class:!0,href:!0});var Rl=s(Ce);Ho=a(Rl,"SPAN",{});var Vl=s(Ho);k(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),Bn=c(t),E=a(t,"DIV",{class:!0});var I=s(E);k(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 xi=s(Qt);Kt=a(xi,"A",{href:!0});var Hl=s(Kt);Kr=i(Hl,"LlamaForSequenceClassification"),Hl.forEach(o),ei=i(xi,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-2) do.`),xi.forEach(o),ti=c(I),N=a(I,"P",{});var X=s(N);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);_i=i(ra,"This model is also a PyTorch "),zt=a(ra,"A",{href:!0,rel:!0});var od=s(zt);gi=i(od,"torch.nn.Module"),od.forEach(o),ki=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),bi=c(I),G=a(I,"DIV",{class:!0});var mo=s(G);k(Et.$$.fragment,mo),vi=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),k(Fe.$$.fragment,mo),mo.forEach(o),I.forEach(o),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(kd)),l(_,"id","llama"),l(_,"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(_,"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(Be,"href","https://arxiv.org/abs/2302.13971"),l(Be,"rel","nofollow"),l(Ne,"href","https://docs.google.com/forms/d/e/1FAIpQLSfqNECQnMkycAp2jP4Z9TFX0cGR4uf7b_fBxjY_OjhJILlKGA/viewform?usp=send_form"),l(Ne,"rel","nofollow"),l(Ue,"href","https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py"),l(Ue,"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(Ut,"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(Dt,"href","/docs/transformers/main/en/model_doc/llama2#transformers.LlamaModel"),l(Wt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),l(Jt,"href","/docs/transformers/main/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(_e,"id","transformers.LlamaTokenizer"),l(_e,"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(_e,"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(ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ve,"id","transformers.LlamaTokenizerFast"),l(ve,"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(ve,"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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),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(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/main/en/main_classes/model#transformers.PreTrainedModel"),l(kt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(kt,"rel","nofollow"),l(Ht,"href","/docs/transformers/main/en/model_doc/llama2#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/main/en/model_doc/llama2#transformers.LlamaForCausalLM"),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(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(Ce,"id","transformers.LlamaForSequenceClassification"),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","#transformers.LlamaForSequenceClassification"),l(le,"class","relative group"),l(Kt,"href","/docs/transformers/main/en/model_doc/llama2#transformers.LlamaForSequenceClassification"),l(eo,"href","/docs/transformers/main/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/main/en/model_doc/llama2#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,_),e(_,$),b(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),b(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,Be),e(Be,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,_o),e(_o,_a),p(t,_n,m),p(t,qt,m),e(qt,ga),p(t,gn,m),p(t,he,m),e(he,Pt),e(Pt,ka),e(Pt,Ne),e(Ne,ba),e(he,va),e(he,Se),e(Se,ya),e(Se,Ue),e(Ue,wa),e(Se,Ta),p(t,kn,m),b(De,t,m),p(t,bn,m),p(t,It,m),e(It,go),e(go,La),p(t,vn,m),b(We,t,m),p(t,yn,m),p(t,jt,m),e(jt,$a),p(t,wn,m),p(t,Bt,m),e(Bt,Je),e(Je,Ma),e(Je,Oe),e(Oe,za),e(Je,Ea),p(t,Tn,m),p(t,P,m),e(P,xa),e(P,Ge),e(Ge,Ca),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,Ba),p(t,Ln,m),p(t,Nt,m),e(Nt,Na),p(t,$n,m),p(t,St,m),e(St,pe),e(pe,ko),e(ko,Sa),e(pe,Ua),e(pe,Ut),e(Ut,Da),e(pe,Wa),p(t,Mn,m),p(t,Y,m),e(Y,fe),e(fe,bo),b(Xe,bo,null),e(Y,Ja),e(Y,vo),e(vo,Oa),p(t,zn,m),p(t,j,m),b(He,j,null),e(j,Ga),e(j,Ye),e(Ye,Ra),e(Ye,Dt),e(Dt,Va),e(Ye,Za),e(j,Xa),e(j,Q),e(Q,Ha),e(Q,Wt),e(Wt,Ya),e(Q,Qa),e(Q,Jt),e(Jt,Ka),e(Q,es),e(j,ts),b(ue,j,null),p(t,En,m),p(t,K,m),e(K,_e),e(_e,yo),b(Qe,yo,null),e(K,os),e(K,wo),e(wo,ns),p(t,xn,m),p(t,C,m),b(Ke,C,null),e(C,as),e(C,To),e(To,ss),e(C,rs),e(C,Ot),b(et,Ot,null),e(C,is),e(C,ge),b(tt,ge,null),e(ge,ls),e(ge,ot),e(ot,ds),e(ot,Lo),e(Lo,cs),e(ot,ms),e(C,hs),e(C,S),b(nt,S,null),e(S,ps),e(S,$o),e($o,fs),e(S,us),b(ke,S,null),e(S,_s),e(S,Mo),e(Mo,gs),e(C,ks),e(C,be),b(at,be,null),e(be,bs),e(be,zo),e(zo,vs),p(t,Cn,m),p(t,ee,m),e(ee,ve),e(ve,Eo),b(st,Eo,null),e(ee,ys),e(ee,xo),e(xo,ws),p(t,Fn,m),p(t,M,m),b(rt,M,null),e(M,Ts),e(M,Co),e(Co,Ls),e(M,$s),e(M,Fo),e(Fo,Ms),e(M,zs),b(ye,M,null),e(M,Es),e(M,B),e(B,xs),e(B,Ao),e(Ao,Cs),e(B,Fs),e(B,qo),e(qo,As),e(B,qs),e(B,Po),e(Po,Ps),e(B,Is),e(B,it),e(it,js),e(B,Bs),e(M,Ns),e(M,lt),e(lt,Ss),e(lt,Gt),e(Gt,Us),e(lt,Ds),e(M,Ws),e(M,W),b(dt,W,null),e(W,Js),e(W,Io),e(Io,Os),e(W,Gs),e(W,jo),e(jo,Rs),e(M,Vs),e(M,we),b(ct,we,null),e(we,Zs),e(we,te),e(te,Xs),e(te,Bo),e(Bo,Hs),e(te,Ys),e(te,No),e(No,Qs),e(te,Ks),e(M,er),e(M,J),b(mt,J,null),e(J,tr),e(J,Rt),e(Rt,or),e(Rt,Vt),e(Vt,nr),e(J,ar),e(J,So),e(So,sr),e(M,rr),e(M,Te),b(ht,Te,null),e(Te,ir),e(Te,oe),e(oe,lr),e(oe,Uo),e(Uo,dr),e(oe,cr),e(oe,Do),e(Do,mr),e(oe,hr),e(M,pr),e(M,Zt),b(pt,Zt,null),p(t,An,m),p(t,ne,m),e(ne,Le),e(Le,Wo),b(ft,Wo,null),e(ne,fr),e(ne,Jo),e(Jo,ur),p(t,qn,m),p(t,A,m),b(ut,A,null),e(A,_r),e(A,_t),e(_t,gr),e(_t,Xt),e(Xt,kr),e(_t,br),e(A,vr),e(A,gt),e(gt,yr),e(gt,kt),e(kt,wr),e(gt,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,xr),e(A,O),b(bt,O,null),e(O,Cr),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),b(Me,O,null),p(t,Pn,m),p(t,se,m),e(se,ze),e(ze,Vo),b(vt,Vo,null),e(se,Br),e(se,Zo),e(Zo,Nr),p(t,In,m),p(t,re,m),b(yt,re,null),e(re,Sr),e(re,U),b(wt,U,null),e(U,Ur),e(U,ie),e(ie,Dr),e(ie,Yt),e(Yt,Wr),e(ie,Jr),e(ie,Xo),e(Xo,Or),e(ie,Gr),e(U,Rr),b(Ee,U,null),e(U,Vr),b(xe,U,null),p(t,jn,m),p(t,le,m),e(le,Ce),e(Ce,Ho),b(Tt,Ho,null),e(le,Zr),e(le,Yo),e(Yo,Xr),p(t,Bn,m),p(t,E,m),b(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,N),e(N,oi),e(N,Ko),e(Ko,ni),e(N,ai),e(N,en),e(en,si),e(N,ri),e(N,tn),e(tn,ii),e(N,li),e(N,on),e(on,di),e(N,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,_i),e(Mt,zt),e(zt,gi),e(Mt,ki),e(E,bi),e(E,G),b(Et,G,null),e(G,vi),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),b(Fe,G,null),Nn=!0},p(t,[m]){const xt={};m&2&&(xt.$$scope={dirty:m,ctx:t}),ue.$set(xt);const an={};m&2&&(an.$$scope={dirty:m,ctx:t}),ke.$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 Ct={};m&2&&(Ct.$$scope={dirty:m,ctx:t}),Ee.$set(Ct);const ln={};m&2&&(ln.$$scope={dirty:m,ctx:t}),xe.$set(ln);const dn={};m&2&&(dn.$$scope={dirty:m,ctx:t}),Fe.$set(dn)},i(t){Nn||(v(u.$$.fragment,t),v(je.$$.fragment,t),v(De.$$.fragment,t),v(We.$$.fragment,t),v(Xe.$$.fragment,t),v(He.$$.fragment,t),v(ue.$$.fragment,t),v(Qe.$$.fragment,t),v(Ke.$$.fragment,t),v(et.$$.fragment,t),v(tt.$$.fragment,t),v(nt.$$.fragment,t),v(ke.$$.fragment,t),v(at.$$.fragment,t),v(st.$$.fragment,t),v(rt.$$.fragment,t),v(ye.$$.fragment,t),v(dt.$$.fragment,t),v(ct.$$.fragment,t),v(mt.$$.fragment,t),v(ht.$$.fragment,t),v(pt.$$.fragment,t),v(ft.$$.fragment,t),v(ut.$$.fragment,t),v(bt.$$.fragment,t),v(Me.$$.fragment,t),v(vt.$$.fragment,t),v(yt.$$.fragment,t),v(wt.$$.fragment,t),v(Ee.$$.fragment,t),v(xe.$$.fragment,t),v(Tt.$$.fragment,t),v(Lt.$$.fragment,t),v(Et.$$.fragment,t),v(Fe.$$.fragment,t),Nn=!0)},o(t){y(u.$$.fragment,t),y(je.$$.fragment,t),y(De.$$.fragment,t),y(We.$$.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(ke.$$.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(bt.$$.fragment,t),y(Me.$$.fragment,t),y(vt.$$.fragment,t),y(yt.$$.fragment,t),y(wt.$$.fragment,t),y(Ee.$$.fragment,t),y(xe.$$.fragment,t),y(Tt.$$.fragment,t),y(Lt.$$.fragment,t),y(Et.$$.fragment,t),y(Fe.$$.fragment,t),Nn=!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(_n),t&&o(qt),t&&o(gn),t&&o(he),t&&o(kn),w(De,t),t&&o(bn),t&&o(It),t&&o(vn),w(We,t),t&&o(yn),t&&o(jt),t&&o(wn),t&&o(Bt),t&&o(Tn),t&&o(P),t&&o(Ln),t&&o(Nt),t&&o($n),t&&o(St),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(xn),t&&o(C),w(Ke),w(et),w(tt),w(nt),w(ke),w(at),t&&o(Cn),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(bt),w(Me),t&&o(Pn),t&&o(se),w(vt),t&&o(In),t&&o(re),w(yt),w(wt),w(Ee),w(xe),t&&o(jn),t&&o(le),w(Tt),t&&o(Bn),t&&o(E),w(Lt),w(Et),w(Fe)}}}const kd={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 bd(F){return dd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Md extends sd{constructor(h){super();rd(this,h,bd,gd,id,{})}}export{Md as default,kd as metadata};
