import{S as jo,i as Uo,s as Jo,e as n,k as h,w as d,t as a,M as To,c as o,d as s,m as c,a as r,x as u,h as l,b as m,G as t,g as p,y as f,L as bo,q as y,o as g,B as w,v as Io}from"../chunks/vendor-hf-doc-builder.js";import{I as Ce}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as I}from"../chunks/CodeBlock-hf-doc-builder.js";function vo(sn){let A,zt,S,W,Le,oe,Ps,Oe,Xs,Bt,Q,V,Ke,ie,Ys,et,Hs,Wt,j,Ds,tt,Ls,Os,st,Ks,ea,at,ta,sa,Vt,xe,aa,Rt,_e,la,qt,R,na,lt,oa,ia,Ft,v,ra,nt,pa,ha,ot,ca,ma,Pt,q,da,it,ua,fa,Xt,re,Yt,U,ya,rt,ga,wa,pt,Ma,ja,pe,Ua,Ja,Ht,he,Dt,Ne,Ta,Lt,$,F,ht,ce,ba,ct,Ia,Ot,k,va,mt,ka,Ca,dt,xa,_a,Kt,me,es,C,Na,ut,Ea,Aa,ft,Sa,Qa,ts,de,ss,P,$a,ue,Za,Ga,as,fe,ls,Ee,za,ns,x,yt,Ba,Wa,gt,Va,Ra,wt,qa,os,Ae,Fa,is,ye,rs,Se,Pa,ps,Z,X,Mt,ge,Xa,jt,Ya,hs,Y,Ha,Ut,Da,La,cs,we,ms,M,Oa,Jt,Ka,el,Qe,tl,sl,Tt,al,ll,$e,nl,ol,ds,Me,us,J,il,Ze,rl,pl,Ge,hl,cl,ze,ml,dl,fs,G,H,bt,je,ul,It,fl,ys,T,yl,vt,gl,wl,kt,Ml,jl,Ct,Ul,Jl,gs,D,Tl,xt,bl,Il,ws,z,L,_t,Ue,vl,Nt,kl,Ms,Be,Cl,js,O,xl,Je,_l,Nl,Us,Te,Js,We,El,Ts,be,bs,_,Al,Et,Sl,Ql,At,$l,Zl,Is,Ie,vs,K,Gl,Ve,zl,Bl,ks,B,ee,St,ve,Wl,Qt,Vl,Cs,b,Rl,$t,ql,Fl,Re,Pl,Xl,ke,Yl,Hl,xs,N,Dl,Zt,Ll,Ol,Gt,Kl,en,_s,qe,tn,Ns;return oe=new Ce({}),ie=new Ce({}),re=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmJsZW5kZXJib3QtNDAwTS1kaXN0aWxsJTIyKSUwQSUwQWNoYXQlMjAlM0QlMjAlNUIlMEElMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJIZWxsbyUyQyUyMGhvdyUyMGFyZSUyMHlvdSUzRiUyMiU3RCUyQyUwQSUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJhc3Npc3RhbnQlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySSdtJTIwZG9pbmclMjBncmVhdC4lMjBIb3clMjBjYW4lMjBJJTIwaGVscCUyMHlvdSUyMHRvZGF5JTNGJTIyJTdEJTJDJTBBJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySSdkJTIwbGlrZSUyMHRvJTIwc2hvdyUyMG9mZiUyMGhvdyUyMGNoYXQlMjB0ZW1wbGF0aW5nJTIwd29ya3MhJTIyJTdEJTJDJTBBJTVEJTBBJTBBdG9rZW5pemVyLmFwcGx5X2NoYXRfdGVtcGxhdGUoY2hhdCUyQyUyMHRva2VuaXplJTNERmFsc2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/blenderbot-400M-distill&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>chat = [
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Hello, how are you?&quot;</span>},
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;I&#x27;m doing great. How can I help you today?&quot;</span>},
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;I&#x27;d like to show off how chat templating works!&quot;</span>},
<span class="hljs-meta">... </span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.apply_chat_template(chat, tokenize=<span class="hljs-literal">False</span>)
<span class="hljs-string">&quot; Hello, how are you?  I&#x27;m doing great. How can I help you today?   I&#x27;d like to show off how chat templating works!&lt;/s&gt;&quot;</span>`}}),he=new I({props:{code:"JTBBJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySGVsbG8lMkMlMjBob3clMjBhcmUlMjB5b3UlM0YlMjIlN0QlMkMlMEElMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyYXNzaXN0YW50JTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkknbSUyMGRvaW5nJTIwZ3JlYXQuJTIwSG93JTIwY2FuJTIwSSUyMGhlbHAlMjB5b3UlMjB0b2RheSUzRiUyMiU3RCUyQyUwQSUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkknZCUyMGxpa2UlMjB0byUyMHNob3clMjBvZmYlMjBob3clMjBjaGF0JTIwdGVtcGxhdGluZyUyMHdvcmtzISUyMiU3RCUyQyUwQSU1RCUwQQ==",highlighted:`&gt;&gt; <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
&gt;&gt; tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;meta-llama/Llama-2-7b-chat-hf&quot;</span>)

&gt;&gt; chat = [
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Hello, how are you?&quot;</span>},
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;I&#x27;m doing great. How can I help you today?&quot;</span>},
<span class="hljs-meta">... </span>  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;I&#x27;d like to show off how chat templating works!&quot;</span>},
<span class="hljs-meta">... </span>]

