import{s as ln,n as sn,o as nn}from"../chunks/scheduler.1f027d5a.js";import{S as an,i as pn,e as p,s as n,c as i,h as mn,a as m,d as l,b as a,f as tn,g as o,j as M,k as en,l as Mn,m as s,n as y,t as r,o as u,p as f}from"../chunks/index.6117a65d.js";import{C as on}from"../chunks/CopyLLMTxtMenu.0ff8411a.js";import{D as yn,C as j}from"../chunks/DocNotebookDropdown.316c3715.js";import{H as d,E as rn}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.0eecd2bb.js";function un(es){let b,ie,me,oe,w,ye,c,re,U,ue,J,ls='<em>作者: <a href="https://github.com/peremartra" rel="nofollow">Pere Martra</a></em>',fe,h,ss="在这个 notebook 中，我们将介绍如何使用 PEFT 库对预训练模型进行提示微调。",je,T,ns='要查看与 PEFT 兼容的完整模型列表，请参考他们的<a href="https://huggingface.co/docs/peft/main/en/index#supported-methods" rel="nofollow">文档</a>。',de,$,as="可以使用 PEFT 进行训练的模型示例包括 Bloom、Llama、GPT-J、GPT-2、BERT 等等。Hugging Face 正在努力将更多模型添加到库中。",be,C,we,_,ps="这是一种用于模型的附加微调技术。这意味着我们不会修改原始模型的任何权重。你可能会想，那么我们将如何进行微调呢？好吧，我们将训练添加到模型中的额外层。这就是为什么它被称为附加技术。",ce,Z,ms="考虑到它是一种附加技术，并且它的名字是提示调整，似乎很明显我们将要添加和训练的层与提示有关。",Ue,g,Ms='<img src="https://huggingface.co/datasets/huggingface/cookbook-images/resolve/main/Martra_Figure_5_Prompt_Tuning.jpg" alt="Prompt_Tuning_Diagram"/>',Je,G,is="我们通过使模型能够用其获取的知识增强提示的一部分来创建一种超提示。然而，提示的这部分不能翻译成自然语言。<strong>这就好像我们已经掌握了用嵌入表达自己并生成高效提示的能力。</strong>",he,X,os="在每次训练周期中，唯一可以修改以最小化损失函数的权重是集成到提示中的权重。",Te,W,ys="这种技术的主要结果是，要训练的参数数量确实很少。然而，我们遇到了第二个，也许更重要的结果，即<strong>由于我们不修改预训练模型的权重，它不会改变其行为或忘记它以前学到的任何信息。</strong>",$e,R,rs="训练更快，更具成本效益。此外，我们可以训练各种模型，在推理时，我们只需要加载一个基础模型以及新的较小的训练模型，因为原始模型的权重没有被修改。",Ce,k,_e,V,us="我们将使用两个数据集训练两个不同的模型，每个数据集只使用 Bloom 家族的一个预训练模型。一个模型将使用提示数据集进行训练，而另一个模型将使用激励句子数据集进行训练。我们将比较两个模型在训练前后对同一问题的结果。",Ze,B,fs="此外，我们还将探讨如何只加载基础模型的一个副本到内存中，同时加载两个模型。",ge,v,Ge,I,js="这个库包含了各种微调技术的 Hugging Face 实现，包括提示调整。",Xe,x,We,A,Re,F,ds="从 transformers 库中，我们导入必要的类来实例化模型和分词器。",ke,H,Ve,Y,Be,N,bs="Bloom 是使用 PEFT 库进行提示调整训练的可用模型中最小最智能的模型之一。你可以从 Bloom 家族中选择任何模型，我鼓励你至少尝试其中两个以观察它们之间的差异。",ve,Q,ws="我选择最小的模型以最小化训练时间并避免在 Colab 中出现内存问题。",Ie,z,xe,E,Ae,S,Fe,P,cs="如果你想要实现更多样化和原创的生成，取消注释下面的 <em>model.generate</em> 中的参数：temperature、top_p 和 do_sample。",He,q,Us="在默认配置下，模型的响应在多次调用中保持一致。",Ye,L,Ne,K,Js="由于我们希望有两个不同的训练模型，我将创建两个不同的提示。",Qe,D,hs="第一个模型将使用包含提示的数据集进行训练，第二个模型将使用激励句子的数据集进行训练。",ze,O,Ts="第一个模型将收到提示 “我希望你扮演一个励志教练。“，第二个模型将收到提示 “有两件对你来说很重要的事情：”",Ee,tt,$s="但首先，我要收集一些未经微调的模型的结果。",Se,et,Pe,lt,Cs=`["I want you to act as a motivational coach.  Don't be afraid of being challenged."]
`,qe,st,Le,nt,_s=`['There are two nice things that should matter to you: the price and quality of your product.']
`,Ke,at,Zs="两个答案或多或少都是正确的。任何 Bloom 模型都是预先训练的，能够准确和合理地生成句子。让我们看看，在训练之后，响应是否相等或者生成得更加准确。",De,pt,Oe,mt,gs="使用的数据集包括：",tl,Mt,Gs='<li><a href="https://huggingface.co/datasets/fka/awesome-chatgpt-prompts" rel="nofollow">https://huggingface.co/datasets/fka/awesome-chatgpt-prompts</a></li> <li><a href="https://huggingface.co/datasets/Abirate/english_quotes" rel="nofollow">https://huggingface.co/datasets/Abirate/english_quotes</a></li>',el,it,ll,ot,sl,yt,nl,rt,al,ut,Xs=`&#123;'act': ['Linux Terminal'], 'prompt': ['I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets &#123;like this}. my first command is pwd'], 'input_ids': [[44, 4026, 1152, 427, 1769, 661, 267, 104105, 28434, 17, 473, 2152, 4105, 49123, 530, 1152, 2152, 57502, 1002, 3595, 368, 28434, 3403, 6460, 17, 473, 4026, 1152, 427, 3804, 57502, 1002, 368, 28434, 10014, 14652, 2592, 19826, 4400, 10973, 15, 530, 16915, 4384, 17, 727, 1130, 11602, 184637, 17, 727, 1130, 4105, 49123, 35262, 473, 32247, 1152, 427, 727, 1427, 17, 3262, 707, 3423, 427, 13485, 1152, 7747, 361, 170205, 15, 707, 2152, 727, 1427, 1331, 55385, 5484, 14652, 6291, 999, 117805, 731, 29726, 1119, 96, 17, 2670, 3968, 9361, 632, 269, 42512]], 'attention_mask': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]}
`,pl,ft,ml,jt,Ml,dt,il,bt,ol,wt,Ws=`API 文档：
<a href="https://huggingface.co/docs/peft/main/en/package_reference/tuners#peft.PromptTuningConfig" rel="nofollow">https://huggingface.co/docs/peft/main/en/package_reference/tuners#peft.PromptTuningConfig</a>`,yl,ct,Rs="我们可以对两个要训练的模型使用相同的配置。",rl,Ut,ul,Jt,fl,ht,ks="我们将使用相同的预训练模型和相同的配置来创建两个相同的提示调整模型。",jl,Tt,dl,$t,Vs=`trainable params: 4,096 || all params: 559,218,688 || trainable%: 0.0007324504863471229
None
`,bl,Ct,wl,_t,Bs=`trainable params: 4,096 || all params: 559,218,688 || trainable%: 0.0007324504863471229
None
`,cl,Zt,vs="<strong>太神奇了：你看到可训练参数的减少了吗？我们将要训练可用参数的 0.001%。</strong>",Ul,gt,Is="现在我们要创建训练参数，并且在这两次训练中我们将使用相同的配置。",Jl,Gt,hl,Xt,Tl,Wt,xs="在创建 TrainingArguments 时，我们需要指明包含模型的目录。",$l,Rt,Cl,kt,_l,Vt,As="我们将为每个要训练的模型创建一个 trainer 对象。",Zl,Bt,gl,vt,Gl,It,Xl,xt,Fs="在不到 10 分钟的时间内（在 M1 Pro上的 CPU 时间），我们使用同一个基础模型训练了两个不同任务的模型。",Wl,At,Rl,Ft,Hs="我们将要保存模型。只要我们有创建它们的预训练模型在内存中，这些模型就可以使用了。",kl,Ht,Vl,Yt,Bl,Nt,Ys="你可以从之前保存的路径加载模型，并根据我们的输入要求模型生成文本！",vl,Qt,Il,zt,xl,Et,Ns=`['I want you to act as a motivational coach.  You will be helping students learn how they can improve their performance in the classroom and at school.']
`,Al,St,Qs="如果我们比较两个答案，有些东西改变了。",Fl,Pt,zs="<li><strong><em>预训练模型：</em></strong> <em>我希望你扮演一个激励教练。不要害怕被挑战。</em></li> <li><strong><em>微调模型：</em></strong> <em>我希望你扮演一个激励教练。如果你感到焦虑，你可以使用这个方法。</em></li>",Hl,qt,Es="我们必须记住，我们只训练了模型几分钟，但它们已经足够让我们得到更接近我们想要的结果的响应。",Yl,Lt,Nl,Kt,Ql,Dt,Ss=`['There are two nice things that should matter to you: the weather and your health.']
`,zl,Ot,Ps="对于第二个模型，我们得到了类似的结果。",El,te,qs="<li><strong>预训练模型：</strong> <em>有两件对你来说很重要的事情：你的产品的价格和质量。</em></li> <li><strong>微调模型：</strong> <em>有两件对你来说很重要的事情：天气和你的健康。</em></li>",Sl,ee,Pl,le,Ls="提示微调是一种惊人的技术，可以节省我们数小时的训练时间和大量的金钱。在这个 notebook 中，我们只用了几分钟就训练了两个模型，并且我们可以将两个模型都保存在内存中，为不同的客户提供服务。",ql,se,Ks="如果你想要尝试不同的组合和模型，这个 notebook 已经准备好使用 Bloom 家族中的另一个模型。",Ll,ne,Ds="你可以更改训练的轮数、虚拟 token 的数量和第三个单元格中的模型。然而，有许多配置需要更改。如果你正在寻找一个很好的练习，你可以用固定值替换虚拟 token 的随机初始化。",Kl,ae,Os="<em>微调模型的响应可能在每次我们训练它们时都会有所不同。我粘贴了我的一次训练的结果，但实际结果可能会有所不同。</em>",Dl,pe,Ol,Me,ts;return w=new yn({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/zh-CN/prompt_tuning_peft.ipynb"}]}}),c=new on({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),U=new d({props:{title:"使用 PEFT 进行提示微调",local:"使用-peft-进行提示微调",headingTag:"h1"}}),C=new d({props:{title:"提示微调简要介绍",local:"提示微调简要介绍",headingTag:"h2"}}),k=new d({props:{title:"我们将在 notebook 中做什么？",local:"我们将在-notebook-中做什么",headingTag:"h2"}}),v=new d({props:{title:"加载 PEFT 库",local:"加载-peft-库",headingTag:"h2"}}),x=new j({props:{code:"IXBpcCUyMGluc3RhbGwlMjAtcSUyMHBlZnQlM0QlM0QwLjguMg==",highlighted:'!pip install -q peft==<span class="hljs-number">0.8</span><span class="hljs-number">.2</span>',wrap:!1}}),A=new j({props:{code:"IXBpcCUyMGluc3RhbGwlMjAtcSUyMGRhdGFzZXRzJTNEJTNEMi4xNC41",highlighted:'!pip install -q datasets==<span class="hljs-number">2.14</span><span class="hljs-number">.5</span>',wrap:!1}}),H=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplcg==",highlighted:'<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer',wrap:!1}}),Y=new d({props:{title:"加载模型和分词器。",local:"加载模型和分词器",headingTag:"h3"}}),z=new j({props:{code:"bW9kZWxfbmFtZSUyMCUzRCUyMCUyMmJpZ3NjaWVuY2UlMkZibG9vbXotNTYwbSUyMiUwQSUyM21vZGVsX25hbWUlM0QlMjJiaWdzY2llbmNlJTJGYmxvb20tMWIxJTIyJTBBTlVNX1ZJUlRVQUxfVE9LRU5TJTIwJTNEJTIwNCUwQU5VTV9FUE9DSFMlMjAlM0QlMjA2",highlighted:`model_name = <span class="hljs-string">&quot;bigscience/bloomz-560m&quot;</span>
<span class="hljs-comment">#model_name=&quot;bigscience/bloom-1b1&quot;</span>
NUM_VIRTUAL_TOKENS = <span class="hljs-number">4</span>
NUM_EPOCHS = <span class="hljs-number">6</span>`,wrap:!1}}),E=new j({props:{code:"dG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQobW9kZWxfbmFtZSklMEFmb3VuZGF0aW9uYWxfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfbmFtZSUyQyUwQSUyMCUyMCUyMCUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSUwQSk=",highlighted:`tokenizer = AutoTokenizer.from_pretrained(model_name)
foundational_model = AutoModelForCausalLM.from_pretrained(
    model_name,
    trust_remote_code=<span class="hljs-literal">True</span>
)`,wrap:!1}}),S=new d({props:{title:"使用预训练的 bloom 模型进行推理",local:"使用预训练的-bloom-模型进行推理",headingTag:"h2"}}),L=new j({props:{code:"JTIzdGhpcyUyMGZ1bmN0aW9uJTIwcmV0dXJucyUyMHRoZSUyMG91dHB1dHMlMjBmcm9tJTIwdGhlJTIwbW9kZWwlMjByZWNlaXZlZCUyQyUyMGFuZCUyMGlucHV0cy4lMEFkZWYlMjBnZXRfb3V0cHV0cyhtb2RlbCUyQyUyMGlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTAwKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnB1dF9pZHMlM0RpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhdHRlbnRpb25fbWFzayUzRGlucHV0cyU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0RtYXhfbmV3X3Rva2VucyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyM3RlbXBlcmF0dXJlJTNEMC4yJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzdG9wX3AlM0QwLjk1JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzZG9fc2FtcGxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcGV0aXRpb25fcGVuYWx0eSUzRDEuNSUyQyUyMCUyM0F2b2lkJTIwcmVwZXRpdGlvbi4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlYXJseV9zdG9wcGluZyUzRFRydWUlMkMlMjAlMjNUaGUlMjBtb2RlbCUyMGNhbiUyMHN0b3AlMjBiZWZvcmUlMjByZWFjaCUyMHRoZSUyMG1heF9sZW5ndGglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlb3NfdG9rZW5faWQlM0R0b2tlbml6ZXIuZW9zX3Rva2VuX2lkJTBBJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMG91dHB1dHM=",highlighted:`<span class="hljs-comment">#this function returns the outputs from the model received, and inputs.</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_outputs</span>(<span class="hljs-params">model, inputs, max_new_tokens=<span class="hljs-number">100</span></span>):
    outputs = model.generate(
        input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>],
        attention_mask=inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>],
        max_new_tokens=max_new_tokens,
        <span class="hljs-comment">#temperature=0.2,</span>
        <span class="hljs-comment">#top_p=0.95,</span>
        <span class="hljs-comment">#do_sample=True,</span>
        repetition_penalty=<span class="hljs-number">1.5</span>, <span class="hljs-comment">#Avoid repetition.</span>
        early_stopping=<span class="hljs-literal">True</span>, <span class="hljs-comment">#The model can stop before reach the max_length</span>
        eos_token_id=tokenizer.eos_token_id
    )
    <span class="hljs-keyword">return</span> outputs`,wrap:!1}}),et=new j({props:{code:"aW5wdXRfcHJvbXB0JTIwJTNEJTIwdG9rZW5pemVyKCUyMkklMjB3YW50JTIweW91JTIwdG8lMjBhY3QlMjBhcyUyMGElMjBtb3RpdmF0aW9uYWwlMjBjb2FjaC4lMjAlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQWZvdW5kYXRpb25hbF9vdXRwdXRzX3Byb21wdCUyMCUzRCUyMGdldF9vdXRwdXRzKGZvdW5kYXRpb25hbF9tb2RlbCUyQyUyMGlucHV0X3Byb21wdCUyQyUyMG1heF9uZXdfdG9rZW5zJTNENTApJTBBJTBBcHJpbnQodG9rZW5pemVyLmJhdGNoX2RlY29kZShmb3VuZGF0aW9uYWxfb3V0cHV0c19wcm9tcHQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>input_prompt = tokenizer(<span class="hljs-string">&quot;I want you to act as a motivational coach. &quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>foundational_outputs_prompt = get_outputs(foundational_model, input_prompt, max_new_tokens=<span class="hljs-number">50</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(foundational_outputs_prompt, skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),st=new j({props:{code:"aW5wdXRfc2VudGVuY2VzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoZXJlJTIwYXJlJTIwdHdvJTIwbmljZSUyMHRoaW5ncyUyMHRoYXQlMjBzaG91bGQlMjBtYXR0ZXIlMjB0byUyMHlvdSUzQSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBZm91bmRhdGlvbmFsX291dHB1dHNfc2VudGVuY2UlMjAlM0QlMjBnZXRfb3V0cHV0cyhmb3VuZGF0aW9uYWxfbW9kZWwlMkMlMjBpbnB1dF9zZW50ZW5jZXMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDUwKSUwQSUwQXByaW50KHRva2VuaXplci5iYXRjaF9kZWNvZGUoZm91bmRhdGlvbmFsX291dHB1dHNfc2VudGVuY2UlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>input_sentences = tokenizer(<span class="hljs-string">&quot;There are two nice things that should matter to you:&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>foundational_outputs_sentence = get_outputs(foundational_model, input_sentences, max_new_tokens=<span class="hljs-number">50</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(foundational_outputs_sentence, skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),pt=new d({props:{title:"准备数据集",local:"准备数据集",headingTag:"h2"}}),it=new j({props:{code:"aW1wb3J0JTIwb3MlMEElMjNvcy5lbnZpcm9uJTVCJTIyVE9LRU5JWkVSU19QQVJBTExFTElTTSUyMiU1RCUyMCUzRCUyMCUyMmZhbHNlJTIy",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-comment">#os.environ[&quot;TOKENIZERS_PARALLELISM&quot;] = &quot;false&quot;</span>`,wrap:!1}}),ot=new j({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldF9wcm9tcHQlMjAlM0QlMjAlMjJma2ElMkZhd2Vzb21lLWNoYXRncHQtcHJvbXB0cyUyMiUwQSUwQSUyM0NyZWF0ZSUyMHRoZSUyMERhdGFzZXQlMjB0byUyMGNyZWF0ZSUyMHByb21wdHMuJTBBZGF0YV9wcm9tcHQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoZGF0YXNldF9wcm9tcHQpJTBBZGF0YV9wcm9tcHQlMjAlM0QlMjBkYXRhX3Byb21wdC5tYXAobGFtYmRhJTIwc2FtcGxlcyUzQSUyMHRva2VuaXplcihzYW1wbGVzJTVCJTIycHJvbXB0JTIyJTVEKSUyQyUyMGJhdGNoZWQlM0RUcnVlKSUwQXRyYWluX3NhbXBsZV9wcm9tcHQlMjAlM0QlMjBkYXRhX3Byb21wdCU1QiUyMnRyYWluJTIyJTVELnNlbGVjdChyYW5nZSg1MCkp",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset_prompt = <span class="hljs-string">&quot;fka/awesome-chatgpt-prompts&quot;</span>

<span class="hljs-comment">#Create the Dataset to create prompts.</span>
data_prompt = load_dataset(dataset_prompt)
data_prompt = data_prompt.<span class="hljs-built_in">map</span>(<span class="hljs-keyword">lambda</span> samples: tokenizer(samples[<span class="hljs-string">&quot;prompt&quot;</span>]), batched=<span class="hljs-literal">True</span>)
train_sample_prompt = data_prompt[<span class="hljs-string">&quot;train&quot;</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">50</span>))`,wrap:!1}}),yt=new j({props:{code:"ZGlzcGxheSh0cmFpbl9zYW1wbGVfcHJvbXB0KQ==",highlighted:"display(train_sample_prompt)",wrap:!1}}),rt=new j({props:{code:"cHJpbnQodHJhaW5fc2FtcGxlX3Byb21wdCU1QiUzQTElNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(train_sample_prompt[:<span class="hljs-number">1</span>])',wrap:!1}}),ft=new j({props:{code:"ZGF0YXNldF9zZW50ZW5jZXMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyQWJpcmF0ZSUyRmVuZ2xpc2hfcXVvdGVzJTIyKSUwQSUwQWRhdGFfc2VudGVuY2VzJTIwJTNEJTIwZGF0YXNldF9zZW50ZW5jZXMubWFwKGxhbWJkYSUyMHNhbXBsZXMlM0ElMjB0b2tlbml6ZXIoc2FtcGxlcyU1QiUyMnF1b3RlJTIyJTVEKSUyQyUyMGJhdGNoZWQlM0RUcnVlKSUwQXRyYWluX3NhbXBsZV9zZW50ZW5jZXMlMjAlM0QlMjBkYXRhX3NlbnRlbmNlcyU1QiUyMnRyYWluJTIyJTVELnNlbGVjdChyYW5nZSgyNSkpJTBBdHJhaW5fc2FtcGxlX3NlbnRlbmNlcyUyMCUzRCUyMHRyYWluX3NhbXBsZV9zZW50ZW5jZXMucmVtb3ZlX2NvbHVtbnMoJTVCJ2F1dGhvciclMkMlMjAndGFncyclNUQp",highlighted:`dataset_sentences = load_dataset(<span class="hljs-string">&quot;Abirate/english_quotes&quot;</span>)

data_sentences = dataset_sentences.<span class="hljs-built_in">map</span>(<span class="hljs-keyword">lambda</span> samples: tokenizer(samples[<span class="hljs-string">&quot;quote&quot;</span>]), batched=<span class="hljs-literal">True</span>)
train_sample_sentences = data_sentences[<span class="hljs-string">&quot;train&quot;</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">25</span>))
train_sample_sentences = train_sample_sentences.remove_columns([<span class="hljs-string">&#x27;author&#x27;</span>, <span class="hljs-string">&#x27;tags&#x27;</span>])`,wrap:!1}}),jt=new j({props:{code:"ZGlzcGxheSh0cmFpbl9zYW1wbGVfc2VudGVuY2VzKQ==",highlighted:"display(train_sample_sentences)",wrap:!1}}),dt=new d({props:{title:"微调",local:"微调",headingTag:"h2"}}),bt=new d({props:{title:"PEFT 配置",local:"peft-配置",headingTag:"h3"}}),Ut=new j({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjAlMjBnZXRfcGVmdF9tb2RlbCUyQyUyMFByb21wdFR1bmluZ0NvbmZpZyUyQyUyMFRhc2tUeXBlJTJDJTIwUHJvbXB0VHVuaW5nSW5pdCUwQSUwQWdlbmVyYXRpb25fY29uZmlnJTIwJTNEJTIwUHJvbXB0VHVuaW5nQ29uZmlnKCUwQSUyMCUyMCUyMCUyMHRhc2tfdHlwZSUzRFRhc2tUeXBlLkNBVVNBTF9MTSUyQyUyMCUyM1RoaXMlMjB0eXBlJTIwaW5kaWNhdGVzJTIwdGhlJTIwbW9kZWwlMjB3aWxsJTIwZ2VuZXJhdGUlMjB0ZXh0LiUwQSUyMCUyMCUyMCUyMHByb21wdF90dW5pbmdfaW5pdCUzRFByb21wdFR1bmluZ0luaXQuUkFORE9NJTJDJTIwJTIwJTIzVGhlJTIwYWRkZWQlMjB2aXJ0dWFsJTIwdG9rZW5zJTIwYXJlJTIwaW5pdGlhbGl6YWQlMjB3aXRoJTIwcmFuZG9tJTIwbnVtYmVycyUwQSUyMCUyMCUyMCUyMG51bV92aXJ0dWFsX3Rva2VucyUzRE5VTV9WSVJUVUFMX1RPS0VOUyUyQyUyMCUyM051bWJlciUyMG9mJTIwdmlydHVhbCUyMHRva2VucyUyMHRvJTIwYmUlMjBhZGRlZCUyMGFuZCUyMHRyYWluZWQuJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyX25hbWVfb3JfcGF0aCUzRG1vZGVsX25hbWUlMjAlMjNUaGUlMjBwcmUtdHJhaW5lZCUyMG1vZGVsLiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span>  get_peft_model, PromptTuningConfig, TaskType, PromptTuningInit

generation_config = PromptTuningConfig(
    task_type=TaskType.CAUSAL_LM, <span class="hljs-comment">#This type indicates the model will generate text.</span>
    prompt_tuning_init=PromptTuningInit.RANDOM,  <span class="hljs-comment">#The added virtual tokens are initializad with random numbers</span>
    num_virtual_tokens=NUM_VIRTUAL_TOKENS, <span class="hljs-comment">#Number of virtual tokens to be added and trained.</span>
    tokenizer_name_or_path=model_name <span class="hljs-comment">#The pre-trained model.</span>
)`,wrap:!1}}),Jt=new d({props:{title:"创建两个提示调整模型。",local:"创建两个提示调整模型",headingTag:"h3"}}),Tt=new j({props:{code:"cGVmdF9tb2RlbF9wcm9tcHQlMjAlM0QlMjBnZXRfcGVmdF9tb2RlbChmb3VuZGF0aW9uYWxfbW9kZWwlMkMlMjBnZW5lcmF0aW9uX2NvbmZpZyklMEFwcmludChwZWZ0X21vZGVsX3Byb21wdC5wcmludF90cmFpbmFibGVfcGFyYW1ldGVycygpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>peft_model_prompt = get_peft_model(foundational_model, generation_config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(peft_model_prompt.print_trainable_parameters())`,wrap:!1}}),Ct=new j({props:{code:"cGVmdF9tb2RlbF9zZW50ZW5jZXMlMjAlM0QlMjBnZXRfcGVmdF9tb2RlbChmb3VuZGF0aW9uYWxfbW9kZWwlMkMlMjBnZW5lcmF0aW9uX2NvbmZpZyklMEFwcmludChwZWZ0X21vZGVsX3NlbnRlbmNlcy5wcmludF90cmFpbmFibGVfcGFyYW1ldGVycygpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>peft_model_sentences = get_peft_model(foundational_model, generation_config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(peft_model_sentences.print_trainable_parameters())`,wrap:!1}}),Gt=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBZGVmJTIwY3JlYXRlX3RyYWluaW5nX2FyZ3VtZW50cyhwYXRoJTJDJTIwbGVhcm5pbmdfcmF0ZSUzRDAuMDAzNSUyQyUyMGVwb2NocyUzRDYpJTNBJTBBJTIwJTIwJTIwJTIwdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0RwYXRoJTJDJTIwJTIzJTIwV2hlcmUlMjB0aGUlMjBtb2RlbCUyMHByZWRpY3Rpb25zJTIwYW5kJTIwY2hlY2twb2ludHMlMjB3aWxsJTIwYmUlMjB3cml0dGVuJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdXNlX2NwdSUzRFRydWUlMkMlMjAlMjMlMjBUaGlzJTIwaXMlMjBuZWNlc3NhcnklMjBmb3IlMjBDUFUlMjBjbHVzdGVycy4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhdXRvX2ZpbmRfYmF0Y2hfc2l6ZSUzRFRydWUlMkMlMjAlMjMlMjBGaW5kJTIwYSUyMHN1aXRhYmxlJTIwYmF0Y2glMjBzaXplJTIwdGhhdCUyMHdpbGwlMjBmaXQlMjBpbnRvJTIwbWVtb3J5JTIwYXV0b21hdGljYWxseSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0QlMjBsZWFybmluZ19yYXRlJTJDJTIwJTIzJTIwSGlnaGVyJTIwbGVhcm5pbmclMjByYXRlJTIwdGhhbiUyMGZ1bGwlMjBGaW5lLVR1bmluZyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0RlcG9jaHMlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdHJhaW5pbmdfYXJncw==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments
<span class="hljs-keyword">def</span> <span class="hljs-title function_">create_training_arguments</span>(<span class="hljs-params">path, learning_rate=<span class="hljs-number">0.0035</span>, epochs=<span class="hljs-number">6</span></span>):
    training_args = TrainingArguments(
        output_dir=path, <span class="hljs-comment"># Where the model predictions and checkpoints will be written</span>
        use_cpu=<span class="hljs-literal">True</span>, <span class="hljs-comment"># This is necessary for CPU clusters.</span>
        auto_find_batch_size=<span class="hljs-literal">True</span>, <span class="hljs-comment"># Find a suitable batch size that will fit into memory automatically</span>
        learning_rate= learning_rate, <span class="hljs-comment"># Higher learning rate than full Fine-Tuning</span>
        num_train_epochs=epochs
    )
    <span class="hljs-keyword">return</span> training_args`,wrap:!1}}),Xt=new j({props:{code:"aW1wb3J0JTIwb3MlMEElMEF3b3JraW5nX2RpciUyMCUzRCUyMCUyMi4lMkYlMjIlMEElMEElMjNJcyUyMGJlc3QlMjB0byUyMHN0b3JlJTIwdGhlJTIwbW9kZWxzJTIwaW4lMjBzZXBhcmF0ZSUyMGZvbGRlcnMuJTBBJTIzQ3JlYXRlJTIwdGhlJTIwbmFtZSUyMG9mJTIwdGhlJTIwZGlyZWN0b3JpZXMlMjB3aGVyZSUyMHRvJTIwc3RvcmUlMjB0aGUlMjBtb2RlbHMuJTBBb3V0cHV0X2RpcmVjdG9yeV9wcm9tcHQlMjAlM0QlMjAlMjBvcy5wYXRoLmpvaW4od29ya2luZ19kaXIlMkMlMjAlMjJwZWZ0X291dHB1dHNfcHJvbXB0JTIyKSUwQW91dHB1dF9kaXJlY3Rvcnlfc2VudGVuY2VzJTIwJTNEJTIwb3MucGF0aC5qb2luKHdvcmtpbmdfZGlyJTJDJTIwJTIycGVmdF9vdXRwdXRzX3NlbnRlbmNlcyUyMiklMEElMEElMjNKdXN0JTIwY3JlYXRpbmclMjB0aGUlMjBkaXJlY3RvcmlzJTIwaWYlMjBub3QlMjBleGlzdC4lMEFpZiUyMG5vdCUyMG9zLnBhdGguZXhpc3RzKHdvcmtpbmdfZGlyKSUzQSUwQSUyMCUyMCUyMCUyMG9zLm1rZGlyKHdvcmtpbmdfZGlyKSUwQWlmJTIwbm90JTIwb3MucGF0aC5leGlzdHMob3V0cHV0X2RpcmVjdG9yeV9wcm9tcHQpJTNBJTBBJTIwJTIwJTIwJTIwb3MubWtkaXIob3V0cHV0X2RpcmVjdG9yeV9wcm9tcHQpJTBBaWYlMjBub3QlMjBvcy5wYXRoLmV4aXN0cyhvdXRwdXRfZGlyZWN0b3J5X3NlbnRlbmNlcyklM0ElMEElMjAlMjAlMjAlMjBvcy5ta2RpcihvdXRwdXRfZGlyZWN0b3J5X3NlbnRlbmNlcyk=",highlighted:`<span class="hljs-keyword">import</span> os

working_dir = <span class="hljs-string">&quot;./&quot;</span>

<span class="hljs-comment">#Is best to store the models in separate folders.</span>
<span class="hljs-comment">#Create the name of the directories where to store the models.</span>
output_directory_prompt =  os.path.join(working_dir, <span class="hljs-string">&quot;peft_outputs_prompt&quot;</span>)
output_directory_sentences = os.path.join(working_dir, <span class="hljs-string">&quot;peft_outputs_sentences&quot;</span>)

<span class="hljs-comment">#Just creating the directoris if not exist.</span>
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.exists(working_dir):
    os.mkdir(working_dir)
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.exists(output_directory_prompt):
    os.mkdir(output_directory_prompt)
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.exists(output_directory_sentences):
    os.mkdir(output_directory_sentences)`,wrap:!1}}),Rt=new j({props:{code:"dHJhaW5pbmdfYXJnc19wcm9tcHQlMjAlM0QlMjBjcmVhdGVfdHJhaW5pbmdfYXJndW1lbnRzKG91dHB1dF9kaXJlY3RvcnlfcHJvbXB0JTJDJTIwMC4wMDMlMkMlMjBOVU1fRVBPQ0hTKSUwQXRyYWluaW5nX2FyZ3Nfc2VudGVuY2VzJTIwJTNEJTIwY3JlYXRlX3RyYWluaW5nX2FyZ3VtZW50cyhvdXRwdXRfZGlyZWN0b3J5X3NlbnRlbmNlcyUyQyUyMDAuMDAzJTJDJTIwTlVNX0VQT0NIUyk=",highlighted:`training_args_prompt = create_training_arguments(output_directory_prompt, <span class="hljs-number">0.003</span>, NUM_EPOCHS)
training_args_sentences = create_training_arguments(output_directory_sentences, <span class="hljs-number">0.003</span>, NUM_EPOCHS)`,wrap:!1}}),kt=new d({props:{title:"训练",local:"训练",headingTag:"h2"}}),Bt=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluZXIlMkMlMjBEYXRhQ29sbGF0b3JGb3JMYW5ndWFnZU1vZGVsaW5nJTBBZGVmJTIwY3JlYXRlX3RyYWluZXIobW9kZWwlMkMlMjB0cmFpbmluZ19hcmdzJTJDJTIwdHJhaW5fZGF0YXNldCklM0ElMEElMjAlMjAlMjAlMjB0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTIwJTIzJTIwV2UlMjBwYXNzJTIwaW4lMjB0aGUlMjBQRUZUJTIwdmVyc2lvbiUyMG9mJTIwdGhlJTIwZm91bmRhdGlvbiUyMG1vZGVsJTJDJTIwYmxvb216LTU2ME0lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUyMCUyM1RoZSUyMGFyZ3MlMjBmb3IlMjB0aGUlMjB0cmFpbmluZy4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEdHJhaW5fZGF0YXNldCUyQyUyMCUyM1RoZSUyMGRhdGFzZXQlMjB1c2VkJTIwdG8lMjB0eXJhaW4lMjB0aGUlMjBtb2RlbC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNERGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlMkMlMjBtbG0lM0RGYWxzZSklMjAlMjMlMjBtbG0lM0RGYWxzZSUyMGluZGljYXRlcyUyMG5vdCUyMHRvJTIwdXNlJTIwbWFza2VkJTIwbGFuZ3VhZ2UlMjBtb2RlbGluZyUwQSUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0cmFpbmVy",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer, DataCollatorForLanguageModeling
<span class="hljs-keyword">def</span> <span class="hljs-title function_">create_trainer</span>(<span class="hljs-params">model, training_args, train_dataset</span>):
    trainer = Trainer(
        model=model, <span class="hljs-comment"># We pass in the PEFT version of the foundation model, bloomz-560M</span>
        args=training_args, <span class="hljs-comment">#The args for the training.</span>
        train_dataset=train_dataset, <span class="hljs-comment">#The dataset used to tyrain the model.</span>
        data_collator=DataCollatorForLanguageModeling(tokenizer, mlm=<span class="hljs-literal">False</span>) <span class="hljs-comment"># mlm=False indicates not to use masked language modeling</span>
    )
    <span class="hljs-keyword">return</span> trainer`,wrap:!1}}),vt=new j({props:{code:"JTIzVHJhaW5pbmclMjBmaXJzdCUyMG1vZGVsLiUwQXRyYWluZXJfcHJvbXB0JTIwJTNEJTIwY3JlYXRlX3RyYWluZXIocGVmdF9tb2RlbF9wcm9tcHQlMkMlMjB0cmFpbmluZ19hcmdzX3Byb21wdCUyQyUyMHRyYWluX3NhbXBsZV9wcm9tcHQpJTBBdHJhaW5lcl9wcm9tcHQudHJhaW4oKQ==",highlighted:`<span class="hljs-comment">#Training first model.</span>
trainer_prompt = create_trainer(peft_model_prompt, training_args_prompt, train_sample_prompt)
trainer_prompt.train()`,wrap:!1}}),It=new j({props:{code:"JTIzVHJhaW5pbmclMjBzZWNvbmQlMjBtb2RlbC4lMEF0cmFpbmVyX3NlbnRlbmNlcyUyMCUzRCUyMGNyZWF0ZV90cmFpbmVyKHBlZnRfbW9kZWxfc2VudGVuY2VzJTJDJTIwdHJhaW5pbmdfYXJnc19zZW50ZW5jZXMlMkMlMjB0cmFpbl9zYW1wbGVfc2VudGVuY2VzKSUwQXRyYWluZXJfc2VudGVuY2VzLnRyYWluKCk=",highlighted:`<span class="hljs-comment">#Training second model.</span>
trainer_sentences = create_trainer(peft_model_sentences, training_args_sentences, train_sample_sentences)
trainer_sentences.train()`,wrap:!1}}),At=new d({props:{title:"保存模型",local:"保存模型",headingTag:"h2"}}),Ht=new j({props:{code:"dHJhaW5lcl9wcm9tcHQubW9kZWwuc2F2ZV9wcmV0cmFpbmVkKG91dHB1dF9kaXJlY3RvcnlfcHJvbXB0KSUwQXRyYWluZXJfc2VudGVuY2VzLm1vZGVsLnNhdmVfcHJldHJhaW5lZChvdXRwdXRfZGlyZWN0b3J5X3NlbnRlbmNlcyk=",highlighted:`trainer_prompt.model.save_pretrained(output_directory_prompt)
trainer_sentences.model.save_pretrained(output_directory_sentences)`,wrap:!1}}),Yt=new d({props:{title:"推理",local:"推理",headingTag:"h2"}}),Qt=new j({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEElMEFsb2FkZWRfbW9kZWxfcHJvbXB0JTIwJTNEJTIwUGVmdE1vZGVsLmZyb21fcHJldHJhaW5lZChmb3VuZGF0aW9uYWxfbW9kZWwlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRfZGlyZWN0b3J5X3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyM2RldmljZV9tYXAlM0QnYXV0byclMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpc190cmFpbmFibGUlM0RGYWxzZSk=",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

loaded_model_prompt = PeftModel.from_pretrained(foundational_model,
                                         output_directory_prompt,
                                         <span class="hljs-comment">#device_map=&#x27;auto&#x27;,</span>
                                         is_trainable=<span class="hljs-literal">False</span>)`,wrap:!1}}),zt=new j({props:{code:"bG9hZGVkX21vZGVsX3Byb21wdF9vdXRwdXRzJTIwJTNEJTIwZ2V0X291dHB1dHMobG9hZGVkX21vZGVsX3Byb21wdCUyQyUyMGlucHV0X3Byb21wdCklMEFwcmludCh0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGxvYWRlZF9tb2RlbF9wcm9tcHRfb3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>loaded_model_prompt_outputs = get_outputs(loaded_model_prompt, input_prompt)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(loaded_model_prompt_outputs, skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),Lt=new j({props:{code:"bG9hZGVkX21vZGVsX3Byb21wdC5sb2FkX2FkYXB0ZXIob3V0cHV0X2RpcmVjdG9yeV9zZW50ZW5jZXMlMkMlMjBhZGFwdGVyX25hbWUlM0QlMjJxdW90ZXMlMjIpJTBBbG9hZGVkX21vZGVsX3Byb21wdC5zZXRfYWRhcHRlciglMjJxdW90ZXMlMjIp",highlighted:`loaded_model_prompt.load_adapter(output_directory_sentences, adapter_name=<span class="hljs-string">&quot;quotes&quot;</span>)
loaded_model_prompt.set_adapter(<span class="hljs-string">&quot;quotes&quot;</span>)`,wrap:!1}}),Kt=new j({props:{code:"bG9hZGVkX21vZGVsX3NlbnRlbmNlc19vdXRwdXRzJTIwJTNEJTIwZ2V0X291dHB1dHMobG9hZGVkX21vZGVsX3Byb21wdCUyQyUyMGlucHV0X3NlbnRlbmNlcyklMEFwcmludCh0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGxvYWRlZF9tb2RlbF9zZW50ZW5jZXNfb3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>loaded_model_sentences_outputs = get_outputs(loaded_model_prompt, input_sentences)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(loaded_model_sentences_outputs, skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),ee=new d({props:{title:"结论",local:"结论",headingTag:"h1"}}),pe=new rn({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/prompt_tuning_peft.md"}}),{c(){b=p("meta"),ie=n(),me=p("p"),oe=n(),i(w.$$.fragment),ye=n(),i(c.$$.fragment),re=n(),i(U.$$.fragment),ue=n(),J=p("p"),J.innerHTML=ls,fe=n(),h=p("p"),h.textContent=ss,je=n(),T=p("p"),T.innerHTML=ns,de=n(),$=p("p"),$.textContent=as,be=n(),i(C.$$.fragment),we=n(),_=p("p"),_.textContent=ps,ce=n(),Z=p("p"),Z.textContent=ms,Ue=n(),g=p("p"),g.innerHTML=Ms,Je=n(),G=p("p"),G.innerHTML=is,he=n(),X=p("p"),X.textContent=os,Te=n(),W=p("p"),W.innerHTML=ys,$e=n(),R=p("p"),R.textContent=rs,Ce=n(),i(k.$$.fragment),_e=n(),V=p("p"),V.textContent=us,Ze=n(),B=p("p"),B.textContent=fs,ge=n(),i(v.$$.fragment),Ge=n(),I=p("p"),I.textContent=js,Xe=n(),i(x.$$.fragment),We=n(),i(A.$$.fragment),Re=n(),F=p("p"),F.textContent=ds,ke=n(),i(H.$$.fragment),Ve=n(),i(Y.$$.fragment),Be=n(),N=p("p"),N.textContent=bs,ve=n(),Q=p("p"),Q.textContent=ws,Ie=n(),i(z.$$.fragment),xe=n(),i(E.$$.fragment),Ae=n(),i(S.$$.fragment),Fe=n(),P=p("p"),P.innerHTML=cs,He=n(),q=p("p"),q.textContent=Us,Ye=n(),i(L.$$.fragment),Ne=n(),K=p("p"),K.textContent=Js,Qe=n(),D=p("p"),D.textContent=hs,ze=n(),O=p("p"),O.textContent=Ts,Ee=n(),tt=p("p"),tt.textContent=$s,Se=n(),i(et.$$.fragment),Pe=n(),lt=p("pre"),lt.textContent=Cs,qe=n(),i(st.$$.fragment),Le=n(),nt=p("pre"),nt.textContent=_s,Ke=n(),at=p("p"),at.textContent=Zs,De=n(),i(pt.$$.fragment),Oe=n(),mt=p("p"),mt.textContent=gs,tl=n(),Mt=p("ul"),Mt.innerHTML=Gs,el=n(),i(it.$$.fragment),ll=n(),i(ot.$$.fragment),sl=n(),i(yt.$$.fragment),nl=n(),i(rt.$$.fragment),al=n(),ut=p("pre"),ut.textContent=Xs,pl=n(),i(ft.$$.fragment),ml=n(),i(jt.$$.fragment),Ml=n(),i(dt.$$.fragment),il=n(),i(bt.$$.fragment),ol=n(),wt=p("p"),wt.innerHTML=Ws,yl=n(),ct=p("p"),ct.textContent=Rs,rl=n(),i(Ut.$$.fragment),ul=n(),i(Jt.$$.fragment),fl=n(),ht=p("p"),ht.textContent=ks,jl=n(),i(Tt.$$.fragment),dl=n(),$t=p("pre"),$t.textContent=Vs,bl=n(),i(Ct.$$.fragment),wl=n(),_t=p("pre"),_t.textContent=Bs,cl=n(),Zt=p("p"),Zt.innerHTML=vs,Ul=n(),gt=p("p"),gt.textContent=Is,Jl=n(),i(Gt.$$.fragment),hl=n(),i(Xt.$$.fragment),Tl=n(),Wt=p("p"),Wt.textContent=xs,$l=n(),i(Rt.$$.fragment),Cl=n(),i(kt.$$.fragment),_l=n(),Vt=p("p"),Vt.textContent=As,Zl=n(),i(Bt.$$.fragment),gl=n(),i(vt.$$.fragment),Gl=n(),i(It.$$.fragment),Xl=n(),xt=p("p"),xt.textContent=Fs,Wl=n(),i(At.$$.fragment),Rl=n(),Ft=p("p"),Ft.textContent=Hs,kl=n(),i(Ht.$$.fragment),Vl=n(),i(Yt.$$.fragment),Bl=n(),Nt=p("p"),Nt.textContent=Ys,vl=n(),i(Qt.$$.fragment),Il=n(),i(zt.$$.fragment),xl=n(),Et=p("pre"),Et.textContent=Ns,Al=n(),St=p("p"),St.textContent=Qs,Fl=n(),Pt=p("ul"),Pt.innerHTML=zs,Hl=n(),qt=p("p"),qt.textContent=Es,Yl=n(),i(Lt.$$.fragment),Nl=n(),i(Kt.$$.fragment),Ql=n(),Dt=p("pre"),Dt.textContent=Ss,zl=n(),Ot=p("p"),Ot.textContent=Ps,El=n(),te=p("ul"),te.innerHTML=qs,Sl=n(),i(ee.$$.fragment),Pl=n(),le=p("p"),le.textContent=Ls,ql=n(),se=p("p"),se.textContent=Ks,Ll=n(),ne=p("p"),ne.textContent=Ds,Kl=n(),ae=p("p"),ae.innerHTML=Os,Dl=n(),i(pe.$$.fragment),Ol=n(),Me=p("p"),this.h()},l(t){const e=mn("svelte-u9bgzb",document.head);b=m(e,"META",{name:!0,content:!0}),e.forEach(l),ie=a(t),me=m(t,"P",{}),tn(me).forEach(l),oe=a(t),o(w.$$.fragment,t),ye=a(t),o(c.$$.fragment,t),re=a(t),o(U.$$.fragment,t),ue=a(t),J=m(t,"P",{"data-svelte-h":!0}),M(J)!=="svelte-1hm5fnd"&&(J.innerHTML=ls),fe=a(t),h=m(t,"P",{"data-svelte-h":!0}),M(h)!=="svelte-k8apnd"&&(h.textContent=ss),je=a(t),T=m(t,"P",{"data-svelte-h":!0}),M(T)!=="svelte-183v4i5"&&(T.innerHTML=ns),de=a(t),$=m(t,"P",{"data-svelte-h":!0}),M($)!=="svelte-llxnoz"&&($.textContent=as),be=a(t),o(C.$$.fragment,t),we=a(t),_=m(t,"P",{"data-svelte-h":!0}),M(_)!=="svelte-6e31nm"&&(_.textContent=ps),ce=a(t),Z=m(t,"P",{"data-svelte-h":!0}),M(Z)!=="svelte-18dp60q"&&(Z.textContent=ms),Ue=a(t),g=m(t,"P",{"data-svelte-h":!0}),M(g)!=="svelte-18z3ipt"&&(g.innerHTML=Ms),Je=a(t),G=m(t,"P",{"data-svelte-h":!0}),M(G)!=="svelte-1nkffqs"&&(G.innerHTML=is),he=a(t),X=m(t,"P",{"data-svelte-h":!0}),M(X)!=="svelte-1tegg1n"&&(X.textContent=os),Te=a(t),W=m(t,"P",{"data-svelte-h":!0}),M(W)!=="svelte-13ojr0e"&&(W.innerHTML=ys),$e=a(t),R=m(t,"P",{"data-svelte-h":!0}),M(R)!=="svelte-1mmvk7i"&&(R.textContent=rs),Ce=a(t),o(k.$$.fragment,t),_e=a(t),V=m(t,"P",{"data-svelte-h":!0}),M(V)!=="svelte-qll3ym"&&(V.textContent=us),Ze=a(t),B=m(t,"P",{"data-svelte-h":!0}),M(B)!=="svelte-1f9e5y5"&&(B.textContent=fs),ge=a(t),o(v.$$.fragment,t),Ge=a(t),I=m(t,"P",{"data-svelte-h":!0}),M(I)!=="svelte-1jqtkfh"&&(I.textContent=js),Xe=a(t),o(x.$$.fragment,t),We=a(t),o(A.$$.fragment,t),Re=a(t),F=m(t,"P",{"data-svelte-h":!0}),M(F)!=="svelte-1wz4900"&&(F.textContent=ds),ke=a(t),o(H.$$.fragment,t),Ve=a(t),o(Y.$$.fragment,t),Be=a(t),N=m(t,"P",{"data-svelte-h":!0}),M(N)!=="svelte-tyj5lb"&&(N.textContent=bs),ve=a(t),Q=m(t,"P",{"data-svelte-h":!0}),M(Q)!=="svelte-hv45u7"&&(Q.textContent=ws),Ie=a(t),o(z.$$.fragment,t),xe=a(t),o(E.$$.fragment,t),Ae=a(t),o(S.$$.fragment,t),Fe=a(t),P=m(t,"P",{"data-svelte-h":!0}),M(P)!=="svelte-1fujawk"&&(P.innerHTML=cs),He=a(t),q=m(t,"P",{"data-svelte-h":!0}),M(q)!=="svelte-1t9fxk8"&&(q.textContent=Us),Ye=a(t),o(L.$$.fragment,t),Ne=a(t),K=m(t,"P",{"data-svelte-h":!0}),M(K)!=="svelte-qzii9o"&&(K.textContent=Js),Qe=a(t),D=m(t,"P",{"data-svelte-h":!0}),M(D)!=="svelte-1jz4d16"&&(D.textContent=hs),ze=a(t),O=m(t,"P",{"data-svelte-h":!0}),M(O)!=="svelte-x816ca"&&(O.textContent=Ts),Ee=a(t),tt=m(t,"P",{"data-svelte-h":!0}),M(tt)!=="svelte-gaknpy"&&(tt.textContent=$s),Se=a(t),o(et.$$.fragment,t),Pe=a(t),lt=m(t,"PRE",{"data-svelte-h":!0}),M(lt)!=="svelte-j0gwzs"&&(lt.textContent=Cs),qe=a(t),o(st.$$.fragment,t),Le=a(t),nt=m(t,"PRE",{"data-svelte-h":!0}),M(nt)!=="svelte-156di1e"&&(nt.textContent=_s),Ke=a(t),at=m(t,"P",{"data-svelte-h":!0}),M(at)!=="svelte-1drfwsu"&&(at.textContent=Zs),De=a(t),o(pt.$$.fragment,t),Oe=a(t),mt=m(t,"P",{"data-svelte-h":!0}),M(mt)!=="svelte-1rf18xk"&&(mt.textContent=gs),tl=a(t),Mt=m(t,"UL",{"data-svelte-h":!0}),M(Mt)!=="svelte-q7foik"&&(Mt.innerHTML=Gs),el=a(t),o(it.$$.fragment,t),ll=a(t),o(ot.$$.fragment,t),sl=a(t),o(yt.$$.fragment,t),nl=a(t),o(rt.$$.fragment,t),al=a(t),ut=m(t,"PRE",{"data-svelte-h":!0}),M(ut)!=="svelte-19qaqk6"&&(ut.textContent=Xs),pl=a(t),o(ft.$$.fragment,t),ml=a(t),o(jt.$$.fragment,t),Ml=a(t),o(dt.$$.fragment,t),il=a(t),o(bt.$$.fragment,t),ol=a(t),wt=m(t,"P",{"data-svelte-h":!0}),M(wt)!=="svelte-ga822j"&&(wt.innerHTML=Ws),yl=a(t),ct=m(t,"P",{"data-svelte-h":!0}),M(ct)!=="svelte-1ba2eyz"&&(ct.textContent=Rs),rl=a(t),o(Ut.$$.fragment,t),ul=a(t),o(Jt.$$.fragment,t),fl=a(t),ht=m(t,"P",{"data-svelte-h":!0}),M(ht)!=="svelte-1659lue"&&(ht.textContent=ks),jl=a(t),o(Tt.$$.fragment,t),dl=a(t),$t=m(t,"PRE",{"data-svelte-h":!0}),M($t)!=="svelte-1j4ogfu"&&($t.textContent=Vs),bl=a(t),o(Ct.$$.fragment,t),wl=a(t),_t=m(t,"PRE",{"data-svelte-h":!0}),M(_t)!=="svelte-1j4ogfu"&&(_t.textContent=Bs),cl=a(t),Zt=m(t,"P",{"data-svelte-h":!0}),M(Zt)!=="svelte-qd5vw9"&&(Zt.innerHTML=vs),Ul=a(t),gt=m(t,"P",{"data-svelte-h":!0}),M(gt)!=="svelte-yat80l"&&(gt.textContent=Is),Jl=a(t),o(Gt.$$.fragment,t),hl=a(t),o(Xt.$$.fragment,t),Tl=a(t),Wt=m(t,"P",{"data-svelte-h":!0}),M(Wt)!=="svelte-1kvnpq3"&&(Wt.textContent=xs),$l=a(t),o(Rt.$$.fragment,t),Cl=a(t),o(kt.$$.fragment,t),_l=a(t),Vt=m(t,"P",{"data-svelte-h":!0}),M(Vt)!=="svelte-ukow41"&&(Vt.textContent=As),Zl=a(t),o(Bt.$$.fragment,t),gl=a(t),o(vt.$$.fragment,t),Gl=a(t),o(It.$$.fragment,t),Xl=a(t),xt=m(t,"P",{"data-svelte-h":!0}),M(xt)!=="svelte-uayr8h"&&(xt.textContent=Fs),Wl=a(t),o(At.$$.fragment,t),Rl=a(t),Ft=m(t,"P",{"data-svelte-h":!0}),M(Ft)!=="svelte-1m4fky2"&&(Ft.textContent=Hs),kl=a(t),o(Ht.$$.fragment,t),Vl=a(t),o(Yt.$$.fragment,t),Bl=a(t),Nt=m(t,"P",{"data-svelte-h":!0}),M(Nt)!=="svelte-2ugde3"&&(Nt.textContent=Ys),vl=a(t),o(Qt.$$.fragment,t),Il=a(t),o(zt.$$.fragment,t),xl=a(t),Et=m(t,"PRE",{"data-svelte-h":!0}),M(Et)!=="svelte-17c65rx"&&(Et.textContent=Ns),Al=a(t),St=m(t,"P",{"data-svelte-h":!0}),M(St)!=="svelte-qho7gg"&&(St.textContent=Qs),Fl=a(t),Pt=m(t,"UL",{"data-svelte-h":!0}),M(Pt)!=="svelte-xewazx"&&(Pt.innerHTML=zs),Hl=a(t),qt=m(t,"P",{"data-svelte-h":!0}),M(qt)!=="svelte-vanqym"&&(qt.textContent=Es),Yl=a(t),o(Lt.$$.fragment,t),Nl=a(t),o(Kt.$$.fragment,t),Ql=a(t),Dt=m(t,"PRE",{"data-svelte-h":!0}),M(Dt)!=="svelte-1h21gmq"&&(Dt.textContent=Ss),zl=a(t),Ot=m(t,"P",{"data-svelte-h":!0}),M(Ot)!=="svelte-8rd4fj"&&(Ot.textContent=Ps),El=a(t),te=m(t,"UL",{"data-svelte-h":!0}),M(te)!=="svelte-yccex6"&&(te.innerHTML=qs),Sl=a(t),o(ee.$$.fragment,t),Pl=a(t),le=m(t,"P",{"data-svelte-h":!0}),M(le)!=="svelte-1nhoviv"&&(le.textContent=Ls),ql=a(t),se=m(t,"P",{"data-svelte-h":!0}),M(se)!=="svelte-13xfee6"&&(se.textContent=Ks),Ll=a(t),ne=m(t,"P",{"data-svelte-h":!0}),M(ne)!=="svelte-lhgy67"&&(ne.textContent=Ds),Kl=a(t),ae=m(t,"P",{"data-svelte-h":!0}),M(ae)!=="svelte-k1fwp0"&&(ae.innerHTML=Os),Dl=a(t),o(pe.$$.fragment,t),Ol=a(t),Me=m(t,"P",{}),tn(Me).forEach(l),this.h()},h(){en(b,"name","hf:doc:metadata"),en(b,"content",fn)},m(t,e){Mn(document.head,b),s(t,ie,e),s(t,me,e),s(t,oe,e),y(w,t,e),s(t,ye,e),y(c,t,e),s(t,re,e),y(U,t,e),s(t,ue,e),s(t,J,e),s(t,fe,e),s(t,h,e),s(t,je,e),s(t,T,e),s(t,de,e),s(t,$,e),s(t,be,e),y(C,t,e),s(t,we,e),s(t,_,e),s(t,ce,e),s(t,Z,e),s(t,Ue,e),s(t,g,e),s(t,Je,e),s(t,G,e),s(t,he,e),s(t,X,e),s(t,Te,e),s(t,W,e),s(t,$e,e),s(t,R,e),s(t,Ce,e),y(k,t,e),s(t,_e,e),s(t,V,e),s(t,Ze,e),s(t,B,e),s(t,ge,e),y(v,t,e),s(t,Ge,e),s(t,I,e),s(t,Xe,e),y(x,t,e),s(t,We,e),y(A,t,e),s(t,Re,e),s(t,F,e),s(t,ke,e),y(H,t,e),s(t,Ve,e),y(Y,t,e),s(t,Be,e),s(t,N,e),s(t,ve,e),s(t,Q,e),s(t,Ie,e),y(z,t,e),s(t,xe,e),y(E,t,e),s(t,Ae,e),y(S,t,e),s(t,Fe,e),s(t,P,e),s(t,He,e),s(t,q,e),s(t,Ye,e),y(L,t,e),s(t,Ne,e),s(t,K,e),s(t,Qe,e),s(t,D,e),s(t,ze,e),s(t,O,e),s(t,Ee,e),s(t,tt,e),s(t,Se,e),y(et,t,e),s(t,Pe,e),s(t,lt,e),s(t,qe,e),y(st,t,e),s(t,Le,e),s(t,nt,e),s(t,Ke,e),s(t,at,e),s(t,De,e),y(pt,t,e),s(t,Oe,e),s(t,mt,e),s(t,tl,e),s(t,Mt,e),s(t,el,e),y(it,t,e),s(t,ll,e),y(ot,t,e),s(t,sl,e),y(yt,t,e),s(t,nl,e),y(rt,t,e),s(t,al,e),s(t,ut,e),s(t,pl,e),y(ft,t,e),s(t,ml,e),y(jt,t,e),s(t,Ml,e),y(dt,t,e),s(t,il,e),y(bt,t,e),s(t,ol,e),s(t,wt,e),s(t,yl,e),s(t,ct,e),s(t,rl,e),y(Ut,t,e),s(t,ul,e),y(Jt,t,e),s(t,fl,e),s(t,ht,e),s(t,jl,e),y(Tt,t,e),s(t,dl,e),s(t,$t,e),s(t,bl,e),y(Ct,t,e),s(t,wl,e),s(t,_t,e),s(t,cl,e),s(t,Zt,e),s(t,Ul,e),s(t,gt,e),s(t,Jl,e),y(Gt,t,e),s(t,hl,e),y(Xt,t,e),s(t,Tl,e),s(t,Wt,e),s(t,$l,e),y(Rt,t,e),s(t,Cl,e),y(kt,t,e),s(t,_l,e),s(t,Vt,e),s(t,Zl,e),y(Bt,t,e),s(t,gl,e),y(vt,t,e),s(t,Gl,e),y(It,t,e),s(t,Xl,e),s(t,xt,e),s(t,Wl,e),y(At,t,e),s(t,Rl,e),s(t,Ft,e),s(t,kl,e),y(Ht,t,e),s(t,Vl,e),y(Yt,t,e),s(t,Bl,e),s(t,Nt,e),s(t,vl,e),y(Qt,t,e),s(t,Il,e),y(zt,t,e),s(t,xl,e),s(t,Et,e),s(t,Al,e),s(t,St,e),s(t,Fl,e),s(t,Pt,e),s(t,Hl,e),s(t,qt,e),s(t,Yl,e),y(Lt,t,e),s(t,Nl,e),y(Kt,t,e),s(t,Ql,e),s(t,Dt,e),s(t,zl,e),s(t,Ot,e),s(t,El,e),s(t,te,e),s(t,Sl,e),y(ee,t,e),s(t,Pl,e),s(t,le,e),s(t,ql,e),s(t,se,e),s(t,Ll,e),s(t,ne,e),s(t,Kl,e),s(t,ae,e),s(t,Dl,e),y(pe,t,e),s(t,Ol,e),s(t,Me,e),ts=!0},p:sn,i(t){ts||(r(w.$$.fragment,t),r(c.$$.fragment,t),r(U.$$.fragment,t),r(C.$$.fragment,t),r(k.$$.fragment,t),r(v.$$.fragment,t),r(x.$$.fragment,t),r(A.$$.fragment,t),r(H.$$.fragment,t),r(Y.$$.fragment,t),r(z.$$.fragment,t),r(E.$$.fragment,t),r(S.$$.fragment,t),r(L.$$.fragment,t),r(et.$$.fragment,t),r(st.$$.fragment,t),r(pt.$$.fragment,t),r(it.$$.fragment,t),r(ot.$$.fragment,t),r(yt.$$.fragment,t),r(rt.$$.fragment,t),r(ft.$$.fragment,t),r(jt.$$.fragment,t),r(dt.$$.fragment,t),r(bt.$$.fragment,t),r(Ut.$$.fragment,t),r(Jt.$$.fragment,t),r(Tt.$$.fragment,t),r(Ct.$$.fragment,t),r(Gt.$$.fragment,t),r(Xt.$$.fragment,t),r(Rt.$$.fragment,t),r(kt.$$.fragment,t),r(Bt.$$.fragment,t),r(vt.$$.fragment,t),r(It.$$.fragment,t),r(At.$$.fragment,t),r(Ht.$$.fragment,t),r(Yt.$$.fragment,t),r(Qt.$$.fragment,t),r(zt.$$.fragment,t),r(Lt.$$.fragment,t),r(Kt.$$.fragment,t),r(ee.$$.fragment,t),r(pe.$$.fragment,t),ts=!0)},o(t){u(w.$$.fragment,t),u(c.$$.fragment,t),u(U.$$.fragment,t),u(C.$$.fragment,t),u(k.$$.fragment,t),u(v.$$.fragment,t),u(x.$$.fragment,t),u(A.$$.fragment,t),u(H.$$.fragment,t),u(Y.$$.fragment,t),u(z.$$.fragment,t),u(E.$$.fragment,t),u(S.$$.fragment,t),u(L.$$.fragment,t),u(et.$$.fragment,t),u(st.$$.fragment,t),u(pt.$$.fragment,t),u(it.$$.fragment,t),u(ot.$$.fragment,t),u(yt.$$.fragment,t),u(rt.$$.fragment,t),u(ft.$$.fragment,t),u(jt.$$.fragment,t),u(dt.$$.fragment,t),u(bt.$$.fragment,t),u(Ut.$$.fragment,t),u(Jt.$$.fragment,t),u(Tt.$$.fragment,t),u(Ct.$$.fragment,t),u(Gt.$$.fragment,t),u(Xt.$$.fragment,t),u(Rt.$$.fragment,t),u(kt.$$.fragment,t),u(Bt.$$.fragment,t),u(vt.$$.fragment,t),u(It.$$.fragment,t),u(At.$$.fragment,t),u(Ht.$$.fragment,t),u(Yt.$$.fragment,t),u(Qt.$$.fragment,t),u(zt.$$.fragment,t),u(Lt.$$.fragment,t),u(Kt.$$.fragment,t),u(ee.$$.fragment,t),u(pe.$$.fragment,t),ts=!1},d(t){t&&(l(ie),l(me),l(oe),l(ye),l(re),l(ue),l(J),l(fe),l(h),l(je),l(T),l(de),l($),l(be),l(we),l(_),l(ce),l(Z),l(Ue),l(g),l(Je),l(G),l(he),l(X),l(Te),l(W),l($e),l(R),l(Ce),l(_e),l(V),l(Ze),l(B),l(ge),l(Ge),l(I),l(Xe),l(We),l(Re),l(F),l(ke),l(Ve),l(Be),l(N),l(ve),l(Q),l(Ie),l(xe),l(Ae),l(Fe),l(P),l(He),l(q),l(Ye),l(Ne),l(K),l(Qe),l(D),l(ze),l(O),l(Ee),l(tt),l(Se),l(Pe),l(lt),l(qe),l(Le),l(nt),l(Ke),l(at),l(De),l(Oe),l(mt),l(tl),l(Mt),l(el),l(ll),l(sl),l(nl),l(al),l(ut),l(pl),l(ml),l(Ml),l(il),l(ol),l(wt),l(yl),l(ct),l(rl),l(ul),l(fl),l(ht),l(jl),l(dl),l($t),l(bl),l(wl),l(_t),l(cl),l(Zt),l(Ul),l(gt),l(Jl),l(hl),l(Tl),l(Wt),l($l),l(Cl),l(_l),l(Vt),l(Zl),l(gl),l(Gl),l(Xl),l(xt),l(Wl),l(Rl),l(Ft),l(kl),l(Vl),l(Bl),l(Nt),l(vl),l(Il),l(xl),l(Et),l(Al),l(St),l(Fl),l(Pt),l(Hl),l(qt),l(Yl),l(Nl),l(Ql),l(Dt),l(zl),l(Ot),l(El),l(te),l(Sl),l(Pl),l(le),l(ql),l(se),l(Ll),l(ne),l(Kl),l(ae),l(Dl),l(Ol),l(Me)),l(b),f(w,t),f(c,t),f(U,t),f(C,t),f(k,t),f(v,t),f(x,t),f(A,t),f(H,t),f(Y,t),f(z,t),f(E,t),f(S,t),f(L,t),f(et,t),f(st,t),f(pt,t),f(it,t),f(ot,t),f(yt,t),f(rt,t),f(ft,t),f(jt,t),f(dt,t),f(bt,t),f(Ut,t),f(Jt,t),f(Tt,t),f(Ct,t),f(Gt,t),f(Xt,t),f(Rt,t),f(kt,t),f(Bt,t),f(vt,t),f(It,t),f(At,t),f(Ht,t),f(Yt,t),f(Qt,t),f(zt,t),f(Lt,t),f(Kt,t),f(ee,t),f(pe,t)}}}const fn='{"title":"使用 PEFT 进行提示微调","local":"使用-peft-进行提示微调","sections":[{"title":"提示微调简要介绍","local":"提示微调简要介绍","sections":[],"depth":2},{"title":"我们将在 notebook 中做什么？","local":"我们将在-notebook-中做什么","sections":[],"depth":2},{"title":"加载 PEFT 库","local":"加载-peft-库","sections":[{"title":"加载模型和分词器。","local":"加载模型和分词器","sections":[],"depth":3}],"depth":2},{"title":"使用预训练的 bloom 模型进行推理","local":"使用预训练的-bloom-模型进行推理","sections":[],"depth":2},{"title":"准备数据集","local":"准备数据集","sections":[],"depth":2},{"title":"微调","local":"微调","sections":[{"title":"PEFT 配置","local":"peft-配置","sections":[],"depth":3},{"title":"创建两个提示调整模型。","local":"创建两个提示调整模型","sections":[],"depth":3}],"depth":2},{"title":"训练","local":"训练","sections":[],"depth":2},{"title":"保存模型","local":"保存模型","sections":[],"depth":2},{"title":"推理","local":"推理","sections":[],"depth":2}],"depth":1}';function jn(es){return nn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Jn extends an{constructor(b){super(),pn(this,b,jn,un,ln,{})}}export{Jn as component};
