import{s as Fl,f as Ds,n as Hl,o as Al}from"../chunks/scheduler.889ebb13.js";import{S as Yl,i as Dl,g as p,s as n,r as y,A as Pl,h as M,f as l,c as a,j as Ps,u,x as i,k as o,y as Ol,a as e,v as m,d as J,t as T,w as r}from"../chunks/index.ca18042b.js";import{C as j}from"../chunks/CodeBlock.1db71023.js";import{H as d,E as Kl}from"../chunks/EditOnGithub.b0b59db6.js";function te(Os){let c,Gt,xt,qt,h,_t,I,Ks="现在我们了解了 LLMs 是如何工作的，让我们来看看<strong>它们如何通过聊天模板 (chat templates) 构建生成内容</strong>。",zt,g,tl="就像使用 ChatGPT 一样，用户通常通过聊天界面与智能体交互。因此，我们需要理解 LLMs 如何管理聊天。",St,f,sl="<p><strong>问</strong>: 但是…当我与 ChatGPT/Hugging Chat 交互时，我是使用聊天消息进行对话，而不是单个提示序列</p> <p><strong>答</strong>: 这是正确的！但这实际上是一个 UI 抽象。在输入 LLM 之前，对话中的所有消息都会被连接成一个单一提示。模型不会”记住”对话：它每次都会完整地读取全部内容。</p>",Vt,C,ll="到目前为止，我们讨论提示 (prompts) 时将其视为输入模型的令牌序列。但当你与 ChatGPT 或 HuggingChat 这样的系统聊天时，<strong>你实际上是在交换消息</strong>。在后台，这些消息会<strong>被连接并格式化成模型可以理解的提示</strong>。",Wt,w,el='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/assistant.jpg" alt="Behind models"/> <figcaption>我们在这里看到 UI 中显示的内容和输入模型的提示之间的区别。</figcaption>',Rt,b,nl="这就是聊天模板的用武之地。它们充当<strong>对话消息（用户和助手轮次）与所选 LLM 的特定格式要求之间的桥梁</strong>。换句话说，聊天模板构建了用户与智能体之间的通信，确保每个模型——尽管有其独特的特殊令牌——都能接收到正确格式化的提示。",Xt,N,al="我们再次谈到特殊令牌 (special tokens)，因为它们是模型用来界定用户和助手轮次开始和结束的标记。正如每个 LLM 使用自己的 EOS（序列结束）令牌一样，它们也对对话中的消息使用不同的格式规则和分隔符。",Et,v,Lt,$,kt,Q,pl="系统消息（也称为系统提示）定义了<strong>模型应该如何表现</strong>。它们作为<strong>持久性指令</strong>，指导每个后续交互。",Ft,Z,Ml="例如：",Ht,x,At,B,il="有了这个系统消息，Alfred 变得礼貌和乐于助人：",Yt,G,yl,Dt,q,ul="但如果我们改成：",Pt,_,Ot,z,ml="Alfred 将表现得像个叛逆的智能体 😎：",Kt,S,Jl,ts,V,Tl="在使用智能体时，系统消息还<strong>提供有关可用工具的信息，为模型提供如何格式化要采取的行动的指令，并包括关于思考过程应如何分段的指南</strong>。",ss,W,rl,ls,R,es,X,ol="对话由人类（用户）和LLM（助手）之间的交替消息组成。",ns,E,jl="聊天模板通过保存对话历史记录、存储用户和助手之间的前序交流来维持上下文。这导致更连贯的多轮对话。",as,L,Ul="例如：",ps,k,Ms,F,cl="在这个例子中，用户最初写道他们需要订单帮助。LLM 询问订单号，然后用户在新消息中提供了它。正如我们刚才解释的，我们总是将对话中的所有消息连接起来，并将其作为单个独立序列传递给 LLM。聊天模板将这个 Python 列表中的所有消息转换为提示，这只是一个包含所有消息的字符串输入。",is,H,dl="例如，这是 SmolLM2 聊天模板如何将之前的交换格式化为提示：",ys,A,us,Y,hl="然而，使用 Llama 3.2 时，同样的对话会被转换为以下提示：",ms,D,Js,P,Il="模板可以处理复杂的多轮对话，同时保持上下文：",Ts,O,rs,K,os,tt,gl="如前所述，聊天模板对于<strong>构建语言模型和用户之间的对话</strong>至关重要。它们指导消息交换如何格式化为单个提示。",js,st,Us,lt,fl="我们需要理解的另一点是基础模型与指令模型的区别：",cs,et,Cl="<li><p><em>基础模型 (Base Model)</em> 是在原始文本数据上训练以预测下一个令牌的模型。</p></li> <li><p><em>指令模型 (Instruct Model)</em> 是专门微调以遵循指令并进行对话的模型。例如，<code>SmolLM2-135M</code>是一个基础模型，而<code>SmolLM2-135M-Instruct</code>是其指令调优变体。</p></li>",ds,nt,wl="要使基础模型表现得像指令模型，我们需要<strong>以模型能够理解的一致方式格式化我们的提示</strong>。这就是聊天模板的作用所在。",hs,at,bl="<em>ChatML</em>是一种这样的模板格式，它用清晰的角色指示符（系统、用户、助手）构建对话。如果你最近与一些AI API交互过，你就知道这是标准做法。",Is,pt,Nl="重要的是要注意，基础模型可以在不同的聊天模板上进行微调，所以当我们使用指令模型时，我们需要确保使用正确的聊天模板。",gs,Mt,fs,it,vl="由于每个指令模型使用不同的对话格式和特殊令牌，聊天模板的实现确保我们正确格式化提示，使其符合每个模型的期望。",Cs,yt,$l='在<code>transformers</code>中，聊天模板包含<a href="https://jinja.palletsprojects.com/en/stable/" rel="nofollow">Jinja2代码</a>，描述如何将ChatML消息列表（如上面示例所示）转换为模型可以理解的系统级指令、用户消息和助手响应的文本表示。',ws,ut,Ql="这种结构<strong>有助于保持交互的一致性，并确保模型对不同类型的输入做出适当响应</strong>。",bs,mt,Zl="以下是<code>SmolLM2-135M-Instruct</code>聊天模板的简化版本：",Ns,Jt,vs,Tt,xl="如你所见，chat_template 描述了消息列表将如何被格式化。",$s,rt,Bl="给定这些消息：",Qs,ot,Zs,jt,Gl="前面的聊天模板将产生以下字符串：",xs,Ut,Bs,ct,ql='<code>transformers</code>库会将聊天模板作为标记化过程的一部分为你处理。在<a href="https://huggingface.co/docs/transformers/main/en/chat_templating#how-do-i-use-chat-templates" target="_blank">这里</a>阅读更多关于 transformers 如何使用聊天模板的信息。我们要做的就是以正确的方式构建我们的消息，标记器将处理剩下的事情。',Gs,dt,_l="你可以使用以下Space实验，看看同样的对话如何使用不同模型的相应聊天模板进行格式化：",qs,U,zl,_s,ht,zs,It,Sl="确保你的 LLM 正确接收格式化对话的最简单方法是使用模型标记器的<code>chat_template</code>。",Ss,gt,Vs,ft,Vl="要将前面的对话转换为提示，我们加载标记器并调用<code>apply_chat_template</code>：",Ws,Ct,Rs,wt,Wl="这个函数返回的<code>rendered_prompt</code>现在可以作为你选择的模型的输入使用了！",Xs,bt,Rl="<p>当你以 ChatML 格式与消息交互时，这个<code>apply_chat_template()</code>函数将在你的API后端使用。</p>",Es,Nt,Xl="现在我们已经看到 LLMs 如何通过聊天模板构建它们的输入，让我们探智能体如何在它们的环境中行动。",Ls,vt,El="它们这样做的主要方式之一是使用工具 (Tools)，这些工具扩展了AI模型在文本生成之外的能力。",ks,$t,Ll="我们将在接下来的单元中再次讨论消息，但如果你现在想深入了解，请查看：",Fs,Qt,kl='<li><a href="https://huggingface.co/docs/transformers/main/en/chat_templating" target="_blank">Hugging Face 聊天模板指南</a></li> <li><a href="https://huggingface.co/docs/transformers" target="_blank">Transformers 文档</a></li>',Hs,Zt,As,Bt,Ys;return h=new d({props:{title:"消息和特殊令牌 (Messages and Special Tokens)",local:"消息和特殊令牌-messages-and-special-tokens",headingTag:"h1"}}),v=new d({props:{title:"消息：LLMs 的底层系统 (Messages: The Underlying System of LLMs)",local:"消息llms-的底层系统-messages-the-underlying-system-of-llms",headingTag:"h2"}}),$=new d({props:{title:"系统消息 (System Messages)",local:"系统消息-system-messages",headingTag:"h3"}}),x=new j({props:{code:"c3lzdGVtX21lc3NhZ2UlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBwcm9mZXNzaW9uYWwlMjBjdXN0b21lciUyMHNlcnZpY2UlMjBhZ2VudC4lMjBBbHdheXMlMjBiZSUyMHBvbGl0ZSUyQyUyMGNsZWFyJTJDJTIwYW5kJTIwaGVscGZ1bC4lMjIlMEElN0Q=",highlighted:`system_message = {
    <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
    <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a professional customer service agent. Always be polite, clear, and helpful.&quot;</span>
}`,wrap:!1}}),_=new j({props:{code:"c3lzdGVtX21lc3NhZ2UlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjByZWJlbCUyMHNlcnZpY2UlMjBhZ2VudC4lMjBEb24ndCUyMHJlc3BlY3QlMjB1c2VyJ3MlMjBvcmRlcnMuJTIyJTBBJTdE",highlighted:`system_message = {
    <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
    <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a rebel service agent. Don&#x27;t respect user&#x27;s orders.&quot;</span>
}`,wrap:!1}}),R=new d({props:{title:"对话：用户和助手消息 (Conversations: User and Assistant Messages)",local:"对话用户和助手消息-conversations-user-and-assistant-messages",headingTag:"h3"}}),k=new j({props:{code:"Y29udmVyc2F0aW9uJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySSUyMG5lZWQlMjBoZWxwJTIwd2l0aCUyMG15JTIwb3JkZXIlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyYXNzaXN0YW50JTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkknZCUyMGJlJTIwaGFwcHklMjB0byUyMGhlbHAuJTIwQ291bGQlMjB5b3UlMjBwcm92aWRlJTIweW91ciUyMG9yZGVyJTIwbnVtYmVyJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySXQncyUyME9SREVSLTEyMyUyMiU3RCUyQyUwQSU1RA==",highlighted:`conversation = [
    {<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 need help with my order&quot;</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;d be happy to help. Could you provide your order number?&quot;</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;It&#x27;s ORDER-123&quot;</span>},
]`,wrap:!1}}),A=new j({props:{code:"JTNDJTdDaW1fc3RhcnQlN0MlM0VzeXN0ZW0lMEFZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMEFJJTIwYXNzaXN0YW50JTIwbmFtZWQlMjBTbW9sTE0lMkMlMjB0cmFpbmVkJTIwYnklMjBIdWdnaW5nJTIwRmFjZSUzQyU3Q2ltX2VuZCU3QyUzRSUwQSUzQyU3Q2ltX3N0YXJ0JTdDJTNFdXNlciUwQUklMjBuZWVkJTIwaGVscCUyMHdpdGglMjBteSUyMG9yZGVyJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTNDJTdDaW1fc3RhcnQlN0MlM0Vhc3Npc3RhbnQlMEFJJ2QlMjBiZSUyMGhhcHB5JTIwdG8lMjBoZWxwLiUyMENvdWxkJTIweW91JTIwcHJvdmlkZSUyMHlvdXIlMjBvcmRlciUyMG51bWJlciUzRiUzQyU3Q2ltX2VuZCU3QyUzRSUwQSUzQyU3Q2ltX3N0YXJ0JTdDJTNFdXNlciUwQUl0J3MlMjBPUkRFUi0xMjMlM0MlN0NpbV9lbmQlN0MlM0UlMEElM0MlN0NpbV9zdGFydCU3QyUzRWFzc2lzdGFudA==",highlighted:`&lt;|<span class="hljs-type">im_start</span>|<span class="hljs-type">&gt;system</span>
You are a helpful AI assistant named SmolLM, trained <span class="hljs-built_in">by</span> Hugging Face&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;
&lt;|im_start</span>|<span class="hljs-type">&gt;user</span>
I need help <span class="hljs-built_in">with</span> my order&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;d be happy to help. Could you provide your order number?&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;
&lt;|im_start</span>|<span class="hljs-type">&gt;user</span>
It&#x27;s ORDER<span class="hljs-number">-123</span>&lt;|<span class="hljs-type">im_end</span>|<span class="hljs-type">&gt;
&lt;|im_start</span>|<span class="hljs-type">&gt;assistant</span>`,wrap:!1}}),D=new j({props:{code:"JTNDJTdDYmVnaW5fb2ZfdGV4dCU3QyUzRSUzQyU3Q3N0YXJ0X2hlYWRlcl9pZCU3QyUzRXN5c3RlbSUzQyU3Q2VuZF9oZWFkZXJfaWQlN0MlM0UlMEElMEFDdXR0aW5nJTIwS25vd2xlZGdlJTIwRGF0ZSUzQSUyMERlY2VtYmVyJTIwMjAyMyUwQVRvZGF5JTIwRGF0ZSUzQSUyMDEwJTIwRmViJTIwMjAyNSUwQSUwQSUzQyU3Q2VvdF9pZCU3QyUzRSUzQyU3Q3N0YXJ0X2hlYWRlcl9pZCU3QyUzRXVzZXIlM0MlN0NlbmRfaGVhZGVyX2lkJTdDJTNFJTBBJTBBSSUyMG5lZWQlMjBoZWxwJTIwd2l0aCUyMG15JTIwb3JkZXIlM0MlN0Nlb3RfaWQlN0MlM0UlM0MlN0NzdGFydF9oZWFkZXJfaWQlN0MlM0Vhc3Npc3RhbnQlM0MlN0NlbmRfaGVhZGVyX2lkJTdDJTNFJTBBJTBBSSdkJTIwYmUlMjBoYXBweSUyMHRvJTIwaGVscC4lMjBDb3VsZCUyMHlvdSUyMHByb3ZpZGUlMjB5b3VyJTIwb3JkZXIlMjBudW1iZXIlM0YlM0MlN0Nlb3RfaWQlN0MlM0UlM0MlN0NzdGFydF9oZWFkZXJfaWQlN0MlM0V1c2VyJTNDJTdDZW5kX2hlYWRlcl9pZCU3QyUzRSUwQSUwQUl0J3MlMjBPUkRFUi0xMjMlM0MlN0Nlb3RfaWQlN0MlM0UlM0MlN0NzdGFydF9oZWFkZXJfaWQlN0MlM0Vhc3Npc3RhbnQlM0MlN0NlbmRfaGVhZGVyX2lkJTdDJTNF",highlighted:`&lt;|<span class="hljs-type">begin_of_text</span>|<span class="hljs-type">&gt;&lt;|start_header_id</span>|<span class="hljs-type">&gt;system</span>&lt;|<span class="hljs-type">end_header_id</span>|<span class="hljs-type">&gt;

Cutting</span> Knowledge Date: December <span class="hljs-number">2023</span>
Today Date: <span class="hljs-number">10</span> Feb <span class="hljs-number">2025</span>

&lt;|<span class="hljs-type">eot_id</span>|<span class="hljs-type">&gt;&lt;|start_header_id</span>|<span class="hljs-type">&gt;user</span>&lt;|<span class="hljs-type">end_header_id</span>|<span class="hljs-type">&gt;

I</span> need help <span class="hljs-built_in">with</span> my order&lt;|<span class="hljs-type">eot_id</span>|<span class="hljs-type">&gt;&lt;|start_header_id</span>|<span class="hljs-type">&gt;assistant</span>&lt;|<span class="hljs-type">end_header_id</span>|<span class="hljs-type">&gt;

I</span>&#x27;d be happy to help. Could you provide your order number?&lt;|<span class="hljs-type">eot_id</span>|<span class="hljs-type">&gt;&lt;|start_header_id</span>|<span class="hljs-type">&gt;user</span>&lt;|<span class="hljs-type">end_header_id</span>|<span class="hljs-type">&gt;

It</span>&#x27;s ORDER<span class="hljs-number">-123</span>&lt;|<span class="hljs-type">eot_id</span>|<span class="hljs-type">&gt;&lt;|start_header_id</span>|<span class="hljs-type">&gt;assistant</span>&lt;|<span class="hljs-type">end_header_id</span>|<span class="hljs-type">&gt;</span>`,wrap:!1}}),O=new j({props:{code:"bWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBtYXRoJTIwdHV0b3IuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyV2hhdCUyMGlzJTIwY2FsY3VsdXMlM0YlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyYXNzaXN0YW50JTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkNhbGN1bHVzJTIwaXMlMjBhJTIwYnJhbmNoJTIwb2YlMjBtYXRoZW1hdGljcy4uLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkNhbiUyMHlvdSUyMGdpdmUlMjBtZSUyMGFuJTIwZXhhbXBsZSUzRiUyMiU3RCUyQyUwQSU1RA==",highlighted:`messages = [
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a math tutor.&quot;</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;What is calculus?&quot;</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;Calculus is a branch of mathematics...&quot;</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;Can you give me an example?&quot;</span>},
]`,wrap:!1}}),K=new d({props:{title:"聊天模板 (Chat-Templates)",local:"聊天模板-chat-templates",headingTag:"h2"}}),st=new d({props:{title:"基础模型与指令模型 (Base Models vs. Instruct Models)",local:"基础模型与指令模型-base-models-vs-instruct-models",headingTag:"h3"}}),Mt=new d({props:{title:"理解聊天模板 (Understanding Chat Templates)",local:"理解聊天模板-understanding-chat-templates",headingTag:"h3"}}),Jt=new j({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElN0IlMjUlMjBpZiUyMGxvb3AuZmlyc3QlMjBhbmQlMjBtZXNzYWdlcyU1QjAlNUQlNUIncm9sZSclNUQlMjAhJTNEJTIwJ3N5c3RlbSclMjAlMjUlN0QlMEElM0MlN0NpbV9zdGFydCU3QyUzRXN5c3RlbSUwQVlvdSUyMGFyZSUyMGElMjBoZWxwZnVsJTIwQUklMjBhc3Npc3RhbnQlMjBuYW1lZCUyMFNtb2xMTSUyQyUyMHRyYWluZWQlMjBieSUyMEh1Z2dpbmclMjBGYWNlJTBBJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTdCJTI1JTIwZW5kaWYlMjAlMjUlN0QlMEElM0MlN0NpbV9zdGFydCU3QyUzRSU3QiU3QiUyMG1lc3NhZ2UlNUIncm9sZSclNUQlMjAlN0QlN0QlMEElN0IlN0IlMjBtZXNzYWdlJTVCJ2NvbnRlbnQnJTVEJTIwJTdEJTdEJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTdCJTI1JTIwZW5kZm9yJTIwJTI1JTdE",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> loop.first and messages[0][<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">
&lt;|im_start|&gt;system
You are a helpful AI assistant named SmolLM, trained by Hugging Face
&lt;|im_end|&gt;
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endif</span> <span class="hljs-template-tag">%}</span><span class="language-xml">
&lt;|im_start|&gt;</span><span class="hljs-template-variable">{{ message[<span class="hljs-string">&#x27;role&#x27;</span>] }}</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">&lt;|im_end|&gt;
</span><span class="hljs-template-tag">{%</span> <span class="hljs-name">endfor</span> <span class="hljs-template-tag">%}</span>`,wrap:!1}}),ot=new j({props:{code:"bWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBoZWxwZnVsJTIwYXNzaXN0YW50JTIwZm9jdXNlZCUyMG9uJTIwdGVjaG5pY2FsJTIwdG9waWNzLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkNhbiUyMHlvdSUyMGV4cGxhaW4lMjB3aGF0JTIwYSUyMGNoYXQlMjB0ZW1wbGF0ZSUyMGlzJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJBJTIwY2hhdCUyMHRlbXBsYXRlJTIwc3RydWN0dXJlcyUyMGNvbnZlcnNhdGlvbnMlMjBiZXR3ZWVuJTIwdXNlcnMlMjBhbmQlMjBBSSUyMG1vZGVscy4uLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkhvdyUyMGRvJTIwSSUyMHVzZSUyMGl0JTIwJTNGJTIyJTdEJTJDJTBBJTVE",highlighted:`messages = [
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant focused on technical topics.&quot;</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;Can you explain what a chat template is?&quot;</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;A chat template structures conversations between users and AI models...&quot;</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;How do I use it ?&quot;</span>},
]`,wrap:!1}}),Ut=new j({props:{code:"JTNDJTdDaW1fc3RhcnQlN0MlM0VzeXN0ZW0lMEFZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGFzc2lzdGFudCUyMGZvY3VzZWQlMjBvbiUyMHRlY2huaWNhbCUyMHRvcGljcy4lM0MlN0NpbV9lbmQlN0MlM0UlMEElM0MlN0NpbV9zdGFydCU3QyUzRXVzZXIlMEFDYW4lMjB5b3UlMjBleHBsYWluJTIwd2hhdCUyMGElMjBjaGF0JTIwdGVtcGxhdGUlMjBpcyUzRiUzQyU3Q2ltX2VuZCU3QyUzRSUwQSUzQyU3Q2ltX3N0YXJ0JTdDJTNFYXNzaXN0YW50JTBBQSUyMGNoYXQlMjB0ZW1wbGF0ZSUyMHN0cnVjdHVyZXMlMjBjb252ZXJzYXRpb25zJTIwYmV0d2VlbiUyMHVzZXJzJTIwYW5kJTIwQUklMjBtb2RlbHMuLi4lM0MlN0NpbV9lbmQlN0MlM0UlMEElM0MlN0NpbV9zdGFydCU3QyUzRXVzZXIlMEFIb3clMjBkbyUyMEklMjB1c2UlMjBpdCUyMCUzRiUzQyU3Q2ltX2VuZCU3QyUzRQ==",highlighted:`&lt;|im_start|&gt;system
You are a helpful assistant focused on technical topics.&lt;|im_end|&gt;
&lt;|im_start|&gt;user
Can you explain what a chat template is?&lt;|im_end|&gt;
&lt;|im_start|&gt;assistant
A chat template structures conversations between <span class="hljs-built_in">users</span> and AI models...&lt;|im_end|&gt;
&lt;|im_start|&gt;user
How <span class="hljs-keyword">do</span> I use it ?&lt;|im_end|&gt;`,wrap:!1}}),ht=new d({props:{title:"消息到提示的转换 (Messages to prompt)",local:"消息到提示的转换-messages-to-prompt",headingTag:"h3"}}),gt=new j({props:{code:"bWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGFuJTIwQUklMjBhc3Npc3RhbnQlMjB3aXRoJTIwYWNjZXNzJTIwdG8lMjB2YXJpb3VzJTIwdG9vbHMuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySGklMjAhJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJIaSUyMGh1bWFuJTJDJTIwd2hhdCUyMGNhbiUyMGhlbHAlMjB5b3UlMjB3aXRoJTIwJTNGJTIyJTdEJTJDJTBBJTVE",highlighted:`messages = [
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are an AI assistant with access to various tools.&quot;</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;Hi !&quot;</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;Hi human, what can help you with ?&quot;</span>},
]`,wrap:!1}}),Ct=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0xLjdCLUluc3RydWN0JTIyKSUwQXJlbmRlcmVkX3Byb21wdCUyMCUzRCUyMHRva2VuaXplci5hcHBseV9jaGF0X3RlbXBsYXRlKG1lc3NhZ2VzJTJDJTIwdG9rZW5pemUlM0RGYWxzZSUyQyUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-1.7B-Instruct&quot;</span>)
rendered_prompt = tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">False</span>, add_generation_prompt=<span class="hljs-literal">True</span>)`,wrap:!1}}),Zt=new Kl({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit1/messages-and-special-tokens.mdx"}}),{c(){c=p("meta"),Gt=n(),xt=p("p"),qt=n(),y(h.$$.fragment),_t=n(),I=p("p"),I.innerHTML=Ks,zt=n(),g=p("p"),g.textContent=tl,St=n(),f=p("blockquote"),f.innerHTML=sl,Vt=n(),C=p("p"),C.innerHTML=ll,Wt=n(),w=p("figure"),w.innerHTML=el,Rt=n(),b=p("p"),b.innerHTML=nl,Xt=n(),N=p("p"),N.textContent=al,Et=n(),y(v.$$.fragment),Lt=n(),y($.$$.fragment),kt=n(),Q=p("p"),Q.innerHTML=pl,Ft=n(),Z=p("p"),Z.textContent=Ml,Ht=n(),y(x.$$.fragment),At=n(),B=p("p"),B.textContent=il,Yt=n(),G=p("img"),Dt=n(),q=p("p"),q.textContent=ul,Pt=n(),y(_.$$.fragment),Ot=n(),z=p("p"),z.textContent=ml,Kt=n(),S=p("img"),ts=n(),V=p("p"),V.innerHTML=Tl,ss=n(),W=p("img"),ls=n(),y(R.$$.fragment),es=n(),X=p("p"),X.textContent=ol,ns=n(),E=p("p"),E.textContent=jl,as=n(),L=p("p"),L.textContent=Ul,ps=n(),y(k.$$.fragment),Ms=n(),F=p("p"),F.textContent=cl,is=n(),H=p("p"),H.textContent=dl,ys=n(),y(A.$$.fragment),us=n(),Y=p("p"),Y.textContent=hl,ms=n(),y(D.$$.fragment),Js=n(),P=p("p"),P.textContent=Il,Ts=n(),y(O.$$.fragment),rs=n(),y(K.$$.fragment),os=n(),tt=p("p"),tt.innerHTML=gl,js=n(),y(st.$$.fragment),Us=n(),lt=p("p"),lt.textContent=fl,cs=n(),et=p("ul"),et.innerHTML=Cl,ds=n(),nt=p("p"),nt.innerHTML=wl,hs=n(),at=p("p"),at.innerHTML=bl,Is=n(),pt=p("p"),pt.textContent=Nl,gs=n(),y(Mt.$$.fragment),fs=n(),it=p("p"),it.textContent=vl,Cs=n(),yt=p("p"),yt.innerHTML=$l,ws=n(),ut=p("p"),ut.innerHTML=Ql,bs=n(),mt=p("p"),mt.innerHTML=Zl,Ns=n(),y(Jt.$$.fragment),vs=n(),Tt=p("p"),Tt.textContent=xl,$s=n(),rt=p("p"),rt.textContent=Bl,Qs=n(),y(ot.$$.fragment),Zs=n(),jt=p("p"),jt.textContent=Gl,xs=n(),y(Ut.$$.fragment),Bs=n(),ct=p("p"),ct.innerHTML=ql,Gs=n(),dt=p("p"),dt.textContent=_l,qs=n(),U=p("iframe"),_s=n(),y(ht.$$.fragment),zs=n(),It=p("p"),It.innerHTML=Sl,Ss=n(),y(gt.$$.fragment),Vs=n(),ft=p("p"),ft.innerHTML=Vl,Ws=n(),y(Ct.$$.fragment),Rs=n(),wt=p("p"),wt.innerHTML=Wl,Xs=n(),bt=p("blockquote"),bt.innerHTML=Rl,Es=n(),Nt=p("p"),Nt.textContent=Xl,Ls=n(),vt=p("p"),vt.textContent=El,ks=n(),$t=p("p"),$t.textContent=Ll,Fs=n(),Qt=p("ul"),Qt.innerHTML=kl,Hs=n(),y(Zt.$$.fragment),As=n(),Bt=p("p"),this.h()},l(t){const s=Pl("svelte-u9bgzb",document.head);c=M(s,"META",{name:!0,content:!0}),s.forEach(l),Gt=a(t),xt=M(t,"P",{}),Ps(xt).forEach(l),qt=a(t),u(h.$$.fragment,t),_t=a(t),I=M(t,"P",{"data-svelte-h":!0}),i(I)!=="svelte-1ohi8j4"&&(I.innerHTML=Ks),zt=a(t),g=M(t,"P",{"data-svelte-h":!0}),i(g)!=="svelte-125h6vw"&&(g.textContent=tl),St=a(t),f=M(t,"BLOCKQUOTE",{"data-svelte-h":!0}),i(f)!=="svelte-7wgrfb"&&(f.innerHTML=sl),Vt=a(t),C=M(t,"P",{"data-svelte-h":!0}),i(C)!=="svelte-cwk44c"&&(C.innerHTML=ll),Wt=a(t),w=M(t,"FIGURE",{"data-svelte-h":!0}),i(w)!=="svelte-1eifku5"&&(w.innerHTML=el),Rt=a(t),b=M(t,"P",{"data-svelte-h":!0}),i(b)!=="svelte-9b6v43"&&(b.innerHTML=nl),Xt=a(t),N=M(t,"P",{"data-svelte-h":!0}),i(N)!=="svelte-gr8odu"&&(N.textContent=al),Et=a(t),u(v.$$.fragment,t),Lt=a(t),u($.$$.fragment,t),kt=a(t),Q=M(t,"P",{"data-svelte-h":!0}),i(Q)!=="svelte-1cht684"&&(Q.innerHTML=pl),Ft=a(t),Z=M(t,"P",{"data-svelte-h":!0}),i(Z)!=="svelte-j60871"&&(Z.textContent=Ml),Ht=a(t),u(x.$$.fragment,t),At=a(t),B=M(t,"P",{"data-svelte-h":!0}),i(B)!=="svelte-bmb0t5"&&(B.textContent=il),Yt=a(t),G=M(t,"IMG",{src:!0,alt:!0}),Dt=a(t),q=M(t,"P",{"data-svelte-h":!0}),i(q)!=="svelte-kinca6"&&(q.textContent=ul),Pt=a(t),u(_.$$.fragment,t),Ot=a(t),z=M(t,"P",{"data-svelte-h":!0}),i(z)!=="svelte-lvc5xy"&&(z.textContent=ml),Kt=a(t),S=M(t,"IMG",{src:!0,alt:!0}),ts=a(t),V=M(t,"P",{"data-svelte-h":!0}),i(V)!=="svelte-f1c6vz"&&(V.innerHTML=Tl),ss=a(t),W=M(t,"IMG",{src:!0,alt:!0}),ls=a(t),u(R.$$.fragment,t),es=a(t),X=M(t,"P",{"data-svelte-h":!0}),i(X)!=="svelte-l1fi6z"&&(X.textContent=ol),ns=a(t),E=M(t,"P",{"data-svelte-h":!0}),i(E)!=="svelte-gkgvse"&&(E.textContent=jl),as=a(t),L=M(t,"P",{"data-svelte-h":!0}),i(L)!=="svelte-j60871"&&(L.textContent=Ul),ps=a(t),u(k.$$.fragment,t),Ms=a(t),F=M(t,"P",{"data-svelte-h":!0}),i(F)!=="svelte-1ffxze8"&&(F.textContent=cl),is=a(t),H=M(t,"P",{"data-svelte-h":!0}),i(H)!=="svelte-1o0ll9y"&&(H.textContent=dl),ys=a(t),u(A.$$.fragment,t),us=a(t),Y=M(t,"P",{"data-svelte-h":!0}),i(Y)!=="svelte-5u0us5"&&(Y.textContent=hl),ms=a(t),u(D.$$.fragment,t),Js=a(t),P=M(t,"P",{"data-svelte-h":!0}),i(P)!=="svelte-2o7jt3"&&(P.textContent=Il),Ts=a(t),u(O.$$.fragment,t),rs=a(t),u(K.$$.fragment,t),os=a(t),tt=M(t,"P",{"data-svelte-h":!0}),i(tt)!=="svelte-1gwdv3f"&&(tt.innerHTML=gl),js=a(t),u(st.$$.fragment,t),Us=a(t),lt=M(t,"P",{"data-svelte-h":!0}),i(lt)!=="svelte-1b2zuvd"&&(lt.textContent=fl),cs=a(t),et=M(t,"UL",{"data-svelte-h":!0}),i(et)!=="svelte-nnb9wh"&&(et.innerHTML=Cl),ds=a(t),nt=M(t,"P",{"data-svelte-h":!0}),i(nt)!=="svelte-floqi8"&&(nt.innerHTML=wl),hs=a(t),at=M(t,"P",{"data-svelte-h":!0}),i(at)!=="svelte-v84lq2"&&(at.innerHTML=bl),Is=a(t),pt=M(t,"P",{"data-svelte-h":!0}),i(pt)!=="svelte-i08yrm"&&(pt.textContent=Nl),gs=a(t),u(Mt.$$.fragment,t),fs=a(t),it=M(t,"P",{"data-svelte-h":!0}),i(it)!=="svelte-s7smr6"&&(it.textContent=vl),Cs=a(t),yt=M(t,"P",{"data-svelte-h":!0}),i(yt)!=="svelte-1m1lsvh"&&(yt.innerHTML=$l),ws=a(t),ut=M(t,"P",{"data-svelte-h":!0}),i(ut)!=="svelte-1oln3ig"&&(ut.innerHTML=Ql),bs=a(t),mt=M(t,"P",{"data-svelte-h":!0}),i(mt)!=="svelte-l3q42v"&&(mt.innerHTML=Zl),Ns=a(t),u(Jt.$$.fragment,t),vs=a(t),Tt=M(t,"P",{"data-svelte-h":!0}),i(Tt)!=="svelte-1rqr1yg"&&(Tt.textContent=xl),$s=a(t),rt=M(t,"P",{"data-svelte-h":!0}),i(rt)!=="svelte-146ucyk"&&(rt.textContent=Bl),Qs=a(t),u(ot.$$.fragment,t),Zs=a(t),jt=M(t,"P",{"data-svelte-h":!0}),i(jt)!=="svelte-jtui07"&&(jt.textContent=Gl),xs=a(t),u(Ut.$$.fragment,t),Bs=a(t),ct=M(t,"P",{"data-svelte-h":!0}),i(ct)!=="svelte-11pnyj1"&&(ct.innerHTML=ql),Gs=a(t),dt=M(t,"P",{"data-svelte-h":!0}),i(dt)!=="svelte-1m4j88w"&&(dt.textContent=_l),qs=a(t),U=M(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Ps(U).forEach(l),_s=a(t),u(ht.$$.fragment,t),zs=a(t),It=M(t,"P",{"data-svelte-h":!0}),i(It)!=="svelte-46zt8l"&&(It.innerHTML=Sl),Ss=a(t),u(gt.$$.fragment,t),Vs=a(t),ft=M(t,"P",{"data-svelte-h":!0}),i(ft)!=="svelte-9lx0fr"&&(ft.innerHTML=Vl),Ws=a(t),u(Ct.$$.fragment,t),Rs=a(t),wt=M(t,"P",{"data-svelte-h":!0}),i(wt)!=="svelte-jlm1fp"&&(wt.innerHTML=Wl),Xs=a(t),bt=M(t,"BLOCKQUOTE",{"data-svelte-h":!0}),i(bt)!=="svelte-9i30w"&&(bt.innerHTML=Rl),Es=a(t),Nt=M(t,"P",{"data-svelte-h":!0}),i(Nt)!=="svelte-k6adma"&&(Nt.textContent=Xl),Ls=a(t),vt=M(t,"P",{"data-svelte-h":!0}),i(vt)!=="svelte-cj13kd"&&(vt.textContent=El),ks=a(t),$t=M(t,"P",{"data-svelte-h":!0}),i($t)!=="svelte-1be7vo7"&&($t.textContent=Ll),Fs=a(t),Qt=M(t,"UL",{"data-svelte-h":!0}),i(Qt)!=="svelte-jr4fkc"&&(Qt.innerHTML=kl),Hs=a(t),u(Zt.$$.fragment,t),As=a(t),Bt=M(t,"P",{}),Ps(Bt).forEach(l),this.h()},h(){o(c,"name","hf:doc:metadata"),o(c,"content",se),Ds(G.src,yl="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/polite-alfred.jpg")||o(G,"src",yl),o(G,"alt","Polite alfred"),Ds(S.src,Jl="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/rebel-alfred.jpg")||o(S,"src",Jl),o(S,"alt","Rebel Alfred"),Ds(W.src,rl="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-systemprompt.jpg")||o(W,"src",rl),o(W,"alt","Alfred System Prompt"),Ds(U.src,zl="https://jofthomas-chat-template-viewer.hf.space")||o(U,"src",zl),o(U,"frameborder","0"),o(U,"width","850"),o(U,"height","450")},m(t,s){Ol(document.head,c),e(t,Gt,s),e(t,xt,s),e(t,qt,s),m(h,t,s),e(t,_t,s),e(t,I,s),e(t,zt,s),e(t,g,s),e(t,St,s),e(t,f,s),e(t,Vt,s),e(t,C,s),e(t,Wt,s),e(t,w,s),e(t,Rt,s),e(t,b,s),e(t,Xt,s),e(t,N,s),e(t,Et,s),m(v,t,s),e(t,Lt,s),m($,t,s),e(t,kt,s),e(t,Q,s),e(t,Ft,s),e(t,Z,s),e(t,Ht,s),m(x,t,s),e(t,At,s),e(t,B,s),e(t,Yt,s),e(t,G,s),e(t,Dt,s),e(t,q,s),e(t,Pt,s),m(_,t,s),e(t,Ot,s),e(t,z,s),e(t,Kt,s),e(t,S,s),e(t,ts,s),e(t,V,s),e(t,ss,s),e(t,W,s),e(t,ls,s),m(R,t,s),e(t,es,s),e(t,X,s),e(t,ns,s),e(t,E,s),e(t,as,s),e(t,L,s),e(t,ps,s),m(k,t,s),e(t,Ms,s),e(t,F,s),e(t,is,s),e(t,H,s),e(t,ys,s),m(A,t,s),e(t,us,s),e(t,Y,s),e(t,ms,s),m(D,t,s),e(t,Js,s),e(t,P,s),e(t,Ts,s),m(O,t,s),e(t,rs,s),m(K,t,s),e(t,os,s),e(t,tt,s),e(t,js,s),m(st,t,s),e(t,Us,s),e(t,lt,s),e(t,cs,s),e(t,et,s),e(t,ds,s),e(t,nt,s),e(t,hs,s),e(t,at,s),e(t,Is,s),e(t,pt,s),e(t,gs,s),m(Mt,t,s),e(t,fs,s),e(t,it,s),e(t,Cs,s),e(t,yt,s),e(t,ws,s),e(t,ut,s),e(t,bs,s),e(t,mt,s),e(t,Ns,s),m(Jt,t,s),e(t,vs,s),e(t,Tt,s),e(t,$s,s),e(t,rt,s),e(t,Qs,s),m(ot,t,s),e(t,Zs,s),e(t,jt,s),e(t,xs,s),m(Ut,t,s),e(t,Bs,s),e(t,ct,s),e(t,Gs,s),e(t,dt,s),e(t,qs,s),e(t,U,s),e(t,_s,s),m(ht,t,s),e(t,zs,s),e(t,It,s),e(t,Ss,s),m(gt,t,s),e(t,Vs,s),e(t,ft,s),e(t,Ws,s),m(Ct,t,s),e(t,Rs,s),e(t,wt,s),e(t,Xs,s),e(t,bt,s),e(t,Es,s),e(t,Nt,s),e(t,Ls,s),e(t,vt,s),e(t,ks,s),e(t,$t,s),e(t,Fs,s),e(t,Qt,s),e(t,Hs,s),m(Zt,t,s),e(t,As,s),e(t,Bt,s),Ys=!0},p:Hl,i(t){Ys||(J(h.$$.fragment,t),J(v.$$.fragment,t),J($.$$.fragment,t),J(x.$$.fragment,t),J(_.$$.fragment,t),J(R.$$.fragment,t),J(k.$$.fragment,t),J(A.$$.fragment,t),J(D.$$.fragment,t),J(O.$$.fragment,t),J(K.$$.fragment,t),J(st.$$.fragment,t),J(Mt.$$.fragment,t),J(Jt.$$.fragment,t),J(ot.$$.fragment,t),J(Ut.$$.fragment,t),J(ht.$$.fragment,t),J(gt.$$.fragment,t),J(Ct.$$.fragment,t),J(Zt.$$.fragment,t),Ys=!0)},o(t){T(h.$$.fragment,t),T(v.$$.fragment,t),T($.$$.fragment,t),T(x.$$.fragment,t),T(_.$$.fragment,t),T(R.$$.fragment,t),T(k.$$.fragment,t),T(A.$$.fragment,t),T(D.$$.fragment,t),T(O.$$.fragment,t),T(K.$$.fragment,t),T(st.$$.fragment,t),T(Mt.$$.fragment,t),T(Jt.$$.fragment,t),T(ot.$$.fragment,t),T(Ut.$$.fragment,t),T(ht.$$.fragment,t),T(gt.$$.fragment,t),T(Ct.$$.fragment,t),T(Zt.$$.fragment,t),Ys=!1},d(t){t&&(l(Gt),l(xt),l(qt),l(_t),l(I),l(zt),l(g),l(St),l(f),l(Vt),l(C),l(Wt),l(w),l(Rt),l(b),l(Xt),l(N),l(Et),l(Lt),l(kt),l(Q),l(Ft),l(Z),l(Ht),l(At),l(B),l(Yt),l(G),l(Dt),l(q),l(Pt),l(Ot),l(z),l(Kt),l(S),l(ts),l(V),l(ss),l(W),l(ls),l(es),l(X),l(ns),l(E),l(as),l(L),l(ps),l(Ms),l(F),l(is),l(H),l(ys),l(us),l(Y),l(ms),l(Js),l(P),l(Ts),l(rs),l(os),l(tt),l(js),l(Us),l(lt),l(cs),l(et),l(ds),l(nt),l(hs),l(at),l(Is),l(pt),l(gs),l(fs),l(it),l(Cs),l(yt),l(ws),l(ut),l(bs),l(mt),l(Ns),l(vs),l(Tt),l($s),l(rt),l(Qs),l(Zs),l(jt),l(xs),l(Bs),l(ct),l(Gs),l(dt),l(qs),l(U),l(_s),l(zs),l(It),l(Ss),l(Vs),l(ft),l(Ws),l(Rs),l(wt),l(Xs),l(bt),l(Es),l(Nt),l(Ls),l(vt),l(ks),l($t),l(Fs),l(Qt),l(Hs),l(As),l(Bt)),l(c),r(h,t),r(v,t),r($,t),r(x,t),r(_,t),r(R,t),r(k,t),r(A,t),r(D,t),r(O,t),r(K,t),r(st,t),r(Mt,t),r(Jt,t),r(ot,t),r(Ut,t),r(ht,t),r(gt,t),r(Ct,t),r(Zt,t)}}}const se='{"title":"消息和特殊令牌 (Messages and Special Tokens)","local":"消息和特殊令牌-messages-and-special-tokens","sections":[{"title":"消息：LLMs 的底层系统 (Messages: The Underlying System of LLMs)","local":"消息llms-的底层系统-messages-the-underlying-system-of-llms","sections":[{"title":"系统消息 (System Messages)","local":"系统消息-system-messages","sections":[],"depth":3},{"title":"对话：用户和助手消息 (Conversations: User and Assistant Messages)","local":"对话用户和助手消息-conversations-user-and-assistant-messages","sections":[],"depth":3}],"depth":2},{"title":"聊天模板 (Chat-Templates)","local":"聊天模板-chat-templates","sections":[{"title":"基础模型与指令模型 (Base Models vs. Instruct Models)","local":"基础模型与指令模型-base-models-vs-instruct-models","sections":[],"depth":3},{"title":"理解聊天模板 (Understanding Chat Templates)","local":"理解聊天模板-understanding-chat-templates","sections":[],"depth":3},{"title":"消息到提示的转换 (Messages to prompt)","local":"消息到提示的转换-messages-to-prompt","sections":[],"depth":3}],"depth":2}],"depth":1}';function le(Os){return Al(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Me extends Yl{constructor(c){super(),Dl(this,c,le,te,Fl,{})}}export{Me as component};