&gt;&gt; tokenizer.use_default_system_prompt = <span class="hljs-literal">False</span>
&gt;&gt; tokenizer.apply_chat_template(chat, tokenize=<span class="hljs-literal">False</span>)
<span class="hljs-string">&quot;&lt;s&gt;[INST] Hello, how are you? [/INST] I&#x27;m doing great. How can I help you today? &lt;/s&gt;&lt;s&gt;[INST] I&#x27;d like to show off how chat templating works! [/INST]&quot;</span>`}}),ce=new Ce({}),me=new I({props:{code:"JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmJsZW5kZXJib3QtNDAwTS1kaXN0aWxsJTIyKSUwQSUwQXRva2VuaXplci5kZWZhdWx0X2NoYXRfdGVtcGxhdGU=",highlighted:`
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/blenderbot-400M-distill&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.default_chat_template
<span class="hljs-string">&quot;{% for message in messages %}{% if message[&#x27;role&#x27;] == &#x27;user&#x27; %}{{ &#x27; &#x27; }}{% endif %}{{ message[&#x27;content&#x27;] }}{% if not loop.last %}{{ &#x27;  &#x27; }}{% endif %}{% endfor %}{{ eos_token }}&quot;</span>`}}),de=new I({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBpZiUyMG1lc3NhZ2UlNUIncm9sZSclNUQlMjAlM0QlM0QlMjAndXNlciclMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlN0IlMjAnJTIwJyUyMCU3RCU3RCUwQSUyMCUyMCUyMCUyMCU3QiUyNSUyMGVuZGlmJTIwJTI1JTdEJTBBJTIwJTIwJTIwJTIwJTdCJTdCJTIwbWVzc2FnZSU1Qidjb250ZW50JyU1RCUyMCU3RCU3RCUwQSUyMCUyMCUyMCUyMCU3QiUyNSUyMGlmJTIwbm90JTIwbG9vcC5sYXN0JTIwJTI1JTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTdCJTIwJyUyMCUyMCclMjAlN0QlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBlbmRpZiUyMCUyNSU3RCUwQSU3QiUyNSUyMGVuZGZvciUyMCUyNSU3RCUwQSU3QiU3QiUyMGVvc190b2tlbiUyMCU3RCU3RA==",highlighted:`<span class="hljs-template-tag">{%</span> <span class="hljs-name">for</span> message <span class="hljs-keyword">in</span> messages <span class="hljs-template-tag">%}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">if</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;user&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27; &#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endif</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
    </span><span class="hljs-template-variable">{{ message[<span class="hljs-string">&#x27;content&#x27;</span>] }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">if</span> not loop.last <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27;  &#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endif</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ eos_token }}</span>`}}),fe=new I({props:{code:"Zm9yJTIwaWR4JTJDJTIwbWVzc2FnZSUyMGluJTIwZW51bWVyYXRlKG1lc3NhZ2VzKSUzQSUwQSUyMCUyMCUyMCUyMGlmJTIwbWVzc2FnZSU1Qidyb2xlJyU1RCUyMCUzRCUzRCUyMCd1c2VyJyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByaW50KCclMjAnKSUwQSUyMCUyMCUyMCUyMHByaW50KG1lc3NhZ2UlNUInY29udGVudCclNUQpJTBBJTIwJTIwJTIwJTIwaWYlMjBub3QlMjBpZHglMjAlM0QlM0QlMjBsZW4obWVzc2FnZXMpJTIwLSUyMDElM0ElMjAlMjAlMjMlMjBDaGVjayUyMGZvciUyMHRoZSUyMGxhc3QlMjBtZXNzYWdlJTIwaW4lMjB0aGUlMjBjb252ZXJzYXRpb24lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmludCgnJTIwJTIwJyklMEFwcmludChlb3NfdG9rZW4p",highlighted:`<span class="hljs-keyword">for</span> idx, message <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(messages):
    <span class="hljs-keyword">if</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;user&#x27;</span>:
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&#x27; &#x27;</span>)
    <span class="hljs-built_in">print</span>(message[<span class="hljs-string">&#x27;content&#x27;</span>])
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> idx == <span class="hljs-built_in">len</span>(messages) - <span class="hljs-number">1</span>:  <span class="hljs-comment"># Check for the last message in the conversation</span>
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&#x27;  &#x27;</span>)
<span class="hljs-built_in">print</span>(eos_token)`}}),ye=new I({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBpZiUyMG1lc3NhZ2UlNUIncm9sZSclNUQlMjAlM0QlM0QlMjAndXNlciclMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlN0IlMjBib3NfdG9rZW4lMjAlMkIlMjAnJTVCSU5TVCU1RCUyMCclMjAlMkIlMjBtZXNzYWdlJTVCJ2NvbnRlbnQnJTVEJTIwJTJCJTIwJyUyMCU1QiUyRklOU1QlNUQnJTIwJTdEJTdEJTBBJTIwJTIwJTIwJTIwJTdCJTI1JTIwZWxpZiUyMG1lc3NhZ2UlNUIncm9sZSclNUQlMjAlM0QlM0QlMjAnc3lzdGVtJyUyMCUyNSU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiU3QiUyMCclM0MlM0NTWVMlM0UlM0UlNUMlNUNuJyUyMCUyQiUyMG1lc3NhZ2UlNUInY29udGVudCclNUQlMjAlMkIlMjAnJTVDJTVDbiUzQyUzQyUyRlNZUyUzRSUzRSU1QyU1Q24lNUMlNUNuJyUyMCU3RCU3RCUwQSUyMCUyMCUyMCUyMCU3QiUyNSUyMGVsaWYlMjBtZXNzYWdlJTVCJ3JvbGUnJTVEJTIwJTNEJTNEJTIwJ2Fzc2lzdGFudCclMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlN0IlMjAnJTIwJyUyMCUyMCUyQiUyMG1lc3NhZ2UlNUInY29udGVudCclNUQlMjAlMkIlMjAnJTIwJyUyMCUyQiUyMGVvc190b2tlbiUyMCU3RCU3RCUwQSUyMCUyMCUyMCUyMCU3QiUyNSUyMGVuZGlmJTIwJTI1JTdEJTBBJTdCJTI1JTIwZW5kZm9yJTIwJTI1JTdE",highlighted:`<span class="hljs-template-tag">{%</span> <span class="hljs-name">for</span> message <span class="hljs-keyword">in</span> messages <span class="hljs-template-tag">%}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">if</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;user&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ bos_token + <span class="hljs-string">&#x27;[INST] &#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27; [/INST]&#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">elif</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;system&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27;&lt;&lt;SYS&gt;&gt;\\\\n&#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27;\\\\n&lt;&lt;/SYS&gt;&gt;\\\\n\\\\n&#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">elif</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;assistant&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27; &#x27;</span>  + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27; &#x27;</span> + eos_token }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endif</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span>`}}),ge=new Ce({}),we=new I({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBpZiUyMG1lc3NhZ2UlNUIncm9sZSclNUQlMjAlM0QlM0QlMjAndXNlciclMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlN0IlMjBib3NfdG9rZW4lMjAlMkIlMjAnJTVCSU5TVCU1RCUyMCclMjAlMkIlMjBtZXNzYWdlJTVCJ2NvbnRlbnQnJTVELnN0cmlwKCklMjAlMkIlMjAnJTIwJTVCJTJGSU5TVCU1RCclMjAlN0QlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBlbGlmJTIwbWVzc2FnZSU1Qidyb2xlJyU1RCUyMCUzRCUzRCUyMCdzeXN0ZW0nJTIwJTI1JTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTdCJTIwJyUzQyUzQ1NZUyUzRSUzRSU1QyU1Q24nJTIwJTJCJTIwbWVzc2FnZSU1Qidjb250ZW50JyU1RC5zdHJpcCgpJTIwJTJCJTIwJyU1QyU1Q24lM0MlM0MlMkZTWVMlM0UlM0UlNUMlNUNuJTVDJTVDbiclMjAlN0QlN0QlMEElMjAlMjAlMjAlMjAlN0IlMjUlMjBlbGlmJTIwbWVzc2FnZSU1Qidyb2xlJyU1RCUyMCUzRCUzRCUyMCdhc3Npc3RhbnQnJTIwJTI1JTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTdCJTIwJyU1QkFTU1QlNUQlMjAnJTIwJTIwJTJCJTIwbWVzc2FnZSU1Qidjb250ZW50JyU1RCUyMCUyQiUyMCclMjAlNUIlMkZBU1NUJTVEJyUyMCUyQiUyMGVvc190b2tlbiUyMCU3RCU3RCUwQSUyMCUyMCUyMCUyMCU3QiUyNSUyMGVuZGlmJTIwJTI1JTdEJTBBJTdCJTI1JTIwZW5kZm9yJTIwJTI1JTdE",highlighted:`<span class="hljs-template-tag">{%</span> <span class="hljs-name">for</span> message <span class="hljs-keyword">in</span> messages <span class="hljs-template-tag">%}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">if</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;user&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ bos_token + <span class="hljs-string">&#x27;[INST] &#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>].strip() + <span class="hljs-string">&#x27; [/INST]&#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">elif</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;system&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27;&lt;&lt;SYS&gt;&gt;\\\\n&#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>].strip() + <span class="hljs-string">&#x27;\\\\n&lt;&lt;/SYS&gt;&gt;\\\\n\\\\n&#x27;</span> }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">elif</span> message[<span class="hljs-string">&#x27;role&#x27;</span>] == <span class="hljs-string">&#x27;assistant&#x27;</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
        </span><span class="hljs-template-variable">{{ <span class="hljs-string">&#x27;[ASST] &#x27;</span>  + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27; [/ASST]&#x27;</span> + eos_token }}</span><span class="language-xml">
    </span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endif</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span>`}}),Me=new I({props:{code:"dGVtcGxhdGUlMjAlM0QlMjB0b2tlbml6ZXIuY2hhdF90ZW1wbGF0ZSUwQXRlbXBsYXRlJTIwJTNEJTIwdGVtcGxhdGUucmVwbGFjZSglMjJTWVMlMjIlMkMlMjAlMjJTWVNURU0lMjIpJTIwJTIwJTIzJTIwQ2hhbmdlJTIwdGhlJTIwc3lzdGVtJTIwdG9rZW4lMEF0b2tlbml6ZXIuY2hhdF90ZW1wbGF0ZSUyMCUzRCUyMHRlbXBsYXRlJTIwJTIwJTIzJTIwU2V0JTIwdGhlJTIwbmV3JTIwdGVtcGxhdGUlMEF0b2tlbml6ZXIucHVzaF90b19odWIoJTIybW9kZWxfbmFtZSUyMiklMjAlMjAlMjMlMjBVcGxvYWQlMjB5b3VyJTIwbmV3JTIwdGVtcGxhdGUlMjB0byUyMHRoZSUyMEh1YiE=",highlighted:`template = tokenizer.chat_template
template = template.replace(<span class="hljs-string">&quot;SYS&quot;</span>, <span class="hljs-string">&quot;SYSTEM&quot;</span>)  <span class="hljs-comment"># Change the system token</span>
tokenizer.chat_template = template  <span class="hljs-comment"># Set the new template</span>
tokenizer.push_to_hub(<span class="hljs-string">&quot;model_name&quot;</span>)  <span class="hljs-comment"># Upload your new template to the Hub!</span>`}}),je=new Ce({}),Ue=new Ce({}),Te=new I({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElMjAlMjAlMjAlMjAlN0IlN0InJTNDJTdDaW1fc3RhcnQlN0MlM0UnJTIwJTJCJTIwbWVzc2FnZSU1Qidyb2xlJyU1RCUyMCUyQiUyMCclNUNuJyUyMCUyQiUyMG1lc3NhZ2UlNUInY29udGVudCclNUQlMjAlMkIlMjAnJTNDJTdDaW1fZW5kJTdDJTNFJyUyMCUyQiUyMCclNUNuJyU3RCU3RCUwQSU3QiUyNSUyMGVuZGZvciUyMCUyNSU3RA==",highlighted:`<span class="hljs-template-tag">{%</span> <span class="hljs-name">for</span> message <span class="hljs-keyword">in</span> messages <span class="hljs-template-tag">%}</span><span class="language-xml">
    </span><span class="hljs-template-variable">{{<span class="hljs-string">&#x27;&lt;|im_start|&gt;&#x27;</span> + message[<span class="hljs-string">&#x27;role&#x27;</span>] + <span class="hljs-string">&#x27;\\n&#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27;&lt;|im_end|&gt;&#x27;</span> + <span class="hljs-string">&#x27;\\n&#x27;</span>}}</span><span class="language-xml">
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span>`}}),be=new I({props:{code:"dG9rZW5pemVyLmNoYXRfdGVtcGxhdGUlMjAlM0QlMjAlMjIlN0IlMjUlMjBmb3IlMjBtZXNzYWdlJTIwaW4lMjBtZXNzYWdlcyUyMCUyNSU3RCU3QiU3QiclM0MlN0NpbV9zdGFydCU3QyUzRSclMjAlMkIlMjBtZXNzYWdlJTVCJ3JvbGUnJTVEJTIwJTJCJTIwJyU1Q24nJTIwJTJCJTIwbWVzc2FnZSU1Qidjb250ZW50JyU1RCUyMCUyQiUyMCclM0MlN0NpbV9lbmQlN0MlM0UnJTIwJTJCJTIwJyU1Q24nJTdEJTdEJTdCJTI1JTIwZW5kZm9yJTIwJTI1JTdEJTIy",highlighted:'<span class="language-xml">tokenizer.chat_template = &quot;</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">for</span> message <span class="hljs-keyword">in</span> messages <span class="hljs-template-tag">%}</span><span class="hljs-template-variable">{{<span class="hljs-string">&#x27;&lt;|im_start|&gt;&#x27;</span> + message[<span class="hljs-string">&#x27;role&#x27;</span>] + <span class="hljs-string">&#x27;\\n&#x27;</span> + message[<span class="hljs-string">&#x27;content&#x27;</span>] + <span class="hljs-string">&#x27;&lt;|im_end|&gt;&#x27;</span> + <span class="hljs-string">&#x27;\\n&#x27;</span>}}</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span><span class="language-xml">&quot;</span>'}}),Ie=new I({props:{code:"JTNDJTdDaW1fc3RhcnQlN0MlM0VzeXN0ZW0lMEFZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGNoYXRib3QlMjB0aGF0JTIwd2lsbCUyMGRvJTIwaXRzJTIwYmVzdCUyMG5vdCUyMHRvJTIwc2F5JTIwYW55dGhpbmclMjBzbyUyMHN0dXBpZCUyMHRoYXQlMjBwZW9wbGUlMjB0d2VldCUyMGFib3V0JTIwaXQuJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTNDJTdDaW1fc3RhcnQlN0MlM0V1c2VyJTBBSG93JTIwYXJlJTIweW91JTNGJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTNDJTdDaW1fc3RhcnQlN0MlM0Vhc3Npc3RhbnQlMEFJJ20lMjBkb2luZyUyMGdyZWF0ISUzQyU3Q2ltX2VuZCU3QyUzRQ==",highlighted:`&lt;|<span class="hljs-type">im_start</span>|<span class="hljs-type">&gt;system</span>
You are a helpful chatbot that will <span class="hljs-built_in">do</span> its best not to say anything so stupid that people tweet about it.&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;
&lt;|im_start</span>|<span class="hljs-type">&gt;user</span>
How are you?&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;
&lt;|im_start</span>|<span class="hljs-type">&gt;assistant</span>
I&#x27;m doing great!&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;</span>`}}),ve=new Ce({}),{c(){A=n("meta"),zt=h(),S=n("h1"),W=n("a"),Le=n("span"),d(oe.$$.fragment),Ps=h(),Oe=n("span"),Xs=a("Templates for Chat Models"),Bt=h(),Q=n("h2"),V=n("a"),Ke=n("span"),d(ie.$$.fragment),Ys=h(),et=n("span"),Hs=a("Introduction"),Wt=h(),j=n("p"),Ds=a("An increasingly common use case for LLMs is "),tt=n("strong"),Ls=a("chat"),Os=a(`. In a chat context, rather than continuing a single string
of text (as is the case with a standard language model), the model instead continues a conversation that consists
of one or more `),st=n("strong"),Ks=a("messages"),ea=a(", each of which includes a "),at=n("strong"),ta=a("role"),sa=a(" as well as message text."),Vt=h(),xe=n("p"),aa=a(`Most commonly, these roles are \u201Cuser\u201D for messages sent by the user, and \u201Cassistant\u201D for messages sent by the model.
Some models also support a \u201Csystem\u201D role. System messages are usually sent at the beginning of the conversation
and include directives about how the model should behave in the subsequent chat.`),Rt=h(),_e=n("p"),la=a(`All language models, including models fine-tuned for chat, operate on linear sequences of tokens and do not intrinsically
have special handling for roles. This means that role information is usually injected by adding control tokens
between messages, to indicate both the message boundary and the relevant roles.`),qt=h(),R=n("p"),na=a(`Unfortunately, there isn\u2019t (yet!) a standard for which tokens to use, and so different models have been trained
with wildly different formatting and control tokens for chat. This can be a real problem for users - if you use the
wrong format, then the model will be confused by your input, and your performance will be a lot worse than it should be.
This is the problem that `),lt=n("strong"),oa=a("chat templates"),ia=a(" aim to resolve."),Ft=h(),v=n("p"),ra=a("Chat conversations are typically represented as a list of dictionaries, where each dictionary contains "),nt=n("code"),pa=a("role"),ha=a(`
and `),ot=n("code"),ca=a("content"),ma=a(` keys, and represents a single chat message. Chat templates are strings containing a Jinja template that
specifies how to format a conversation for a given model into a single tokenizable sequence. By storing this information
with the tokenizer, we can ensure that models get input data in the format they expect.`),Pt=h(),q=n("p"),da=a("Let\u2019s make this concrete with a quick example using the "),it=n("code"),ua=a("BlenderBot"),fa=a(` model. BlenderBot has an extremely simple default
template, which mostly just adds whitespace between rounds of dialogue:`),Xt=h(),d(re.$$.fragment),Yt=h(),U=n("p"),ya=a("Notice how the entire chat is condensed into a single string. If we use "),rt=n("code"),ga=a("tokenize=True"),wa=a(`, which is the default setting,
that string will also be tokenized for us. To see a more complex template in action, though, let\u2019s use the
`),pt=n("code"),Ma=a("meta-llama/Llama-2-7b-chat-hf"),ja=a(` model. Note that this model has gated access, so you will have to
`),pe=n("a"),Ua=a("request access on the repo"),Ja=a(" if you want to run this code yourself:"),Ht=h(),d(he.$$.fragment),Dt=h(),Ne=n("p"),Ta=a(`Note that this time, the tokenizer has added the control tokens [INST] and [/INST] to indicate the start and end of
user messages (but not assistant messages!)`),Lt=h(),$=n("h2"),F=n("a"),ht=n("span"),d(ce.$$.fragment),ba=h(),ct=n("span"),Ia=a("How do chat templates work?"),Ot=h(),k=n("p"),va=a("The chat template for a model is stored on the "),mt=n("code"),ka=a("tokenizer.chat_template"),Ca=a(` attribute. If no chat template is set, the
default template for that model class is used instead. Let\u2019s take a look at the template for `),dt=n("code"),xa=a("BlenderBot"),_a=a(":"),Kt=h(),d(me.$$.fragment),es=h(),C=n("p"),Na=a(`That\u2019s kind of intimidating. Let\u2019s add some newlines and indentation to make it more readable. Note that
we remove the first newline after each block as well as any preceding whitespace before a block by default, using the
Jinja `),ut=n("code"),Ea=a("trim_blocks"),Aa=a(" and "),ft=n("code"),Sa=a("lstrip_blocks"),Qa=a(` flags. This means that you can write your templates with indentations and
newlines and still have them function correctly!`),ts=h(),d(de.$$.fragment),ss=h(),P=n("p"),$a=a("If you\u2019ve never seen one of these before, this is a "),ue=n("a"),Za=a("Jinja template"),Ga=a(`.
Jinja is a templating language that allows you to write simple code that generates text. In many ways, the code and
syntax resembles Python. In pure Python, this template would look something like this:`),as=h(),d(fe.$$.fragment),ls=h(),Ee=n("p"),za=a("Effectively, the template does three things:"),ns=h(),x=n("ol"),yt=n("li"),Ba=a("For each message, if the message is a user message, add a blank space before it, otherwise print nothing."),Wa=h(),gt=n("li"),Va=a("Add the message content"),Ra=h(),wt=n("li"),qa=a("If the message is not the last message, add two spaces after it. After the final message, print the EOS token."),os=h(),Ae=n("p"),Fa=a(`This is a pretty simple template - it doesn\u2019t add any control tokens, and it doesn\u2019t support \u201Csystem\u201D messages, which
are a common way to give the model directives about how it should behave in the subsequent conversation.
But Jinja gives you a lot of flexibility to do those things! Let\u2019s see a Jinja template that can format inputs
similarly to the way LLaMA formats them (note that the real LLaMA template includes handling for default system
messages and slightly different system message handling in general - don\u2019t use this one in your actual code!)`),is=h(),d(ye.$$.fragment),rs=h(),Se=n("p"),Pa=a(`Hopefully if you stare at this for a little bit you can see what this template is doing - it adds specific tokens based
on the \u201Crole\u201D of each message, which represents who sent it. User, assistant and system messages are clearly
distinguishable to the model because of the tokens they\u2019re wrapped in.`),ps=h(),Z=n("h2"),X=n("a"),Mt=n("span"),d(ge.$$.fragment),Xa=h(),jt=n("span"),Ya=a("How do I create a chat template?"),hs=h(),Y=n("p"),Ha=a("Simple, just write a jinja template and set "),Ut=n("code"),Da=a("tokenizer.chat_template"),La=a(`. You may find it easier to start with an
existing template from another model and simply edit it for your needs! For example, we could take the LLaMA template
above and add \u201D[ASST]\u201D and \u201D[/ASST]\u201D to assistant messages:`),cs=h(),d(we.$$.fragment),ms=h(),M=n("p"),Oa=a("Now, simply set the "),Jt=n("code"),Ka=a("tokenizer.chat_template"),el=a(" attribute. Next time you use "),Qe=n("a"),tl=a("apply_chat_template()"),sl=a(`, it will
use your new template! This attribute will be saved in the `),Tt=n("code"),al=a("tokenizer_config.json"),ll=a(` file, so you can use
`),$e=n("a"),nl=a("push_to_hub()"),ol=a(` to upload your new template to the Hub and make sure everyone\u2019s using the right
template for your model!`),ds=h(),d(Me.$$.fragment),us=h(),J=n("p"),il=a("The method "),Ze=n("a"),rl=a("apply_chat_template()"),pl=a(" which uses your chat template is called by the "),Ge=n("a"),hl=a("ConversationalPipeline"),cl=a(` class, so
once you set the correct chat template, your model will automatically become compatible with `),ze=n("a"),ml=a("ConversationalPipeline"),dl=a("."),fs=h(),G=n("h2"),H=n("a"),bt=n("span"),d(je.$$.fragment),ul=h(),It=n("span"),fl=a('What are "default" templates?'),ys=h(),T=n("p"),yl=a(`Before the introduction of chat templates, chat handling was hardcoded at the model class level. For backwards
compatibility, we have retained this class-specific handling as default templates, also set at the class level. If a
model does not have a chat template set, but there is a default template for its model class, the `),vt=n("code"),gl=a("ConversationPipeline"),wl=a(`
class and methods like `),kt=n("code"),Ml=a("apply_chat_template"),jl=a(` will use the class template instead. You can find out what the default
template for your tokenizer is by checking the `),Ct=n("code"),Ul=a("tokenizer.default_chat_template"),Jl=a(" attribute."),gs=h(),D=n("p"),Tl=a(`This is something we do purely for backward compatibility reasons, to avoid breaking any existing workflows. Even when
the class template is appropriate for your model, we strongly recommend overriding the default template by
setting the `),xt=n("code"),bl=a("chat_template"),Il=a(` attribute explicitly to make it clear to users that your model has been correctly configured
for chat, and to future-proof in case the default templates are ever altered or deprecated.`),ws=h(),z=n("h2"),L=n("a"),_t=n("span"),d(Ue.$$.fragment),vl=h(),Nt=n("span"),kl=a("What template should I use?"),Ms=h(),Be=n("p"),Cl=a(`When setting the template for a model that\u2019s already been trained for chat, you should ensure that the template
exactly matches the message formatting that the model saw during training, or else you will probably experience
performance degradation. This is true even if you\u2019re training the model further - you will probably get the best
performance if you keep the chat tokens constant. This is very analogous to tokenization - you generally get the
best performance for inference or fine-tuning when you precisely match the tokenization used during training.`),js=h(),O=n("p"),xl=a(`If you\u2019re training a model from scratch, or fine-tuning a base language model for chat, on the other hand,
you have a lot of freedom to choose an appropriate template! LLMs are smart enough to learn to handle lots of different
input formats. Our default template for models that don\u2019t have a class-specific template follows the
`),Je=n("a"),_l=a("ChatML format"),Nl=a(", and this is a good, flexible choice for many use-cases. It looks like this:"),Us=h(),d(Te.$$.fragment),Js=h(),We=n("p"),El=a("If you like this one, here it is in one-liner form, ready to copy into your code:"),Ts=h(),d(be.$$.fragment),bs=h(),_=n("p"),Al=a("This template wraps each message in "),Et=n("code"),Sl=a("<|im_start|>"),Ql=a(" and "),At=n("code"),$l=a("<|im_end|>"),Zl=a(` tokens, and simply writes the role as a string, which
allows for flexibility in the roles you train with. The output looks like this:`),Is=h(),d(Ie.$$.fragment),vs=h(),K=n("p"),Gl=a(`The \u201Cuser\u201D, \u201Csystem\u201D and \u201Cassistant\u201D roles are the standard for chat, and we recommend using them when it makes sense,
particularly if you want your model to operate well with `),Ve=n("a"),zl=a("ConversationalPipeline"),Bl=a(`. However, you are not limited
to these roles - templating is extremely flexible, and any string can be a role.`),ks=h(),B=n("h2"),ee=n("a"),St=n("span"),d(ve.$$.fragment),Wl=h(),Qt=n("span"),Vl=a("I want to use chat templates! How should I get started?"),Cs=h(),b=n("p"),Rl=a("If you have any chat models, you should set their "),$t=n("code"),ql=a("tokenizer.chat_template"),Fl=a(` attribute and test it using
`),Re=n("a"),Pl=a("apply_chat_template()"),Xl=a(`. This applies even if you\u2019re not the model owner - if you\u2019re using a model
with an empty chat template, or one that\u2019s still using the default class template, please open a `),ke=n("a"),Yl=a("pull request"),Hl=a(` to
the model repository so that this attribute can be set properly!`),xs=h(),N=n("p"),Dl=a("Once the attribute is set, that\u2019s it, you\u2019re done! "),Zt=n("code"),Ll=a("tokenizer.apply_chat_template"),Ol=a(` will now work correctly for that
model, which means it is also automatically supported in places like `),Gt=n("code"),Kl=a("ConversationPipeline"),en=a("!"),_s=h(),qe=n("p"),tn=a(`By ensuring that models have this attribute, we can make sure that the whole community gets to use the full power of
open-source models. Formatting mismatches have been haunting the field and silently harming performance for too long -
it\u2019s time to put an end to them!`),this.h()},l(e){const i=To('[data-svelte="svelte-1phssyn"]',document.head);A=o(i,"META",{name:!0,content:!0}),i.forEach(s),zt=c(e),S=o(e,"H1",{class:!0});var Es=r(S);W=o(Es,"A",{id:!0,class:!0,href:!0});var an=r(W);Le=o(an,"SPAN",{});var ln=r(Le);u(oe.$$.fragment,ln),ln.forEach(s),an.forEach(s),Ps=c(Es),Oe=o(Es,"SPAN",{});var nn=r(Oe);Xs=l(nn,"Templates for Chat Models"),nn.forEach(s),Es.forEach(s),Bt=c(e),Q=o(e,"H2",{class:!0});var As=r(Q);V=o(As,"A",{id:!0,class:!0,href:!0});var on=r(V);Ke=o(on,"SPAN",{});var rn=r(Ke);u(ie.$$.fragment,rn),rn.forEach(s),on.forEach(s),Ys=c(As),et=o(As,"SPAN",{});var pn=r(et);Hs=l(pn,"Introduction"),pn.forEach(s),As.forEach(s),Wt=c(e),j=o(e,"P",{});var te=r(j);Ds=l(te,"An increasingly common use case for LLMs is "),tt=o(te,"STRONG",{});var hn=r(tt);Ls=l(hn,"chat"),hn.forEach(s),Os=l(te,`. In a chat context, rather than continuing a single string
of text (as is the case with a standard language model), the model instead continues a conversation that consists
of one or more `),st=o(te,"STRONG",{});var cn=r(st);Ks=l(cn,"messages"),cn.forEach(s),ea=l(te,", each of which includes a "),at=o(te,"STRONG",{});var mn=r(at);ta=l(mn,"role"),mn.forEach(s),sa=l(te," as well as message text."),te.forEach(s),Vt=c(e),xe=o(e,"P",{});var dn=r(xe);aa=l(dn,`Most commonly, these roles are \u201Cuser\u201D for messages sent by the user, and \u201Cassistant\u201D for messages sent by the model.
Some models also support a \u201Csystem\u201D role. System messages are usually sent at the beginning of the conversation
and include directives about how the model should behave in the subsequent chat.`),dn.forEach(s),Rt=c(e),_e=o(e,"P",{});var un=r(_e);la=l(un,`All language models, including models fine-tuned for chat, operate on linear sequences of tokens and do not intrinsically
have special handling for roles. This means that role information is usually injected by adding control tokens
between messages, to indicate both the message boundary and the relevant roles.`),un.forEach(s),qt=c(e),R=o(e,"P",{});var Ss=r(R);na=l(Ss,`Unfortunately, there isn\u2019t (yet!) a standard for which tokens to use, and so different models have been trained
with wildly different formatting and control tokens for chat. This can be a real problem for users - if you use the
wrong format, then the model will be confused by your input, and your performance will be a lot worse than it should be.
This is the problem that `),lt=o(Ss,"STRONG",{});var fn=r(lt);oa=l(fn,"chat templates"),fn.forEach(s),ia=l(Ss," aim to resolve."),Ss.forEach(s),Ft=c(e),v=o(e,"P",{});var Fe=r(v);ra=l(Fe,"Chat conversations are typically represented as a list of dictionaries, where each dictionary contains "),nt=o(Fe,"CODE",{});var yn=r(nt);pa=l(yn,"role"),yn.forEach(s),ha=l(Fe,`
and `),ot=o(Fe,"CODE",{});var gn=r(ot);ca=l(gn,"content"),gn.forEach(s),ma=l(Fe,` keys, and represents a single chat message. Chat templates are strings containing a Jinja template that
specifies how to format a conversation for a given model into a single tokenizable sequence. By storing this information
with the tokenizer, we can ensure that models get input data in the format they expect.`),Fe.forEach(s),Pt=c(e),q=o(e,"P",{});var Qs=r(q);da=l(Qs,"Let\u2019s make this concrete with a quick example using the "),it=o(Qs,"CODE",{});var wn=r(it);ua=l(wn,"BlenderBot"),wn.forEach(s),fa=l(Qs,` model. BlenderBot has an extremely simple default
template, which mostly just adds whitespace between rounds of dialogue:`),Qs.forEach(s),Xt=c(e),u(re.$$.fragment,e),Yt=c(e),U=o(e,"P",{});var se=r(U);ya=l(se,"Notice how the entire chat is condensed into a single string. If we use "),rt=o(se,"CODE",{});var Mn=r(rt);ga=l(Mn,"tokenize=True"),Mn.forEach(s),wa=l(se,`, which is the default setting,
that string will also be tokenized for us. To see a more complex template in action, though, let\u2019s use the
`),pt=o(se,"CODE",{});var jn=r(pt);Ma=l(jn,"meta-llama/Llama-2-7b-chat-hf"),jn.forEach(s),ja=l(se,` model. Note that this model has gated access, so you will have to
`),pe=o(se,"A",{href:!0,rel:!0});var Un=r(pe);Ua=l(Un,"request access on the repo"),Un.forEach(s),Ja=l(se," if you want to run this code yourself:"),se.forEach(s),Ht=c(e),u(he.$$.fragment,e),Dt=c(e),Ne=o(e,"P",{});var Jn=r(Ne);Ta=l(Jn,`Note that this time, the tokenizer has added the control tokens [INST] and [/INST] to indicate the start and end of
user messages (but not assistant messages!)`),Jn.forEach(s),Lt=c(e),$=o(e,"H2",{class:!0});var $s=r($);F=o($s,"A",{id:!0,class:!0,href:!0});var Tn=r(F);ht=o(Tn,"SPAN",{});var bn=r(ht);u(ce.$$.fragment,bn),bn.forEach(s),Tn.forEach(s),ba=c($s),ct=o($s,"SPAN",{});var In=r(ct);Ia=l(In,"How do chat templates work?"),In.forEach(s),$s.forEach(s),Ot=c(e),k=o(e,"P",{});var Pe=r(k);va=l(Pe,"The chat template for a model is stored on the "),mt=o(Pe,"CODE",{});var vn=r(mt);ka=l(vn,"tokenizer.chat_template"),vn.forEach(s),Ca=l(Pe,` attribute. If no chat template is set, the
default template for that model class is used instead. Let\u2019s take a look at the template for `),dt=o(Pe,"CODE",{});var kn=r(dt);xa=l(kn,"BlenderBot"),kn.forEach(s),_a=l(Pe,":"),Pe.forEach(s),Kt=c(e),u(me.$$.fragment,e),es=c(e),C=o(e,"P",{});var Xe=r(C);Na=l(Xe,`That\u2019s kind of intimidating. Let\u2019s add some newlines and indentation to make it more readable. Note that
we remove the first newline after each block as well as any preceding whitespace before a block by default, using the
Jinja `),ut=o(Xe,"CODE",{});var Cn=r(ut);Ea=l(Cn,"trim_blocks"),Cn.forEach(s),Aa=l(Xe," and "),ft=o(Xe,"CODE",{});var xn=r(ft);Sa=l(xn,"lstrip_blocks"),xn.forEach(s),Qa=l(Xe,` flags. This means that you can write your templates with indentations and
newlines and still have them function correctly!`),Xe.forEach(s),ts=c(e),u(de.$$.fragment,e),ss=c(e),P=o(e,"P",{});var Zs=r(P);$a=l(Zs,"If you\u2019ve never seen one of these before, this is a "),ue=o(Zs,"A",{href:!0,rel:!0});var _n=r(ue);Za=l(_n,"Jinja template"),_n.forEach(s),Ga=l(Zs,`.
Jinja is a templating language that allows you to write simple code that generates text. In many ways, the code and
syntax resembles Python. In pure Python, this template would look something like this:`),Zs.forEach(s),as=c(e),u(fe.$$.fragment,e),ls=c(e),Ee=o(e,"P",{});var Nn=r(Ee);za=l(Nn,"Effectively, the template does three things:"),Nn.forEach(s),ns=c(e),x=o(e,"OL",{});var Ye=r(x);yt=o(Ye,"LI",{});var En=r(yt);Ba=l(En,"For each message, if the message is a user message, add a blank space before it, otherwise print nothing."),En.forEach(s),Wa=c(Ye),gt=o(Ye,"LI",{});var An=r(gt);Va=l(An,"Add the message content"),An.forEach(s),Ra=c(Ye),wt=o(Ye,"LI",{});var Sn=r(wt);qa=l(Sn,"If the message is not the last message, add two spaces after it. After the final message, print the EOS token."),Sn.forEach(s),Ye.forEach(s),os=c(e),Ae=o(e,"P",{});var Qn=r(Ae);Fa=l(Qn,`This is a pretty simple template - it doesn\u2019t add any control tokens, and it doesn\u2019t support \u201Csystem\u201D messages, which
are a common way to give the model directives about how it should behave in the subsequent conversation.
But Jinja gives you a lot of flexibility to do those things! Let\u2019s see a Jinja template that can format inputs
similarly to the way LLaMA formats them (note that the real LLaMA template includes handling for default system
messages and slightly different system message handling in general - don\u2019t use this one in your actual code!)`),Qn.forEach(s),is=c(e),u(ye.$$.fragment,e),rs=c(e),Se=o(e,"P",{});var $n=r(Se);Pa=l($n,`Hopefully if you stare at this for a little bit you can see what this template is doing - it adds specific tokens based
on the \u201Crole\u201D of each message, which represents who sent it. User, assistant and system messages are clearly
distinguishable to the model because of the tokens they\u2019re wrapped in.`),$n.forEach(s),ps=c(e),Z=o(e,"H2",{class:!0});var Gs=r(Z);X=o(Gs,"A",{id:!0,class:!0,href:!0});var Zn=r(X);Mt=o(Zn,"SPAN",{});var Gn=r(Mt);u(ge.$$.fragment,Gn),Gn.forEach(s),Zn.forEach(s),Xa=c(Gs),jt=o(Gs,"SPAN",{});var zn=r(jt);Ya=l(zn,"How do I create a chat template?"),zn.forEach(s),Gs.forEach(s),hs=c(e),Y=o(e,"P",{});var zs=r(Y);Ha=l(zs,"Simple, just write a jinja template and set "),Ut=o(zs,"CODE",{});var Bn=r(Ut);Da=l(Bn,"tokenizer.chat_template"),Bn.forEach(s),La=l(zs,`. You may find it easier to start with an
existing template from another model and simply edit it for your needs! For example, we could take the LLaMA template
above and add \u201D[ASST]\u201D and \u201D[/ASST]\u201D to assistant messages:`),zs.forEach(s),cs=c(e),u(we.$$.fragment,e),ms=c(e),M=o(e,"P",{});var E=r(M);Oa=l(E,"Now, simply set the "),Jt=o(E,"CODE",{});var Wn=r(Jt);Ka=l(Wn,"tokenizer.chat_template"),Wn.forEach(s),el=l(E," attribute. Next time you use "),Qe=o(E,"A",{href:!0});var Vn=r(Qe);tl=l(Vn,"apply_chat_template()"),Vn.forEach(s),sl=l(E,`, it will
use your new template! This attribute will be saved in the `),Tt=o(E,"CODE",{});var Rn=r(Tt);al=l(Rn,"tokenizer_config.json"),Rn.forEach(s),ll=l(E,` file, so you can use
`),$e=o(E,"A",{href:!0});var qn=r($e);nl=l(qn,"push_to_hub()"),qn.forEach(s),ol=l(E,` to upload your new template to the Hub and make sure everyone\u2019s using the right
template for your model!`),E.forEach(s),ds=c(e),u(Me.$$.fragment,e),us=c(e),J=o(e,"P",{});var ae=r(J);il=l(ae,"The method "),Ze=o(ae,"A",{href:!0});var Fn=r(Ze);rl=l(Fn,"apply_chat_template()"),Fn.forEach(s),pl=l(ae," which uses your chat template is called by the "),Ge=o(ae,"A",{href:!0});var Pn=r(Ge);hl=l(Pn,"ConversationalPipeline"),Pn.forEach(s),cl=l(ae,` class, so
once you set the correct chat template, your model will automatically become compatible with `),ze=o(ae,"A",{href:!0});var Xn=r(ze);ml=l(Xn,"ConversationalPipeline"),Xn.forEach(s),dl=l(ae,"."),ae.forEach(s),fs=c(e),G=o(e,"H2",{class:!0});var Bs=r(G);H=o(Bs,"A",{id:!0,class:!0,href:!0});var Yn=r(H);bt=o(Yn,"SPAN",{});var Hn=r(bt);u(je.$$.fragment,Hn),Hn.forEach(s),Yn.forEach(s),ul=c(Bs),It=o(Bs,"SPAN",{});var Dn=r(It);fl=l(Dn,'What are "default" templates?'),Dn.forEach(s),Bs.forEach(s),ys=c(e),T=o(e,"P",{});var le=r(T);yl=l(le,`Before the introduction of chat templates, chat handling was hardcoded at the model class level. For backwards
compatibility, we have retained this class-specific handling as default templates, also set at the class level. If a
model does not have a chat template set, but there is a default template for its model class, the `),vt=o(le,"CODE",{});var Ln=r(vt);gl=l(Ln,"ConversationPipeline"),Ln.forEach(s),wl=l(le,`
class and methods like `),kt=o(le,"CODE",{});var On=r(kt);Ml=l(On,"apply_chat_template"),On.forEach(s),jl=l(le,` will use the class template instead. You can find out what the default
template for your tokenizer is by checking the `),Ct=o(le,"CODE",{});var Kn=r(Ct);Ul=l(Kn,"tokenizer.default_chat_template"),Kn.forEach(s),Jl=l(le," attribute."),le.forEach(s),gs=c(e),D=o(e,"P",{});var Ws=r(D);Tl=l(Ws,`This is something we do purely for backward compatibility reasons, to avoid breaking any existing workflows. Even when
the class template is appropriate for your model, we strongly recommend overriding the default template by
setting the `),xt=o(Ws,"CODE",{});var eo=r(xt);bl=l(eo,"chat_template"),eo.forEach(s),Il=l(Ws,` attribute explicitly to make it clear to users that your model has been correctly configured
for chat, and to future-proof in case the default templates are ever altered or deprecated.`),Ws.forEach(s),ws=c(e),z=o(e,"H2",{class:!0});var Vs=r(z);L=o(Vs,"A",{id:!0,class:!0,href:!0});var to=r(L);_t=o(to,"SPAN",{});var so=r(_t);u(Ue.$$.fragment,so),so.forEach(s),to.forEach(s),vl=c(Vs),Nt=o(Vs,"SPAN",{});var ao=r(Nt);kl=l(ao,"What template should I use?"),ao.forEach(s),Vs.forEach(s),Ms=c(e),Be=o(e,"P",{});var lo=r(Be);Cl=l(lo,`When setting the template for a model that\u2019s already been trained for chat, you should ensure that the template
exactly matches the message formatting that the model saw during training, or else you will probably experience
performance degradation. This is true even if you\u2019re training the model further - you will probably get the best
performance if you keep the chat tokens constant. This is very analogous to tokenization - you generally get the
best performance for inference or fine-tuning when you precisely match the tokenization used during training.`),lo.forEach(s),js=c(e),O=o(e,"P",{});var Rs=r(O);xl=l(Rs,`If you\u2019re training a model from scratch, or fine-tuning a base language model for chat, on the other hand,
you have a lot of freedom to choose an appropriate template! LLMs are smart enough to learn to handle lots of different
input formats. Our default template for models that don\u2019t have a class-specific template follows the
`),Je=o(Rs,"A",{href:!0,rel:!0});var no=r(Je);_l=l(no,"ChatML format"),no.forEach(s),Nl=l(Rs,", and this is a good, flexible choice for many use-cases. It looks like this:"),Rs.forEach(s),Us=c(e),u(Te.$$.fragment,e),Js=c(e),We=o(e,"P",{});var oo=r(We);El=l(oo,"If you like this one, here it is in one-liner form, ready to copy into your code:"),oo.forEach(s),Ts=c(e),u(be.$$.fragment,e),bs=c(e),_=o(e,"P",{});var He=r(_);Al=l(He,"This template wraps each message in "),Et=o(He,"CODE",{});var io=r(Et);Sl=l(io,"<|im_start|>"),io.forEach(s),Ql=l(He," and "),At=o(He,"CODE",{});var ro=r(At);$l=l(ro,"<|im_end|>"),ro.forEach(s),Zl=l(He,` tokens, and simply writes the role as a string, which
allows for flexibility in the roles you train with. The output looks like this:`),He.forEach(s),Is=c(e),u(Ie.$$.fragment,e),vs=c(e),K=o(e,"P",{});var qs=r(K);Gl=l(qs,`The \u201Cuser\u201D, \u201Csystem\u201D and \u201Cassistant\u201D roles are the standard for chat, and we recommend using them when it makes sense,
particularly if you want your model to operate well with `),Ve=o(qs,"A",{href:!0});var po=r(Ve);zl=l(po,"ConversationalPipeline"),po.forEach(s),Bl=l(qs,`. However, you are not limited
to these roles - templating is extremely flexible, and any string can be a role.`),qs.forEach(s),ks=c(e),B=o(e,"H2",{class:!0});var Fs=r(B);ee=o(Fs,"A",{id:!0,class:!0,href:!0});var ho=r(ee);St=o(ho,"SPAN",{});var co=r(St);u(ve.$$.fragment,co),co.forEach(s),ho.forEach(s),Wl=c(Fs),Qt=o(Fs,"SPAN",{});var mo=r(Qt);Vl=l(mo,"I want to use chat templates! How should I get started?"),mo.forEach(s),Fs.forEach(s),Cs=c(e),b=o(e,"P",{});var ne=r(b);Rl=l(ne,"If you have any chat models, you should set their "),$t=o(ne,"CODE",{});var uo=r($t);ql=l(uo,"tokenizer.chat_template"),uo.forEach(s),Fl=l(ne,` attribute and test it using
`),Re=o(ne,"A",{href:!0});var fo=r(Re);Pl=l(fo,"apply_chat_template()"),fo.forEach(s),Xl=l(ne,`. This applies even if you\u2019re not the model owner - if you\u2019re using a model
with an empty chat template, or one that\u2019s still using the default class template, please open a `),ke=o(ne,"A",{href:!0,rel:!0});var yo=r(ke);Yl=l(yo,"pull request"),yo.forEach(s),Hl=l(ne,` to
the model repository so that this attribute can be set properly!`),ne.forEach(s),xs=c(e),N=o(e,"P",{});var De=r(N);Dl=l(De,"Once the attribute is set, that\u2019s it, you\u2019re done! "),Zt=o(De,"CODE",{});var go=r(Zt);Ll=l(go,"tokenizer.apply_chat_template"),go.forEach(s),Ol=l(De,` will now work correctly for that
model, which means it is also automatically supported in places like `),Gt=o(De,"CODE",{});var wo=r(Gt);Kl=l(wo,"ConversationPipeline"),wo.forEach(s),en=l(De,"!"),De.forEach(s),_s=c(e),qe=o(e,"P",{});var Mo=r(qe);tn=l(Mo,`By ensuring that models have this attribute, we can make sure that the whole community gets to use the full power of
open-source models. Formatting mismatches have been haunting the field and silently harming performance for too long -
it\u2019s time to put an end to them!`),Mo.forEach(s),this.h()},h(){m(A,"name","hf:doc:metadata"),m(A,"content",JSON.stringify(ko)),m(W,"id","templates-for-chat-models"),m(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(W,"href","#templates-for-chat-models"),m(S,"class","relative group"),m(V,"id","introduction"),m(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(V,"href","#introduction"),m(Q,"class","relative group"),m(pe,"href","https://huggingface.co/meta-llama/Llama-2-7b-chat-hf"),m(pe,"rel","nofollow"),m(F,"id","how-do-chat-templates-work"),m(F,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(F,"href","#how-do-chat-templates-work"),m($,"class","relative group"),m(ue,"href","https://jinja.palletsprojects.com/en/3.1.x/templates/"),m(ue,"rel","nofollow"),m(X,"id","how-do-i-create-a-chat-template"),m(X,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(X,"href","#how-do-i-create-a-chat-template"),m(Z,"class","relative group"),m(Qe,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.apply_chat_template"),m($e,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.push_to_hub"),m(Ze,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.apply_chat_template"),m(Ge,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.ConversationalPipeline"),m(ze,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.ConversationalPipeline"),m(H,"id","what-are-default-templates"),m(H,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(H,"href","#what-are-default-templates"),m(G,"class","relative group"),m(L,"id","what-template-should-i-use"),m(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"),m(L,"href","#what-template-should-i-use"),m(z,"class","relative group"),m(Je,"href","https://github.com/openai/openai-python/blob/main/chatml.md"),m(Je,"rel","nofollow"),m(Ve,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.ConversationalPipeline"),m(ee,"id","i-want-to-use-chat-templates-how-should-i-get-started"),m(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ee,"href","#i-want-to-use-chat-templates-how-should-i-get-started"),m(B,"class","relative group"),m(Re,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.apply_chat_template"),m(ke,"href","https://huggingface.co/docs/hub/repositories-pull-requests-discussions"),m(ke,"rel","nofollow")},m(e,i){t(document.head,A),p(e,zt,i),p(e,S,i),t(S,W),t(W,Le),f(oe,Le,null),t(S,Ps),t(S,Oe),t(Oe,Xs),p(e,Bt,i),p(e,Q,i),t(Q,V),t(V,Ke),f(ie,Ke,null),t(Q,Ys),t(Q,et),t(et,Hs),p(e,Wt,i),p(e,j,i),t(j,Ds),t(j,tt),t(tt,Ls),t(j,Os),t(j,st),t(st,Ks),t(j,ea),t(j,at),t(at,ta),t(j,sa),p(e,Vt,i),p(e,xe,i),t(xe,aa),p(e,Rt,i),p(e,_e,i),t(_e,la),p(e,qt,i),p(e,R,i),t(R,na),t(R,lt),t(lt,oa),t(R,ia),p(e,Ft,i),p(e,v,i),t(v,ra),t(v,nt),t(nt,pa),t(v,ha),t(v,ot),t(ot,ca),t(v,ma),p(e,Pt,i),p(e,q,i),t(q,da),t(q,it),t(it,ua),t(q,fa),p(e,Xt,i),f(re,e,i),p(e,Yt,i),p(e,U,i),t(U,ya),t(U,rt),t(rt,ga),t(U,wa),t(U,pt),t(pt,Ma),t(U,ja),t(U,pe),t(pe,Ua),t(U,Ja),p(e,Ht,i),f(he,e,i),p(e,Dt,i),p(e,Ne,i),t(Ne,Ta),p(e,Lt,i),p(e,$,i),t($,F),t(F,ht),f(ce,ht,null),t($,ba),t($,ct),t(ct,Ia),p(e,Ot,i),p(e,k,i),t(k,va),t(k,mt),t(mt,ka),t(k,Ca),t(k,dt),t(dt,xa),t(k,_a),p(e,Kt,i),f(me,e,i),p(e,es,i),p(e,C,i),t(C,Na),t(C,ut),t(ut,Ea),t(C,Aa),t(C,ft),t(ft,Sa),t(C,Qa),p(e,ts,i),f(de,e,i),p(e,ss,i),p(e,P,i),t(P,$a),t(P,ue),t(ue,Za),t(P,Ga),p(e,as,i),f(fe,e,i),p(e,ls,i),p(e,Ee,i),t(Ee,za),p(e,ns,i),p(e,x,i),t(x,yt),t(yt,Ba),t(x,Wa),t(x,gt),t(gt,Va),t(x,Ra),t(x,wt),t(wt,qa),p(e,os,i),p(e,Ae,i),t(Ae,Fa),p(e,is,i),f(ye,e,i),p(e,rs,i),p(e,Se,i),t(Se,Pa),p(e,ps,i),p(e,Z,i),t(Z,X),t(X,Mt),f(ge,Mt,null),t(Z,Xa),t(Z,jt),t(jt,Ya),p(e,hs,i),p(e,Y,i),t(Y,Ha),t(Y,Ut),t(Ut,Da),t(Y,La),p(e,cs,i),f(we,e,i),p(e,ms,i),p(e,M,i),t(M,Oa),t(M,Jt),t(Jt,Ka),t(M,el),t(M,Qe),t(Qe,tl),t(M,sl),t(M,Tt),t(Tt,al),t(M,ll),t(M,$e),t($e,nl),t(M,ol),p(e,ds,i),f(Me,e,i),p(e,us,i),p(e,J,i),t(J,il),t(J,Ze),t(Ze,rl),t(J,pl),t(J,Ge),t(Ge,hl),t(J,cl),t(J,ze),t(ze,ml),t(J,dl),p(e,fs,i),p(e,G,i),t(G,H),t(H,bt),f(je,bt,null),t(G,ul),t(G,It),t(It,fl),p(e,ys,i),p(e,T,i),t(T,yl),t(T,vt),t(vt,gl),t(T,wl),t(T,kt),t(kt,Ml),t(T,jl),t(T,Ct),t(Ct,Ul),t(T,Jl),p(e,gs,i),p(e,D,i),t(D,Tl),t(D,xt),t(xt,bl),t(D,Il),p(e,ws,i),p(e,z,i),t(z,L),t(L,_t),f(Ue,_t,null),t(z,vl),t(z,Nt),t(Nt,kl),p(e,Ms,i),p(e,Be,i),t(Be,Cl),p(e,js,i),p(e,O,i),t(O,xl),t(O,Je),t(Je,_l),t(O,Nl),p(e,Us,i),f(Te,e,i),p(e,Js,i),p(e,We,i),t(We,El),p(e,Ts,i),f(be,e,i),p(e,bs,i),p(e,_,i),t(_,Al),t(_,Et),t(Et,Sl),t(_,Ql),t(_,At),t(At,$l),t(_,Zl),p(e,Is,i),f(Ie,e,i),p(e,vs,i),p(e,K,i),t(K,Gl),t(K,Ve),t(Ve,zl),t(K,Bl),p(e,ks,i),p(e,B,i),t(B,ee),t(ee,St),f(ve,St,null),t(B,Wl),t(B,Qt),t(Qt,Vl),p(e,Cs,i),p(e,b,i),t(b,Rl),t(b,$t),t($t,ql),t(b,Fl),t(b,Re),t(Re,Pl),t(b,Xl),t(b,ke),t(ke,Yl),t(b,Hl),p(e,xs,i),p(e,N,i),t(N,Dl),t(N,Zt),t(Zt,Ll),t(N,Ol),t(N,Gt),t(Gt,Kl),t(N,en),p(e,_s,i),p(e,qe,i),t(qe,tn),Ns=!0},p:bo,i(e){Ns||(y(oe.$$.fragment,e),y(ie.$$.fragment,e),y(re.$$.fragment,e),y(he.$$.fragment,e),y(ce.$$.fragment,e),y(me.$$.fragment,e),y(de.$$.fragment,e),y(fe.$$.fragment,e),y(ye.$$.fragment,e),y(ge.$$.fragment,e),y(we.$$.fragment,e),y(Me.$$.fragment,e),y(je.$$.fragment,e),y(Ue.$$.fragment,e),y(Te.$$.fragment,e),y(be.$$.fragment,e),y(Ie.$$.fragment,e),y(ve.$$.fragment,e),Ns=!0)},o(e){g(oe.$$.fragment,e),g(ie.$$.fragment,e),g(re.$$.fragment,e),g(he.$$.fragment,e),g(ce.$$.fragment,e),g(me.$$.fragment,e),g(de.$$.fragment,e),g(fe.$$.fragment,e),g(ye.$$.fragment,e),g(ge.$$.fragment,e),g(we.$$.fragment,e),g(Me.$$.fragment,e),g(je.$$.fragment,e),g(Ue.$$.fragment,e),g(Te.$$.fragment,e),g(be.$$.fragment,e),g(Ie.$$.fragment,e),g(ve.$$.fragment,e),Ns=!1},d(e){s(A),e&&s(zt),e&&s(S),w(oe),e&&s(Bt),e&&s(Q),w(ie),e&&s(Wt),e&&s(j),e&&s(Vt),e&&s(xe),e&&s(Rt),e&&s(_e),e&&s(qt),e&&s(R),e&&s(Ft),e&&s(v),e&&s(Pt),e&&s(q),e&&s(Xt),w(re,e),e&&s(Yt),e&&s(U),e&&s(Ht),w(he,e),e&&s(Dt),e&&s(Ne),e&&s(Lt),e&&s($),w(ce),e&&s(Ot),e&&s(k),e&&s(Kt),w(me,e),e&&s(es),e&&s(C),e&&s(ts),w(de,e),e&&s(ss),e&&s(P),e&&s(as),w(fe,e),e&&s(ls),e&&s(Ee),e&&s(ns),e&&s(x),e&&s(os),e&&s(Ae),e&&s(is),w(ye,e),e&&s(rs),e&&s(Se),e&&s(ps),e&&s(Z),w(ge),e&&s(hs),e&&s(Y),e&&s(cs),w(we,e),e&&s(ms),e&&s(M),e&&s(ds),w(Me,e),e&&s(us),e&&s(J),e&&s(fs),e&&s(G),w(je),e&&s(ys),e&&s(T),e&&s(gs),e&&s(D),e&&s(ws),e&&s(z),w(Ue),e&&s(Ms),e&&s(Be),e&&s(js),e&&s(O),e&&s(Us),w(Te,e),e&&s(Js),e&&s(We),e&&s(Ts),w(be,e),e&&s(bs),e&&s(_),e&&s(Is),w(Ie,e),e&&s(vs),e&&s(K),e&&s(ks),e&&s(B),w(ve),e&&s(Cs),e&&s(b),e&&s(xs),e&&s(N),e&&s(_s),e&&s(qe)}}}const ko={local:"templates-for-chat-models",sections:[{local:"introduction",title:"Introduction"},{local:"how-do-chat-templates-work",title:"How do chat templates work?"},{local:"how-do-i-create-a-chat-template",title:"How do I create a chat template?"},{local:"what-are-default-templates",title:'What are "default" templates?'},{local:"what-template-should-i-use",title:"What template should I use?"},{local:"i-want-to-use-chat-templates-how-should-i-get-started",title:"I want to use chat templates! How should I get started?"}],title:"Templates for Chat Models"};function Co(sn){return Io(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Eo extends jo{constructor(A){super();Uo(this,A,Co,vo,Jo,{})}}export{Eo as default,ko as metadata};
