import{s as va,o as Ca,n as I}from"../chunks/scheduler.3e4cb221.js";import{S as Ra,i as Ga,g as y,s as o,r as d,A as Wa,h as b,f as a,c as i,j as N,u as $,x as T,k as ka,y as U,a as r,v as u,d as g,t as h,w as M}from"../chunks/index.bc693fcb.js";import{T as St}from"../chunks/Tip.4df9f752.js";import{F as It,Y as Za,M as E}from"../chunks/Markdown.79356aac.js";import{C as J}from"../chunks/CodeBlock.4b1f9331.js";import{D as Ha}from"../chunks/DocNotebookDropdown.171b144b.js";import{H as Y}from"../chunks/Heading.fa24041c.js";function Va(w){let s,p;return s=new J({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRvcmNo",highlighted:"pip install torch",wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Ia(w){let s,p;return s=new E({props:{$$slots:{default:[Va]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Xa(w){let s,p;return s=new J({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRlbnNvcmZsb3c=",highlighted:"pip install tensorflow",wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Fa(w){let s,p;return s=new E({props:{$$slots:{default:[Xa]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Na(w){let s,p="使用 <code>AutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 来加载预训练模型和它关联的分词器（更多信息可以参考下一节的 <code>AutoClass</code>）：",t,n,f;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChtb2RlbF9uYW1lKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX25hbWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),T(s)!=="svelte-16qd42h"&&(s.innerHTML=p),t=i(m),$(n.$$.fragment,m)},m(m,_){r(m,s,_),r(m,t,_),u(n,m,_),f=!0},p:I,i(m){f||(g(n.$$.fragment,m),f=!0)},o(m){h(n.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(n,m)}}}function xa(w){let s,p;return s=new E({props:{$$slots:{default:[Na]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function za(w){let s,p="使用 <code>TFAutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 来加载预训练模型和它关联的分词器（更多信息可以参考下一节的 <code>TFAutoClass</code>）：",t,n,f;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQobW9kZWxfbmFtZSklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9uYW1lKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1scc1z5"&&(s.innerHTML=p),t=i(m),$(n.$$.fragment,m)},m(m,_){r(m,s,_),r(m,t,_),u(n,m,_),f=!0},p:I,i(m){f||(g(n.$$.fragment,m),f=!0)},o(m){h(n.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(n,m)}}}function Ea(w){let s,p;return s=new E({props:{$$slots:{default:[za]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Ba(w){let s,p;return s=new J({props:{code:"cHRfYmF0Y2glMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTVCJTIyV2UlMjBhcmUlMjB2ZXJ5JTIwaGFwcHklMjB0byUyMHNob3clMjB5b3UlMjB0aGUlMjAlRjAlOUYlQTQlOTclMjBUcmFuc2Zvcm1lcnMlMjBsaWJyYXJ5LiUyMiUyQyUyMCUyMldlJTIwaG9wZSUyMHlvdSUyMGRvbid0JTIwaGF0ZSUyMGl0LiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBtYXhfbGVuZ3RoJTNENTEyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the 🤗 Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Ya(w){let s,p;return s=new E({props:{$$slots:{default:[Ba]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function La(w){let s,p;return s=new J({props:{code:"dGZfYmF0Y2glMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTVCJTIyV2UlMjBhcmUlMjB2ZXJ5JTIwaGFwcHklMjB0byUyMHNob3clMjB5b3UlMjB0aGUlMjAlRjAlOUYlQTQlOTclMjBUcmFuc2Zvcm1lcnMlMjBsaWJyYXJ5LiUyMiUyQyUyMCUyMldlJTIwaG9wZSUyMHlvdSUyMGRvbid0JTIwaGF0ZSUyMGl0LiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBtYXhfbGVuZ3RoJTNENTEyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the 🤗 Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;tf&quot;</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Aa(w){let s,p;return s=new E({props:{$$slots:{default:[La]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Qa(w){let s,p='查阅<a href="./preprocessing">预处理</a>教程来获得有关分词的更详细的信息，以及如何使用 <code>AutoFeatureExtractor</code> 和 <code>AutoProcessor</code> 来处理图像，音频，还有多模式输入。';return{c(){s=y("p"),s.innerHTML=p},l(t){s=b(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-l21b6c"&&(s.innerHTML=p)},m(t,n){r(t,s,n)},p:I,d(t){t&&a(s)}}}function qa(w){let s,p='通过 <a href="./task_summary">任务摘要</a> 查找 <code>AutoModel</code> 支持的任务.';return{c(){s=y("p"),s.innerHTML=p},l(t){s=b(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1mg580k"&&(s.innerHTML=p)},m(t,n){r(t,s,n)},p:I,d(t){t&&a(s)}}}function Sa(w){let s,p="🤗 Transformers 提供了一种简单统一的方式来加载预训练的实例. 这表示你可以像加载 <code>AutoTokenizer</code> 一样加载 <code>AutoModel</code>。唯一不同的地方是为你的任务选择正确的<code>AutoModel</code>。对于文本（或序列）分类，你应该加载<code>AutoModelForSequenceClassification</code>：",t,n,f,m,_,v,C="现在可以把预处理好的输入批次直接送进模型。你只需要通过 <code>**</code> 来解包字典:",R,j,Z,W,L="模型在 <code>logits</code> 属性输出最终的激活结果. 在 <code>logits</code> 上应用 softmax 函数来查询概率:",H,G,V;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbF9uYW1lJTIwJTNEJTIwJTIybmxwdG93biUyRmJlcnQtYmFzZS1tdWx0aWxpbmd1YWwtdW5jYXNlZC1zZW50aW1lbnQlMjIlMEFwdF9tb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX25hbWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(model_name)`,wrap:!1}}),m=new St({props:{$$slots:{default:[qa]},$$scope:{ctx:w}}}),j=new J({props:{code:"cHRfb3V0cHV0cyUyMCUzRCUyMHB0X21vZGVsKCoqcHRfYmF0Y2gp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_outputs = pt_model(**pt_batch)',wrap:!1}}),G=new J({props:{code:"ZnJvbSUyMHRvcmNoJTIwaW1wb3J0JTIwbm4lMEElMEFwdF9wcmVkaWN0aW9ucyUyMCUzRCUyMG5uLmZ1bmN0aW9uYWwuc29mdG1heChwdF9vdXRwdXRzLmxvZ2l0cyUyQyUyMGRpbSUzRC0xKSUwQXByaW50KHB0X3ByZWRpY3Rpb25zKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> nn

<span class="hljs-meta">&gt;&gt;&gt; </span>pt_predictions = nn.functional.softmax(pt_outputs.logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(pt_predictions)
tensor([[<span class="hljs-number">0.0021</span>, <span class="hljs-number">0.0018</span>, <span class="hljs-number">0.0115</span>, <span class="hljs-number">0.2121</span>, <span class="hljs-number">0.7725</span>],
        [<span class="hljs-number">0.2084</span>, <span class="hljs-number">0.1826</span>, <span class="hljs-number">0.1969</span>, <span class="hljs-number">0.1755</span>, <span class="hljs-number">0.2365</span>]], grad_fn=&lt;SoftmaxBackward0&gt;)`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment),f=o(),d(m.$$.fragment),_=o(),v=y("p"),v.innerHTML=C,R=o(),d(j.$$.fragment),Z=o(),W=y("p"),W.innerHTML=L,H=o(),d(G.$$.fragment)},l(c){s=b(c,"P",{"data-svelte-h":!0}),T(s)!=="svelte-7kcz0m"&&(s.innerHTML=p),t=i(c),$(n.$$.fragment,c),f=i(c),$(m.$$.fragment,c),_=i(c),v=b(c,"P",{"data-svelte-h":!0}),T(v)!=="svelte-1q5w0a3"&&(v.innerHTML=C),R=i(c),$(j.$$.fragment,c),Z=i(c),W=b(c,"P",{"data-svelte-h":!0}),T(W)!=="svelte-ianwj2"&&(W.innerHTML=L),H=i(c),$(G.$$.fragment,c)},m(c,k){r(c,s,k),r(c,t,k),u(n,c,k),r(c,f,k),u(m,c,k),r(c,_,k),r(c,v,k),r(c,R,k),u(j,c,k),r(c,Z,k),r(c,W,k),r(c,H,k),u(G,c,k),V=!0},p(c,k){const x={};k&2&&(x.$$scope={dirty:k,ctx:c}),m.$set(x)},i(c){V||(g(n.$$.fragment,c),g(m.$$.fragment,c),g(j.$$.fragment,c),g(G.$$.fragment,c),V=!0)},o(c){h(n.$$.fragment,c),h(m.$$.fragment,c),h(j.$$.fragment,c),h(G.$$.fragment,c),V=!1},d(c){c&&(a(s),a(t),a(f),a(_),a(v),a(R),a(Z),a(W),a(H)),M(n,c),M(m,c),M(j,c),M(G,c)}}}function Pa(w){let s,p;return s=new E({props:{$$slots:{default:[Sa]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Oa(w){let s,p='通过 <a href="./task_summary">任务摘要</a> 查找 <code>AutoModel</code> 支持的任务.';return{c(){s=y("p"),s.innerHTML=p},l(t){s=b(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1mg580k"&&(s.innerHTML=p)},m(t,n){r(t,s,n)},p:I,d(t){t&&a(s)}}}function Da(w){let s,p="🤗 Transformers 提供了一种简单统一的方式来加载预训练的实例。这表示你可以像加载 <code>AutoTokenizer</code> 一样加载 <code>TFAutoModel</code>。唯一不同的地方是为你的任务选择正确的 <code>TFAutoModel</code>，对于文本（或序列）分类，你应该加载 <code>TFAutoModelForSequenceClassification</code>：",t,n,f,m,_,v,C="现在通过直接将字典的键传给张量，将预处理的输入批次传给模型。",R,j,Z,W,L="模型在 <code>logits</code> 属性输出最终的激活结果。在 <code>logits</code> 上应用softmax函数来查询概率：",H,G,V;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsX25hbWUlMjAlM0QlMjAlMjJubHB0b3duJTJGYmVydC1iYXNlLW11bHRpbGluZ3VhbC11bmNhc2VkLXNlbnRpbWVudCUyMiUwQXRmX21vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChtb2RlbF9uYW1lKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(model_name)`,wrap:!1}}),m=new St({props:{$$slots:{default:[Oa]},$$scope:{ctx:w}}}),j=new J({props:{code:"dGZfb3V0cHV0cyUyMCUzRCUyMHRmX21vZGVsKHRmX2JhdGNoKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_outputs = tf_model(tf_batch)',wrap:!1}}),G=new J({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEF0Zl9wcmVkaWN0aW9ucyUyMCUzRCUyMHRmLm5uLnNvZnRtYXgodGZfb3V0cHV0cy5sb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBdGZfcHJlZGljdGlvbnM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_predictions = tf.nn.softmax(tf_outputs.logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_predictions`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment),f=o(),d(m.$$.fragment),_=o(),v=y("p"),v.textContent=C,R=o(),d(j.$$.fragment),Z=o(),W=y("p"),W.innerHTML=L,H=o(),d(G.$$.fragment)},l(c){s=b(c,"P",{"data-svelte-h":!0}),T(s)!=="svelte-koi20"&&(s.innerHTML=p),t=i(c),$(n.$$.fragment,c),f=i(c),$(m.$$.fragment,c),_=i(c),v=b(c,"P",{"data-svelte-h":!0}),T(v)!=="svelte-16cvbg6"&&(v.textContent=C),R=i(c),$(j.$$.fragment,c),Z=i(c),W=b(c,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1aahzm4"&&(W.innerHTML=L),H=i(c),$(G.$$.fragment,c)},m(c,k){r(c,s,k),r(c,t,k),u(n,c,k),r(c,f,k),u(m,c,k),r(c,_,k),r(c,v,k),r(c,R,k),u(j,c,k),r(c,Z,k),r(c,W,k),r(c,H,k),u(G,c,k),V=!0},p(c,k){const x={};k&2&&(x.$$scope={dirty:k,ctx:c}),m.$set(x)},i(c){V||(g(n.$$.fragment,c),g(m.$$.fragment,c),g(j.$$.fragment,c),g(G.$$.fragment,c),V=!0)},o(c){h(n.$$.fragment,c),h(m.$$.fragment,c),h(j.$$.fragment,c),h(G.$$.fragment,c),V=!1},d(c){c&&(a(s),a(t),a(f),a(_),a(v),a(R),a(Z),a(W),a(H)),M(n,c),M(m,c),M(j,c),M(G,c)}}}function Ka(w){let s,p;return s=new E({props:{$$slots:{default:[Da]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function en(w){let s,p=`所有 🤗 Transformers 模型（PyTorch 或 TensorFlow）在最终的激活函数（比如 softmax）<em>之前</em> 输出张量，
因为最终的激活函数常常与 loss 融合。模型的输出是特殊的数据类，所以它们的属性可以在 IDE 中被自动补全。模型的输出就像一个元组或字典（你可以通过整数、切片或字符串来索引它），在这种情况下，为 None 的属性会被忽略。`;return{c(){s=y("p"),s.innerHTML=p},l(t){s=b(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-pdy338"&&(s.innerHTML=p)},m(t,n){r(t,s,n)},p:I,d(t){t&&a(s)}}}function tn(w){let s,p="当你的模型微调完成，你就可以使用 <code>PreTrainedModel.save_pretrained()</code> 把它和它的分词器保存下来：",t,n,f,m,_="当你准备再次使用这个模型时，就可以使用 <code>PreTrainedModel.from_pretrained()</code> 加载它了：",v,C,R;return n=new J({props:{code:"cHRfc2F2ZV9kaXJlY3RvcnklMjAlM0QlMjAlMjIuJTJGcHRfc2F2ZV9wcmV0cmFpbmVkJTIyJTBBdG9rZW5pemVyLnNhdmVfcHJldHJhaW5lZChwdF9zYXZlX2RpcmVjdG9yeSklMEFwdF9tb2RlbC5zYXZlX3ByZXRyYWluZWQocHRfc2F2ZV9kaXJlY3Rvcnkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_save_directory = <span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(pt_save_directory)`,wrap:!1}}),C=new J({props:{code:"cHRfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjIuJTJGcHRfc2F2ZV9wcmV0cmFpbmVkJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>)',wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment),f=o(),m=y("p"),m.innerHTML=_,v=o(),d(C.$$.fragment)},l(j){s=b(j,"P",{"data-svelte-h":!0}),T(s)!=="svelte-xdox9p"&&(s.innerHTML=p),t=i(j),$(n.$$.fragment,j),f=i(j),m=b(j,"P",{"data-svelte-h":!0}),T(m)!=="svelte-g9zhes"&&(m.innerHTML=_),v=i(j),$(C.$$.fragment,j)},m(j,Z){r(j,s,Z),r(j,t,Z),u(n,j,Z),r(j,f,Z),r(j,m,Z),r(j,v,Z),u(C,j,Z),R=!0},p:I,i(j){R||(g(n.$$.fragment,j),g(C.$$.fragment,j),R=!0)},o(j){h(n.$$.fragment,j),h(C.$$.fragment,j),R=!1},d(j){j&&(a(s),a(t),a(f),a(m),a(v)),M(n,j),M(C,j)}}}function sn(w){let s,p;return s=new E({props:{$$slots:{default:[tn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function ln(w){let s,p="当你的模型微调完成，你就可以使用 <code>TFPreTrainedModel.save_pretrained()</code> 把它和它的分词器保存下来：",t,n,f,m,_="当你准备再次使用这个模型时，就可以使用 <code>TFPreTrainedModel.from_pretrained()</code> 加载它了：",v,C,R;return n=new J({props:{code:"dGZfc2F2ZV9kaXJlY3RvcnklMjAlM0QlMjAlMjIuJTJGdGZfc2F2ZV9wcmV0cmFpbmVkJTIyJTBBdG9rZW5pemVyLnNhdmVfcHJldHJhaW5lZCh0Zl9zYXZlX2RpcmVjdG9yeSklMEF0Zl9tb2RlbC5zYXZlX3ByZXRyYWluZWQodGZfc2F2ZV9kaXJlY3Rvcnkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_save_directory = <span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(tf_save_directory)`,wrap:!1}}),C=new J({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZ0Zl9zYXZlX3ByZXRyYWluZWQlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>)',wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment),f=o(),m=y("p"),m.innerHTML=_,v=o(),d(C.$$.fragment)},l(j){s=b(j,"P",{"data-svelte-h":!0}),T(s)!=="svelte-19ch297"&&(s.innerHTML=p),t=i(j),$(n.$$.fragment,j),f=i(j),m=b(j,"P",{"data-svelte-h":!0}),T(m)!=="svelte-izarei"&&(m.innerHTML=_),v=i(j),$(C.$$.fragment,j)},m(j,Z){r(j,s,Z),r(j,t,Z),u(n,j,Z),r(j,f,Z),r(j,m,Z),r(j,v,Z),u(C,j,Z),R=!0},p:I,i(j){R||(g(n.$$.fragment,j),g(C.$$.fragment,j),R=!0)},o(j){h(n.$$.fragment,j),h(C.$$.fragment,j),R=!1},d(j){j&&(a(s),a(t),a(f),a(m),a(v)),M(n,j),M(C,j)}}}function an(w){let s,p;return s=new E({props:{$$slots:{default:[ln]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function nn(w){let s,p;return s=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKHRmX3NhdmVfZGlyZWN0b3J5KSUwQXB0X21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQodGZfc2F2ZV9kaXJlY3RvcnklMkMlMjBmcm9tX3RmJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(tf_save_directory, from_tf=<span class="hljs-literal">True</span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function rn(w){let s,p;return s=new E({props:{$$slots:{default:[nn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function pn(w){let s,p;return s=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQocHRfc2F2ZV9kaXJlY3RvcnkpJTBBdGZfbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKHB0X3NhdmVfZGlyZWN0b3J5JTJDJTIwZnJvbV9wdCUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(pt_save_directory, from_pt=<span class="hljs-literal">True</span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p:I,i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function on(w){let s,p;return s=new E({props:{$$slots:{default:[pn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function mn(w){let s,p="使用 <code>AutoModel.from_config()</code> 根据你的自定义配置创建一个模型：",t,n,f;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQW15X21vZGVsJTIwJTNEJTIwQXV0b01vZGVsLmZyb21fY29uZmlnKG15X2NvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_model = AutoModel.from_config(my_config)`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),T(s)!=="svelte-kq2sqw"&&(s.innerHTML=p),t=i(m),$(n.$$.fragment,m)},m(m,_){r(m,s,_),r(m,t,_),u(n,m,_),f=!0},p:I,i(m){f||(g(n.$$.fragment,m),f=!0)},o(m){h(n.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(n,m)}}}function cn(w){let s,p;return s=new E({props:{$$slots:{default:[mn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function fn(w){let s,p="使用 <code>TFAutoModel.from_config()</code> 根据你的自定义配置创建一个模型：",t,n,f;return n=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsJTBBJTBBbXlfbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbC5mcm9tX2NvbmZpZyhteV9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_model = TFAutoModel.from_config(my_config)`,wrap:!1}}),{c(){s=y("p"),s.innerHTML=p,t=o(),d(n.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1obn2o6"&&(s.innerHTML=p),t=i(m),$(n.$$.fragment,m)},m(m,_){r(m,s,_),r(m,t,_),u(n,m,_),f=!0},p:I,i(m){f||(g(n.$$.fragment,m),f=!0)},o(m){h(n.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(n,m)}}}function dn(w){let s,p;return s=new E({props:{$$slots:{default:[fn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,n){u(s,t,n),p=!0},p(t,n){const f={};n&2&&(f.$$scope={dirty:n,ctx:t}),s.$set(f)},i(t){p||(g(s.$$.fragment,t),p=!0)},o(t){h(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function $n(w){let s,p="对于像翻译或摘要这些使用序列到序列模型的任务，用 <code>Seq2SeqTrainer</code> 和 <code>Seq2SeqTrainingArguments</code> 来替代。";return{c(){s=y("p"),s.innerHTML=p},l(t){s=b(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-d3rcx4"&&(s.innerHTML=p)},m(t,n){r(t,s,n)},p:I,d(t){t&&a(s)}}}function un(w){let s,p,t,n,f,m,_,v,C,R='快来使用 🤗 Transformers 吧！无论你是开发人员还是日常用户，这篇快速上手教程都将帮助你入门并且向你展示如何使用 <code>pipeline()</code> 进行推理，使用 <a href="./model_doc/auto">AutoClass</a> 加载一个预训练模型和预处理器，以及使用 PyTorch 或 TensorFlow 快速训练一个模型。如果你是一个初学者，我们建议你接下来查看我们的教程或者<a href="https://huggingface.co/course/chapter1/1" rel="nofollow">课程</a>，来更深入地了解在这里介绍到的概念。',j,Z,W="在开始之前，确保你已经安装了所有必要的库：",L,H,G,V,c="你还需要安装喜欢的机器学习框架：",k,x,Pt,te,Ot,se,Dt,le,Xl="使用 <code>pipeline()</code> 是利用预训练模型进行推理的最简单的方式。你能够将 <code>pipeline()</code> 开箱即用地用于跨不同模态的多种任务。来看看它支持的任务列表：",Kt,ae,Fl="<thead><tr><th><strong>任务</strong></th> <th><strong>描述</strong></th> <th><strong>模态</strong></th> <th><strong>Pipeline</strong></th></tr></thead> <tbody><tr><td>文本分类</td> <td>为给定的文本序列分配一个标签</td> <td>NLP</td> <td>pipeline(task=“sentiment-analysis”)</td></tr> <tr><td>文本生成</td> <td>根据给定的提示生成文本</td> <td>NLP</td> <td>pipeline(task=“text-generation”)</td></tr> <tr><td>命名实体识别</td> <td>为序列里的每个 token 分配一个标签（人, 组织, 地址等等）</td> <td>NLP</td> <td>pipeline(task=“ner”)</td></tr> <tr><td>问答系统</td> <td>通过给定的上下文和问题, 在文本中提取答案</td> <td>NLP</td> <td>pipeline(task=“question-answering”)</td></tr> <tr><td>掩盖填充</td> <td>预测出正确的在序列中被掩盖的token</td> <td>NLP</td> <td>pipeline(task=“fill-mask”)</td></tr> <tr><td>文本摘要</td> <td>为文本序列或文档生成总结</td> <td>NLP</td> <td>pipeline(task=“summarization”)</td></tr> <tr><td>文本翻译</td> <td>将文本从一种语言翻译为另一种语言</td> <td>NLP</td> <td>pipeline(task=“translation”)</td></tr> <tr><td>图像分类</td> <td>为图像分配一个标签</td> <td>Computer vision</td> <td>pipeline(task=“image-classification”)</td></tr> <tr><td>图像分割</td> <td>为图像中每个独立的像素分配标签（支持语义、全景和实例分割）</td> <td>Computer vision</td> <td>pipeline(task=“image-segmentation”)</td></tr> <tr><td>目标检测</td> <td>预测图像中目标对象的边界框和类别</td> <td>Computer vision</td> <td>pipeline(task=“object-detection”)</td></tr> <tr><td>音频分类</td> <td>给音频文件分配一个标签</td> <td>Audio</td> <td>pipeline(task=“audio-classification”)</td></tr> <tr><td>自动语音识别</td> <td>将音频文件中的语音提取为文本</td> <td>Audio</td> <td>pipeline(task=“automatic-speech-recognition”)</td></tr> <tr><td>视觉问答</td> <td>给定一个图像和一个问题，正确地回答有关图像的问题</td> <td>Multimodal</td> <td>pipeline(task=“vqa”)</td></tr></tbody>",es,ne,Nl='创建一个 <code>pipeline()</code> 实例并且指定你想要将它用于的任务，就可以开始了。你可以将 <code>pipeline()</code> 用于任何一个上面提到的任务，如果想知道支持的任务的完整列表，可以查阅 <a href="./main_classes/pipelines">pipeline API 参考</a>。不过, 在这篇教程中，你将把 <code>pipeline()</code> 用在一个情感分析示例上：',ts,re,ss,pe,xl='<code>pipeline()</code> 会下载并缓存一个用于情感分析的默认的<a href="https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english" rel="nofollow">预训练模型</a>和分词器。现在你可以在目标文本上使用 <code>classifier</code> 了：',ls,oe,as,ie,zl="如果你有不止一个输入，可以把所有输入放入一个列表然后传给<code>pipeline()</code>，它将会返回一个字典列表：",ns,me,rs,ce,El="<code>pipeline()</code> 也可以为任何你喜欢的任务遍历整个数据集。在下面这个示例中，让我们选择自动语音识别作为我们的任务：",ps,fe,os,de,Bl='加载一个你想遍历的音频数据集（查阅 🤗 Datasets <a href="https://huggingface.co/docs/datasets/quickstart#audio" rel="nofollow">快速开始</a> 获得更多信息）。比如，加载 <a href="https://huggingface.co/datasets/PolyAI/minds14" rel="nofollow">MInDS-14</a> 数据集：',is,$e,ms,ue,Yl='你需要确保数据集中的音频的采样率与 <a href="https://huggingface.co/facebook/wav2vec2-base-960h" rel="nofollow"><code>facebook/wav2vec2-base-960h</code></a> 训练用到的音频的采样率一致：',cs,ge,fs,he,Ll=`当调用 <code>&quot;audio&quot;</code> 列时, 音频文件将会自动加载并重采样。
从前四个样本中提取原始波形数组，将它作为列表传给 pipeline：`,ds,Me,$s,ye,Al='对于输入非常庞大的大型数据集（比如语音或视觉），你会想到使用一个生成器，而不是一个将所有输入都加载进内存的列表。查阅 <a href="./main_classes/pipelines">pipeline API 参考</a> 来获取更多信息。',us,be,gs,je,Ql='<code>pipeline()</code> 可以容纳 <a href="https://huggingface.co/models" rel="nofollow">Hub</a> 中的任何模型，这让 <code>pipeline()</code> 更容易适用于其他用例。比如，你想要一个能够处理法语文本的模型，就可以使用 Hub 上的标记来筛选出合适的模型。靠前的筛选结果会返回一个为情感分析微调的多语言的 <a href="https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment" rel="nofollow">BERT 模型</a>，你可以将它用于法语文本：',hs,Te,Ms,A,ys,we,ql="在 <code>pipeline()</code> 中指定模型和分词器，现在你就可以在法语文本上使用 <code>classifier</code> 了：",bs,Je,js,Ue,Sl='如果你没有找到适合你的模型，就需要在你的数据上微调一个预训练模型了。查看 <a href="./training">微调教程</a> 来学习怎样进行微调。最后，微调完模型后，考虑一下在 Hub 上与社区 <a href="./model_sharing">分享</a> 这个模型，把机器学习普及到每一个人! 🤗',Ts,_e,ws,ke,Js,Ze,Pl='在幕后，是由 <code>AutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 一起支持你在上面用到的 <code>pipeline()</code>。<a href="./model_doc/auto">AutoClass</a> 是一个能够通过预训练模型的名称或路径自动查找其架构的快捷方式。你只需要为你的任务选择合适的 <code>AutoClass</code> 和它关联的预处理类。',Us,ve,Ol="让我们回过头来看上一节的示例，看看怎样使用 <code>AutoClass</code> 来重现使用 <code>pipeline()</code> 的结果。",_s,Ce,ks,Re,Dl='分词器负责预处理文本，将文本转换为用于输入模型的数字数组。有多个用来管理分词过程的规则，包括如何拆分单词和在什么样的级别上拆分单词（在 <a href="./tokenizer_summary">分词器总结</a> 学习更多关于分词的信息）。要记住最重要的是你需要实例化的分词器要与模型的名称相同, 来确保和模型训练时使用相同的分词规则。',Zs,Ge,Kl="使用 <code>AutoTokenizer</code> 加载一个分词器:",vs,We,Cs,He,ea="将文本传入分词器：",Rs,Ve,Gs,Ie,ta="分词器返回了含有如下内容的字典:",Ws,Xe,sa='<li><a href="./glossary#input-ids">input_ids</a>：用数字表示的 token。</li> <li><a href=".glossary#attention-mask">attention_mask</a>：应该关注哪些 token 的指示。</li>',Hs,Fe,la="分词器也可以接受列表作为输入，并填充和截断文本，返回具有统一长度的批次：",Vs,Q,Is,q,Xs,Ne,Fs,S,Ns,P,xs,xe,zs,O,Es,ze,aa="🤗 Transformers 有一个特别酷的功能，它能够保存一个模型，并且将它加载为 PyTorch 或 TensorFlow 模型。<code>from_pt</code> 或 <code>from_tf</code> 参数可以将模型从一个框架转换为另一个框架：",Bs,D,Ys,Ee,Ls,Be,na="你可以修改模型的配置类来改变模型的构建方式。配置指明了模型的属性，比如隐藏层或者注意力头的数量。当你从自定义的配置类初始化模型时，你就开始自定义模型构建了。模型属性是随机初始化的，你需要先训练模型，然后才能得到有意义的结果。",As,Ye,ra="通过导入 <code>AutoConfig</code> 来开始，之后加载你想修改的预训练模型。在 <code>AutoConfig.from_pretrained()</code> 中，你能够指定想要修改的属性，比如注意力头的数量：",Qs,Le,qs,K,Ss,Ae,pa='查阅 <a href="./create_a_model">创建一个自定义结构</a> 指南获取更多关于构建自定义配置的信息。',Ps,Qe,Os,qe,oa='所有的模型都是标准的 <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow"><code>torch.nn.Module</code></a>，所以你可以在任何典型的训练模型中使用它们。当你编写自己的训练循环时，🤗 Transformers 为 PyTorch 提供了一个 <code>Trainer</code> 类，它包含了基础的训练循环并且为诸如分布式训练，混合精度等特性增加了额外的功能。',Ds,Se,ia="取决于你的任务, 你通常可以传递以下的参数给 <code>Trainer</code>：",Ks,X,Pe,Xt,ma='<code>PreTrainedModel</code> 或者 <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow"><code>torch.nn.Module</code></a>：',hl,Oe,Ml,De,Ft,ca="<code>TrainingArguments</code> 含有你可以修改的模型超参数，比如学习率，批次大小和训练时的迭代次数。如果你没有指定训练参数，那么它会使用默认值：",yl,Ke,bl,et,Nt,fa="一个预处理类，比如分词器，特征提取器或者处理器：",jl,tt,Tl,st,xt,da="加载一个数据集：",wl,lt,Jl,at,zt,$a="创建一个给数据集分词的函数，并且使用 <code>map</code> 应用到整个数据集：",Ul,nt,_l,rt,Et,ua="用来从数据集中创建批次的 <code>DataCollatorWithPadding</code>：",kl,pt,el,ot,ga="现在把所有的类传给 <code>Trainer</code>：",tl,it,sl,mt,ha="一切准备就绪后，调用 <code>train()</code> 进行训练：",ll,ct,al,ee,nl,ft,Ma="你可以通过子类化 <code>Trainer</code> 中的方法来自定义训练循环。这样你就可以自定义像损失函数，优化器和调度器这样的特性。查阅 <code>Trainer</code> 参考手册了解哪些方法能够被子类化。",rl,dt,ya='另一个自定义训练循环的方式是通过<a href="./main_classes/callbacks">回调</a>。你可以使用回调来与其他库集成，查看训练循环来报告进度或提前结束训练。回调不会修改训练循环。如果想自定义损失函数等，就需要子类化 <code>Trainer</code> 了。',pl,$t,ol,ut,ba='所有模型都是标准的 <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow"><code>tf.keras.Model</code></a>，所以你可以通过 <a href="https://keras.io/" rel="nofollow">Keras</a> API 实现在 Tensorflow 中训练。🤗 Transformers 提供了 <code>prepare_tf_dataset()</code> 方法来轻松地将数据集加载为 <code>tf.data.Dataset</code>，这样你就可以使用 Keras 的 <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> 和 <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> 方法马上开始训练。',il,z,gt,Bt,ja='使用 <code>TFPreTrainedModel</code> 或者 <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow"><code>tf.keras.Model</code></a> 来开始：',Zl,ht,vl,Mt,Yt,Ta="一个预处理类，比如分词器，特征提取器或者处理器：",Cl,yt,Rl,bt,Lt,wa="创建一个给数据集分词的函数",Gl,jt,Wl,Tt,At,Ja="使用 <code>map</code> 将分词器应用到整个数据集，之后将数据集和分词器传给 <code>prepare_tf_dataset()</code>。如果你需要的话，也可以在这里改变批次大小和是否打乱数据集：",Hl,wt,Vl,Jt,Qt,Ua="一切准备就绪后，调用 <code>compile</code> 和 <code>fit</code> 开始训练：",Il,Ut,ml,_t,cl,kt,_a="现在你已经完成了 🤗 Transformers 的快速上手教程，来看看我们的指南并且学习如何做一些更具体的事情，比如写一个自定义模型，为某个任务微调一个模型以及如何使用脚本来训练模型。如果你有兴趣了解更多 🤗 Transformers 的核心章节，那就喝杯咖啡然后来看看我们的概念指南吧！",fl,qt,dl;return f=new Y({props:{title:"快速上手",local:"快速上手",headingTag:"h1"}}),_=new Ha({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/zh/quicktour.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/zh/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/zh/tensorflow/quicktour.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/zh/quicktour.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/zh/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/zh/tensorflow/quicktour.ipynb"}]}}),H=new J({props:{code:"IXBpcCUyMGluc3RhbGwlMjB0cmFuc2Zvcm1lcnMlMjBkYXRhc2V0cw==",highlighted:"!pip install transformers datasets",wrap:!1}}),x=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Fa],pytorch:[Ia]},$$scope:{ctx:w}}}),te=new Y({props:{title:"Pipeline",local:"pipeline",headingTag:"h2"}}),se=new Za({props:{id:"tiZFewofSLM"}}),re=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMnNlbnRpbWVudC1hbmFseXNpcyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)`,wrap:!1}}),oe=new J({props:{code:"Y2xhc3NpZmllciglMjJXZSUyMGFyZSUyMHZlcnklMjBoYXBweSUyMHRvJTIwc2hvdyUyMHlvdSUyMHRoZSUyMCVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycyUyMGxpYnJhcnkuJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;We are very happy to show you the 🤗 Transformers library.&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9998</span>}]`,wrap:!1}}),me=new J({props:{code:"cmVzdWx0cyUyMCUzRCUyMGNsYXNzaWZpZXIoJTVCJTIyV2UlMjBhcmUlMjB2ZXJ5JTIwaGFwcHklMjB0byUyMHNob3clMjB5b3UlMjB0aGUlMjAlRjAlOUYlQTQlOTclMjBUcmFuc2Zvcm1lcnMlMjBsaWJyYXJ5LiUyMiUyQyUyMCUyMldlJTIwaG9wZSUyMHlvdSUyMGRvbid0JTIwaGF0ZSUyMGl0LiUyMiU1RCklMEFmb3IlMjByZXN1bHQlMjBpbiUyMHJlc3VsdHMlM0ElMEElMjAlMjAlMjAlMjBwcmludChmJTIybGFiZWwlM0ElMjAlN0JyZXN1bHQlNUInbGFiZWwnJTVEJTdEJTJDJTIwd2l0aCUyMHNjb3JlJTNBJTIwJTdCcm91bmQocmVzdWx0JTVCJ3Njb3JlJyU1RCUyQyUyMDQpJTdEJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>results = classifier([<span class="hljs-string">&quot;We are very happy to show you the 🤗 Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> result <span class="hljs-keyword">in</span> results:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;label: <span class="hljs-subst">{result[<span class="hljs-string">&#x27;label&#x27;</span>]}</span>, with score: <span class="hljs-subst">{<span class="hljs-built_in">round</span>(result[<span class="hljs-string">&#x27;score&#x27;</span>], <span class="hljs-number">4</span>)}</span>&quot;</span>)
label: POSITIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.9998</span>
label: NEGATIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.5309</span>`,wrap:!1}}),fe=new J({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEElMEFzcGVlY2hfcmVjb2duaXplciUyMCUzRCUyMHBpcGVsaW5lKCUyMmF1dG9tYXRpYy1zcGVlY2gtcmVjb2duaXRpb24lMjIlMkMlMjBtb2RlbCUzRCUyMmZhY2Vib29rJTJGd2F2MnZlYzItYmFzZS05NjBoJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>speech_recognizer = pipeline(<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;facebook/wav2vec2-base-960h&quot;</span>)`,wrap:!1}}),$e=new J({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMlBvbHlBSSUyRm1pbmRzMTQlMjIlMkMlMjBuYW1lJTNEJTIyZW4tVVMlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`,wrap:!1}}),ge=new J({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQuY2FzdF9jb2x1bW4oJTIyYXVkaW8lMjIlMkMlMjBBdWRpbyhzYW1wbGluZ19yYXRlJTNEc3BlZWNoX3JlY29nbml6ZXIuZmVhdHVyZV9leHRyYWN0b3Iuc2FtcGxpbmdfcmF0ZSkp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))',wrap:!1}}),Me=new J({props:{code:"cmVzdWx0JTIwJTNEJTIwc3BlZWNoX3JlY29nbml6ZXIoZGF0YXNldCU1QiUzQTQlNUQlNUIlMjJhdWRpbyUyMiU1RCklMEFwcmludCglNUJkJTVCJTIydGV4dCUyMiU1RCUyMGZvciUyMGQlMjBpbiUyMHJlc3VsdCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>result = speech_recognizer(dataset[:<span class="hljs-number">4</span>][<span class="hljs-string">&quot;audio&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>([d[<span class="hljs-string">&quot;text&quot;</span>] <span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> result])
[<span class="hljs-string">&#x27;I WOULD LIKE TO SET UP A JOINT ACCOUNT WITH MY PARTNER HOW DO I PROCEED WITH DOING THAT&#x27;</span>, <span class="hljs-string">&quot;FODING HOW I&#x27;D SET UP A JOIN TO HET WITH MY WIFE AND WHERE THE AP MIGHT BE&quot;</span>, <span class="hljs-string">&quot;I I&#x27;D LIKE TOY SET UP A JOINT ACCOUNT WITH MY PARTNER I&#x27;M NOT SEEING THE OPTION TO DO IT ON THE AP SO I CALLED IN TO GET SOME HELP CAN I JUST DO IT OVER THE PHONE WITH YOU AND GIVE YOU THE INFORMATION OR SHOULD I DO IT IN THE AP AND I&#x27;M MISSING SOMETHING UQUETTE HAD PREFERRED TO JUST DO IT OVER THE PHONE OF POSSIBLE THINGS&quot;</span>, <span class="hljs-string">&#x27;HOW DO I THURN A JOIN A COUNT&#x27;</span>]`,wrap:!1}}),be=new Y({props:{title:"在 pipeline 中使用另一个模型和分词器",local:"在-pipeline-中使用另一个模型和分词器",headingTag:"h3"}}),Te=new J({props:{code:"bW9kZWxfbmFtZSUyMCUzRCUyMCUyMm5scHRvd24lMkZiZXJ0LWJhc2UtbXVsdGlsaW5ndWFsLXVuY2FzZWQtc2VudGltZW50JTIy",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>',wrap:!1}}),A=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ea],pytorch:[xa]},$$scope:{ctx:w}}}),Je=new J({props:{code:"Y2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMnNlbnRpbWVudC1hbmFseXNpcyUyMiUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIpJTBBY2xhc3NpZmllciglMjJOb3VzJTIwc29tbWVzJTIwdHIlQzMlQThzJTIwaGV1cmV1eCUyMGRlJTIwdm91cyUyMHByJUMzJUE5c2VudGVyJTIwbGElMjBiaWJsaW90aCVDMyVBOHF1ZSUyMCVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycy4lMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>, model=model, tokenizer=tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;Nous sommes très heureux de vous présenter la bibliothèque 🤗 Transformers.&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;5 stars&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.7273</span>}]`,wrap:!1}}),_e=new Y({props:{title:"AutoClass",local:"autoclass",headingTag:"h2"}}),ke=new Za({props:{id:"AhChOFRegn4"}}),Ce=new Y({props:{title:"AutoTokenizer",local:"autotokenizer",headingTag:"h3"}}),We=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFtb2RlbF9uYW1lJTIwJTNEJTIwJTIybmxwdG93biUyRmJlcnQtYmFzZS1tdWx0aWxpbmd1YWwtdW5jYXNlZC1zZW50aW1lbnQlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9uYW1lKQ==",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>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`,wrap:!1}}),Ve=new J({props:{code:"ZW5jb2RpbmclMjAlM0QlMjB0b2tlbml6ZXIoJTIyV2UlMjBhcmUlMjB2ZXJ5JTIwaGFwcHklMjB0byUyMHNob3clMjB5b3UlMjB0aGUlMjAlRjAlOUYlQTQlOTclMjBUcmFuc2Zvcm1lcnMlMjBsaWJyYXJ5LiUyMiklMEFwcmludChlbmNvZGluZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot;We are very happy to show you the 🤗 Transformers library.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoding)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">11312</span>, <span class="hljs-number">10320</span>, <span class="hljs-number">12495</span>, <span class="hljs-number">19308</span>, <span class="hljs-number">10114</span>, <span class="hljs-number">11391</span>, <span class="hljs-number">10855</span>, <span class="hljs-number">10103</span>, <span class="hljs-number">100</span>, <span class="hljs-number">58263</span>, <span class="hljs-number">13299</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]}`,wrap:!1}}),Q=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Aa],pytorch:[Ya]},$$scope:{ctx:w}}}),q=new St({props:{$$slots:{default:[Qa]},$$scope:{ctx:w}}}),Ne=new Y({props:{title:"AutoModel",local:"automodel",headingTag:"h3"}}),S=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ka],pytorch:[Pa]},$$scope:{ctx:w}}}),P=new St({props:{$$slots:{default:[en]},$$scope:{ctx:w}}}),xe=new Y({props:{title:"保存模型",local:"保存模型",headingTag:"h3"}}),O=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[an],pytorch:[sn]},$$scope:{ctx:w}}}),D=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[on],pytorch:[rn]},$$scope:{ctx:w}}}),Ee=new Y({props:{title:"自定义模型构建",local:"自定义模型构建",headingTag:"h2"}}),Le=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFteV9jb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMG5faGVhZHMlM0QxMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, n_heads=<span class="hljs-number">12</span>)`,wrap:!1}}),K=new It({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[dn],pytorch:[cn]},$$scope:{ctx:w}}}),Qe=new Y({props:{title:"Trainer - PyTorch 优化训练循环",local:"trainer---pytorch-优化训练循环",headingTag:"h2"}}),Oe=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),Ke=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJwYXRoJTJGdG8lMkZzYXZlJTJGZm9sZGVyJTJGJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0Q4JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0Q4JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDIlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;path/to/save/folder/&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),tt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),lt=new J({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJyb3R0ZW5fdG9tYXRvZXMlMjIpJTIwJTIwJTIzJTIwZG9jdGVzdCUzQSUyMCUyQklHTk9SRV9SRVNVTFQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;rotten_tomatoes&quot;</span>)  <span class="hljs-comment"># doctest: +IGNORE_RESULT</span>`,wrap:!1}}),nt=new J({props:{code:"ZGVmJTIwdG9rZW5pemVfZGF0YXNldChkYXRhc2V0KSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHRva2VuaXplcihkYXRhc2V0JTVCJTIydGV4dCUyMiU1RCklMEElMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5tYXAodG9rZW5pemVfZGF0YXNldCUyQyUyMGJhdGNoZWQlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">dataset</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(dataset[<span class="hljs-string">&quot;text&quot;</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset, batched=<span class="hljs-literal">True</span>)`,wrap:!1}}),pt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`,wrap:!1}}),it=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluZXIlMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMjAlMjAlMjMlMjBkb2N0ZXN0JTNBJTIwJTJCU0tJUA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># doctest: +SKIP</span>`,wrap:!1}}),ct=new J({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()',wrap:!1}}),ee=new St({props:{$$slots:{default:[$n]},$$scope:{ctx:w}}}),$t=new Y({props:{title:"使用 Tensorflow 训练",local:"使用-tensorflow-训练",headingTag:"h2"}}),ht=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),yt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),jt=new J({props:{code:"ZGVmJTIwdG9rZW5pemVfZGF0YXNldChkYXRhc2V0KSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHRva2VuaXplcihkYXRhc2V0JTVCJTIydGV4dCUyMiU1RCklMjAlMjAlMjMlMjBkb2N0ZXN0JTNBJTIwJTJCU0tJUA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">dataset</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(dataset[<span class="hljs-string">&quot;text&quot;</span>])  <span class="hljs-comment"># doctest: +SKIP</span>`,wrap:!1}}),wt=new J({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQubWFwKHRva2VuaXplX2RhdGFzZXQpJTIwJTIwJTIzJTIwZG9jdGVzdCUzQSUyMCUyQlNLSVAlMEF0Zl9kYXRhc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGRhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEMTYlMkMlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUyMHRva2VuaXplciUzRHRva2VuaXplciUwQSklMjAlMjAlMjMlMjBkb2N0ZXN0JTNBJTIwJTJCU0tJUA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)  <span class="hljs-comment"># doctest: +SKIP</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    dataset, batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># doctest: +SKIP</span>`,wrap:!1}}),Ut=new J({props:{code:"ZnJvbSUyMHRlbnNvcmZsb3cua2VyYXMub3B0aW1pemVycyUyMGltcG9ydCUyMEFkYW0lMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzREFkYW0oM2UtNSkpJTBBbW9kZWwuZml0KGRhdGFzZXQpJTIwJTIwJTIzJTIwZG9jdGVzdCUzQSUyMCUyQlNLSVA=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(dataset)  <span class="hljs-comment"># doctest: +SKIP</span>`,wrap:!1}}),_t=new Y({props:{title:"接下来做什么?",local:"接下来做什么",headingTag:"h2"}}),{c(){s=y("meta"),p=o(),t=y("p"),n=o(),d(f.$$.fragment),m=o(),d(_.$$.fragment),v=o(),C=y("p"),C.innerHTML=R,j=o(),Z=y("p"),Z.textContent=W,L=o(),d(H.$$.fragment),G=o(),V=y("p"),V.textContent=c,k=o(),d(x.$$.fragment),Pt=o(),d(te.$$.fragment),Ot=o(),d(se.$$.fragment),Dt=o(),le=y("p"),le.innerHTML=Xl,Kt=o(),ae=y("table"),ae.innerHTML=Fl,es=o(),ne=y("p"),ne.innerHTML=Nl,ts=o(),d(re.$$.fragment),ss=o(),pe=y("p"),pe.innerHTML=xl,ls=o(),d(oe.$$.fragment),as=o(),ie=y("p"),ie.innerHTML=zl,ns=o(),d(me.$$.fragment),rs=o(),ce=y("p"),ce.innerHTML=El,ps=o(),d(fe.$$.fragment),os=o(),de=y("p"),de.innerHTML=Bl,is=o(),d($e.$$.fragment),ms=o(),ue=y("p"),ue.innerHTML=Yl,cs=o(),d(ge.$$.fragment),fs=o(),he=y("p"),he.innerHTML=Ll,ds=o(),d(Me.$$.fragment),$s=o(),ye=y("p"),ye.innerHTML=Al,us=o(),d(be.$$.fragment),gs=o(),je=y("p"),je.innerHTML=Ql,hs=o(),d(Te.$$.fragment),Ms=o(),d(A.$$.fragment),ys=o(),we=y("p"),we.innerHTML=ql,bs=o(),d(Je.$$.fragment),js=o(),Ue=y("p"),Ue.innerHTML=Sl,Ts=o(),d(_e.$$.fragment),ws=o(),d(ke.$$.fragment),Js=o(),Ze=y("p"),Ze.innerHTML=Pl,Us=o(),ve=y("p"),ve.innerHTML=Ol,_s=o(),d(Ce.$$.fragment),ks=o(),Re=y("p"),Re.innerHTML=Dl,Zs=o(),Ge=y("p"),Ge.innerHTML=Kl,vs=o(),d(We.$$.fragment),Cs=o(),He=y("p"),He.textContent=ea,Rs=o(),d(Ve.$$.fragment),Gs=o(),Ie=y("p"),Ie.textContent=ta,Ws=o(),Xe=y("ul"),Xe.innerHTML=sa,Hs=o(),Fe=y("p"),Fe.textContent=la,Vs=o(),d(Q.$$.fragment),Is=o(),d(q.$$.fragment),Xs=o(),d(Ne.$$.fragment),Fs=o(),d(S.$$.fragment),Ns=o(),d(P.$$.fragment),xs=o(),d(xe.$$.fragment),zs=o(),d(O.$$.fragment),Es=o(),ze=y("p"),ze.innerHTML=aa,Bs=o(),d(D.$$.fragment),Ys=o(),d(Ee.$$.fragment),Ls=o(),Be=y("p"),Be.textContent=na,As=o(),Ye=y("p"),Ye.innerHTML=ra,Qs=o(),d(Le.$$.fragment),qs=o(),d(K.$$.fragment),Ss=o(),Ae=y("p"),Ae.innerHTML=pa,Ps=o(),d(Qe.$$.fragment),Os=o(),qe=y("p"),qe.innerHTML=oa,Ds=o(),Se=y("p"),Se.innerHTML=ia,Ks=o(),X=y("ol"),Pe=y("li"),Xt=y("p"),Xt.innerHTML=ma,hl=o(),d(Oe.$$.fragment),Ml=o(),De=y("li"),Ft=y("p"),Ft.innerHTML=ca,yl=o(),d(Ke.$$.fragment),bl=o(),et=y("li"),Nt=y("p"),Nt.textContent=fa,jl=o(),d(tt.$$.fragment),Tl=o(),st=y("li"),xt=y("p"),xt.textContent=da,wl=o(),d(lt.$$.fragment),Jl=o(),at=y("li"),zt=y("p"),zt.innerHTML=$a,Ul=o(),d(nt.$$.fragment),_l=o(),rt=y("li"),Et=y("p"),Et.innerHTML=ua,kl=o(),d(pt.$$.fragment),el=o(),ot=y("p"),ot.innerHTML=ga,tl=o(),d(it.$$.fragment),sl=o(),mt=y("p"),mt.innerHTML=ha,ll=o(),d(ct.$$.fragment),al=o(),d(ee.$$.fragment),nl=o(),ft=y("p"),ft.innerHTML=Ma,rl=o(),dt=y("p"),dt.innerHTML=ya,pl=o(),d($t.$$.fragment),ol=o(),ut=y("p"),ut.innerHTML=ba,il=o(),z=y("ol"),gt=y("li"),Bt=y("p"),Bt.innerHTML=ja,Zl=o(),d(ht.$$.fragment),vl=o(),Mt=y("li"),Yt=y("p"),Yt.textContent=Ta,Cl=o(),d(yt.$$.fragment),Rl=o(),bt=y("li"),Lt=y("p"),Lt.textContent=wa,Gl=o(),d(jt.$$.fragment),Wl=o(),Tt=y("li"),At=y("p"),At.innerHTML=Ja,Hl=o(),d(wt.$$.fragment),Vl=o(),Jt=y("li"),Qt=y("p"),Qt.innerHTML=Ua,Il=o(),d(Ut.$$.fragment),ml=o(),d(_t.$$.fragment),cl=o(),kt=y("p"),kt.textContent=_a,fl=o(),qt=y("p"),this.h()},l(e){const l=Wa("svelte-u9bgzb",document.head);s=b(l,"META",{name:!0,content:!0}),l.forEach(a),p=i(e),t=b(e,"P",{}),N(t).forEach(a),n=i(e),$(f.$$.fragment,e),m=i(e),$(_.$$.fragment,e),v=i(e),C=b(e,"P",{"data-svelte-h":!0}),T(C)!=="svelte-ozukm6"&&(C.innerHTML=R),j=i(e),Z=b(e,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-10awe57"&&(Z.textContent=W),L=i(e),$(H.$$.fragment,e),G=i(e),V=b(e,"P",{"data-svelte-h":!0}),T(V)!=="svelte-1qrldcv"&&(V.textContent=c),k=i(e),$(x.$$.fragment,e),Pt=i(e),$(te.$$.fragment,e),Ot=i(e),$(se.$$.fragment,e),Dt=i(e),le=b(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-1eb0a9c"&&(le.innerHTML=Xl),Kt=i(e),ae=b(e,"TABLE",{"data-svelte-h":!0}),T(ae)!=="svelte-1cgfltn"&&(ae.innerHTML=Fl),es=i(e),ne=b(e,"P",{"data-svelte-h":!0}),T(ne)!=="svelte-gnf68l"&&(ne.innerHTML=Nl),ts=i(e),$(re.$$.fragment,e),ss=i(e),pe=b(e,"P",{"data-svelte-h":!0}),T(pe)!=="svelte-1budadw"&&(pe.innerHTML=xl),ls=i(e),$(oe.$$.fragment,e),as=i(e),ie=b(e,"P",{"data-svelte-h":!0}),T(ie)!=="svelte-f3tkn3"&&(ie.innerHTML=zl),ns=i(e),$(me.$$.fragment,e),rs=i(e),ce=b(e,"P",{"data-svelte-h":!0}),T(ce)!=="svelte-1of5afq"&&(ce.innerHTML=El),ps=i(e),$(fe.$$.fragment,e),os=i(e),de=b(e,"P",{"data-svelte-h":!0}),T(de)!=="svelte-1x73msc"&&(de.innerHTML=Bl),is=i(e),$($e.$$.fragment,e),ms=i(e),ue=b(e,"P",{"data-svelte-h":!0}),T(ue)!=="svelte-1xxvdtf"&&(ue.innerHTML=Yl),cs=i(e),$(ge.$$.fragment,e),fs=i(e),he=b(e,"P",{"data-svelte-h":!0}),T(he)!=="svelte-pyqv34"&&(he.innerHTML=Ll),ds=i(e),$(Me.$$.fragment,e),$s=i(e),ye=b(e,"P",{"data-svelte-h":!0}),T(ye)!=="svelte-1cip30a"&&(ye.innerHTML=Al),us=i(e),$(be.$$.fragment,e),gs=i(e),je=b(e,"P",{"data-svelte-h":!0}),T(je)!=="svelte-1whjot2"&&(je.innerHTML=Ql),hs=i(e),$(Te.$$.fragment,e),Ms=i(e),$(A.$$.fragment,e),ys=i(e),we=b(e,"P",{"data-svelte-h":!0}),T(we)!=="svelte-1bwseje"&&(we.innerHTML=ql),bs=i(e),$(Je.$$.fragment,e),js=i(e),Ue=b(e,"P",{"data-svelte-h":!0}),T(Ue)!=="svelte-uyj2qy"&&(Ue.innerHTML=Sl),Ts=i(e),$(_e.$$.fragment,e),ws=i(e),$(ke.$$.fragment,e),Js=i(e),Ze=b(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1fbekzg"&&(Ze.innerHTML=Pl),Us=i(e),ve=b(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-iw2osk"&&(ve.innerHTML=Ol),_s=i(e),$(Ce.$$.fragment,e),ks=i(e),Re=b(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-pupyjv"&&(Re.innerHTML=Dl),Zs=i(e),Ge=b(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-1iigdiw"&&(Ge.innerHTML=Kl),vs=i(e),$(We.$$.fragment,e),Cs=i(e),He=b(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-bt7849"&&(He.textContent=ea),Rs=i(e),$(Ve.$$.fragment,e),Gs=i(e),Ie=b(e,"P",{"data-svelte-h":!0}),T(Ie)!=="svelte-1dcb4pt"&&(Ie.textContent=ta),Ws=i(e),Xe=b(e,"UL",{"data-svelte-h":!0}),T(Xe)!=="svelte-1hv4uqa"&&(Xe.innerHTML=sa),Hs=i(e),Fe=b(e,"P",{"data-svelte-h":!0}),T(Fe)!=="svelte-hbhd9z"&&(Fe.textContent=la),Vs=i(e),$(Q.$$.fragment,e),Is=i(e),$(q.$$.fragment,e),Xs=i(e),$(Ne.$$.fragment,e),Fs=i(e),$(S.$$.fragment,e),Ns=i(e),$(P.$$.fragment,e),xs=i(e),$(xe.$$.fragment,e),zs=i(e),$(O.$$.fragment,e),Es=i(e),ze=b(e,"P",{"data-svelte-h":!0}),T(ze)!=="svelte-rne23r"&&(ze.innerHTML=aa),Bs=i(e),$(D.$$.fragment,e),Ys=i(e),$(Ee.$$.fragment,e),Ls=i(e),Be=b(e,"P",{"data-svelte-h":!0}),T(Be)!=="svelte-1v6i9vn"&&(Be.textContent=na),As=i(e),Ye=b(e,"P",{"data-svelte-h":!0}),T(Ye)!=="svelte-15b3fgp"&&(Ye.innerHTML=ra),Qs=i(e),$(Le.$$.fragment,e),qs=i(e),$(K.$$.fragment,e),Ss=i(e),Ae=b(e,"P",{"data-svelte-h":!0}),T(Ae)!=="svelte-n1ja8b"&&(Ae.innerHTML=pa),Ps=i(e),$(Qe.$$.fragment,e),Os=i(e),qe=b(e,"P",{"data-svelte-h":!0}),T(qe)!=="svelte-1bwvvy5"&&(qe.innerHTML=oa),Ds=i(e),Se=b(e,"P",{"data-svelte-h":!0}),T(Se)!=="svelte-1mmhf7y"&&(Se.innerHTML=ia),Ks=i(e),X=b(e,"OL",{});var F=N(X);Pe=b(F,"LI",{});var Zt=N(Pe);Xt=b(Zt,"P",{"data-svelte-h":!0}),T(Xt)!=="svelte-ruv62q"&&(Xt.innerHTML=ma),hl=i(Zt),$(Oe.$$.fragment,Zt),Zt.forEach(a),Ml=i(F),De=b(F,"LI",{});var vt=N(De);Ft=b(vt,"P",{"data-svelte-h":!0}),T(Ft)!=="svelte-gaji1x"&&(Ft.innerHTML=ca),yl=i(vt),$(Ke.$$.fragment,vt),vt.forEach(a),bl=i(F),et=b(F,"LI",{});var Ct=N(et);Nt=b(Ct,"P",{"data-svelte-h":!0}),T(Nt)!=="svelte-hspqy3"&&(Nt.textContent=fa),jl=i(Ct),$(tt.$$.fragment,Ct),Ct.forEach(a),Tl=i(F),st=b(F,"LI",{});var Rt=N(st);xt=b(Rt,"P",{"data-svelte-h":!0}),T(xt)!=="svelte-wmvqzp"&&(xt.textContent=da),wl=i(Rt),$(lt.$$.fragment,Rt),Rt.forEach(a),Jl=i(F),at=b(F,"LI",{});var Gt=N(at);zt=b(Gt,"P",{"data-svelte-h":!0}),T(zt)!=="svelte-nju1yy"&&(zt.innerHTML=$a),Ul=i(Gt),$(nt.$$.fragment,Gt),Gt.forEach(a),_l=i(F),rt=b(F,"LI",{});var Wt=N(rt);Et=b(Wt,"P",{"data-svelte-h":!0}),T(Et)!=="svelte-1iom2zz"&&(Et.innerHTML=ua),kl=i(Wt),$(pt.$$.fragment,Wt),Wt.forEach(a),F.forEach(a),el=i(e),ot=b(e,"P",{"data-svelte-h":!0}),T(ot)!=="svelte-15smi2d"&&(ot.innerHTML=ga),tl=i(e),$(it.$$.fragment,e),sl=i(e),mt=b(e,"P",{"data-svelte-h":!0}),T(mt)!=="svelte-1si5m9v"&&(mt.innerHTML=ha),ll=i(e),$(ct.$$.fragment,e),al=i(e),$(ee.$$.fragment,e),nl=i(e),ft=b(e,"P",{"data-svelte-h":!0}),T(ft)!=="svelte-gx0dd1"&&(ft.innerHTML=Ma),rl=i(e),dt=b(e,"P",{"data-svelte-h":!0}),T(dt)!=="svelte-814nns"&&(dt.innerHTML=ya),pl=i(e),$($t.$$.fragment,e),ol=i(e),ut=b(e,"P",{"data-svelte-h":!0}),T(ut)!=="svelte-22aao9"&&(ut.innerHTML=ba),il=i(e),z=b(e,"OL",{});var B=N(z);gt=b(B,"LI",{});var Ht=N(gt);Bt=b(Ht,"P",{"data-svelte-h":!0}),T(Bt)!=="svelte-1ghnmtu"&&(Bt.innerHTML=ja),Zl=i(Ht),$(ht.$$.fragment,Ht),Ht.forEach(a),vl=i(B),Mt=b(B,"LI",{});var Vt=N(Mt);Yt=b(Vt,"P",{"data-svelte-h":!0}),T(Yt)!=="svelte-hspqy3"&&(Yt.textContent=Ta),Cl=i(Vt),$(yt.$$.fragment,Vt),Vt.forEach(a),Rl=i(B),bt=b(B,"LI",{});var $l=N(bt);Lt=b($l,"P",{"data-svelte-h":!0}),T(Lt)!=="svelte-jf0jr8"&&(Lt.textContent=wa),Gl=i($l),$(jt.$$.fragment,$l),$l.forEach(a),Wl=i(B),Tt=b(B,"LI",{});var ul=N(Tt);At=b(ul,"P",{"data-svelte-h":!0}),T(At)!=="svelte-8o19az"&&(At.innerHTML=Ja),Hl=i(ul),$(wt.$$.fragment,ul),ul.forEach(a),Vl=i(B),Jt=b(B,"LI",{});var gl=N(Jt);Qt=b(gl,"P",{"data-svelte-h":!0}),T(Qt)!=="svelte-inq7rl"&&(Qt.innerHTML=Ua),Il=i(gl),$(Ut.$$.fragment,gl),gl.forEach(a),B.forEach(a),ml=i(e),$(_t.$$.fragment,e),cl=i(e),kt=b(e,"P",{"data-svelte-h":!0}),T(kt)!=="svelte-t3rs4b"&&(kt.textContent=_a),fl=i(e),qt=b(e,"P",{}),N(qt).forEach(a),this.h()},h(){ka(s,"name","hf:doc:metadata"),ka(s,"content",gn)},m(e,l){U(document.head,s),r(e,p,l),r(e,t,l),r(e,n,l),u(f,e,l),r(e,m,l),u(_,e,l),r(e,v,l),r(e,C,l),r(e,j,l),r(e,Z,l),r(e,L,l),u(H,e,l),r(e,G,l),r(e,V,l),r(e,k,l),u(x,e,l),r(e,Pt,l),u(te,e,l),r(e,Ot,l),u(se,e,l),r(e,Dt,l),r(e,le,l),r(e,Kt,l),r(e,ae,l),r(e,es,l),r(e,ne,l),r(e,ts,l),u(re,e,l),r(e,ss,l),r(e,pe,l),r(e,ls,l),u(oe,e,l),r(e,as,l),r(e,ie,l),r(e,ns,l),u(me,e,l),r(e,rs,l),r(e,ce,l),r(e,ps,l),u(fe,e,l),r(e,os,l),r(e,de,l),r(e,is,l),u($e,e,l),r(e,ms,l),r(e,ue,l),r(e,cs,l),u(ge,e,l),r(e,fs,l),r(e,he,l),r(e,ds,l),u(Me,e,l),r(e,$s,l),r(e,ye,l),r(e,us,l),u(be,e,l),r(e,gs,l),r(e,je,l),r(e,hs,l),u(Te,e,l),r(e,Ms,l),u(A,e,l),r(e,ys,l),r(e,we,l),r(e,bs,l),u(Je,e,l),r(e,js,l),r(e,Ue,l),r(e,Ts,l),u(_e,e,l),r(e,ws,l),u(ke,e,l),r(e,Js,l),r(e,Ze,l),r(e,Us,l),r(e,ve,l),r(e,_s,l),u(Ce,e,l),r(e,ks,l),r(e,Re,l),r(e,Zs,l),r(e,Ge,l),r(e,vs,l),u(We,e,l),r(e,Cs,l),r(e,He,l),r(e,Rs,l),u(Ve,e,l),r(e,Gs,l),r(e,Ie,l),r(e,Ws,l),r(e,Xe,l),r(e,Hs,l),r(e,Fe,l),r(e,Vs,l),u(Q,e,l),r(e,Is,l),u(q,e,l),r(e,Xs,l),u(Ne,e,l),r(e,Fs,l),u(S,e,l),r(e,Ns,l),u(P,e,l),r(e,xs,l),u(xe,e,l),r(e,zs,l),u(O,e,l),r(e,Es,l),r(e,ze,l),r(e,Bs,l),u(D,e,l),r(e,Ys,l),u(Ee,e,l),r(e,Ls,l),r(e,Be,l),r(e,As,l),r(e,Ye,l),r(e,Qs,l),u(Le,e,l),r(e,qs,l),u(K,e,l),r(e,Ss,l),r(e,Ae,l),r(e,Ps,l),u(Qe,e,l),r(e,Os,l),r(e,qe,l),r(e,Ds,l),r(e,Se,l),r(e,Ks,l),r(e,X,l),U(X,Pe),U(Pe,Xt),U(Pe,hl),u(Oe,Pe,null),U(X,Ml),U(X,De),U(De,Ft),U(De,yl),u(Ke,De,null),U(X,bl),U(X,et),U(et,Nt),U(et,jl),u(tt,et,null),U(X,Tl),U(X,st),U(st,xt),U(st,wl),u(lt,st,null),U(X,Jl),U(X,at),U(at,zt),U(at,Ul),u(nt,at,null),U(X,_l),U(X,rt),U(rt,Et),U(rt,kl),u(pt,rt,null),r(e,el,l),r(e,ot,l),r(e,tl,l),u(it,e,l),r(e,sl,l),r(e,mt,l),r(e,ll,l),u(ct,e,l),r(e,al,l),u(ee,e,l),r(e,nl,l),r(e,ft,l),r(e,rl,l),r(e,dt,l),r(e,pl,l),u($t,e,l),r(e,ol,l),r(e,ut,l),r(e,il,l),r(e,z,l),U(z,gt),U(gt,Bt),U(gt,Zl),u(ht,gt,null),U(z,vl),U(z,Mt),U(Mt,Yt),U(Mt,Cl),u(yt,Mt,null),U(z,Rl),U(z,bt),U(bt,Lt),U(bt,Gl),u(jt,bt,null),U(z,Wl),U(z,Tt),U(Tt,At),U(Tt,Hl),u(wt,Tt,null),U(z,Vl),U(z,Jt),U(Jt,Qt),U(Jt,Il),u(Ut,Jt,null),r(e,ml,l),u(_t,e,l),r(e,cl,l),r(e,kt,l),r(e,fl,l),r(e,qt,l),dl=!0},p(e,[l]){const F={};l&2&&(F.$$scope={dirty:l,ctx:e}),x.$set(F);const Zt={};l&2&&(Zt.$$scope={dirty:l,ctx:e}),A.$set(Zt);const vt={};l&2&&(vt.$$scope={dirty:l,ctx:e}),Q.$set(vt);const Ct={};l&2&&(Ct.$$scope={dirty:l,ctx:e}),q.$set(Ct);const Rt={};l&2&&(Rt.$$scope={dirty:l,ctx:e}),S.$set(Rt);const Gt={};l&2&&(Gt.$$scope={dirty:l,ctx:e}),P.$set(Gt);const Wt={};l&2&&(Wt.$$scope={dirty:l,ctx:e}),O.$set(Wt);const B={};l&2&&(B.$$scope={dirty:l,ctx:e}),D.$set(B);const Ht={};l&2&&(Ht.$$scope={dirty:l,ctx:e}),K.$set(Ht);const Vt={};l&2&&(Vt.$$scope={dirty:l,ctx:e}),ee.$set(Vt)},i(e){dl||(g(f.$$.fragment,e),g(_.$$.fragment,e),g(H.$$.fragment,e),g(x.$$.fragment,e),g(te.$$.fragment,e),g(se.$$.fragment,e),g(re.$$.fragment,e),g(oe.$$.fragment,e),g(me.$$.fragment,e),g(fe.$$.fragment,e),g($e.$$.fragment,e),g(ge.$$.fragment,e),g(Me.$$.fragment,e),g(be.$$.fragment,e),g(Te.$$.fragment,e),g(A.$$.fragment,e),g(Je.$$.fragment,e),g(_e.$$.fragment,e),g(ke.$$.fragment,e),g(Ce.$$.fragment,e),g(We.$$.fragment,e),g(Ve.$$.fragment,e),g(Q.$$.fragment,e),g(q.$$.fragment,e),g(Ne.$$.fragment,e),g(S.$$.fragment,e),g(P.$$.fragment,e),g(xe.$$.fragment,e),g(O.$$.fragment,e),g(D.$$.fragment,e),g(Ee.$$.fragment,e),g(Le.$$.fragment,e),g(K.$$.fragment,e),g(Qe.$$.fragment,e),g(Oe.$$.fragment,e),g(Ke.$$.fragment,e),g(tt.$$.fragment,e),g(lt.$$.fragment,e),g(nt.$$.fragment,e),g(pt.$$.fragment,e),g(it.$$.fragment,e),g(ct.$$.fragment,e),g(ee.$$.fragment,e),g($t.$$.fragment,e),g(ht.$$.fragment,e),g(yt.$$.fragment,e),g(jt.$$.fragment,e),g(wt.$$.fragment,e),g(Ut.$$.fragment,e),g(_t.$$.fragment,e),dl=!0)},o(e){h(f.$$.fragment,e),h(_.$$.fragment,e),h(H.$$.fragment,e),h(x.$$.fragment,e),h(te.$$.fragment,e),h(se.$$.fragment,e),h(re.$$.fragment,e),h(oe.$$.fragment,e),h(me.$$.fragment,e),h(fe.$$.fragment,e),h($e.$$.fragment,e),h(ge.$$.fragment,e),h(Me.$$.fragment,e),h(be.$$.fragment,e),h(Te.$$.fragment,e),h(A.$$.fragment,e),h(Je.$$.fragment,e),h(_e.$$.fragment,e),h(ke.$$.fragment,e),h(Ce.$$.fragment,e),h(We.$$.fragment,e),h(Ve.$$.fragment,e),h(Q.$$.fragment,e),h(q.$$.fragment,e),h(Ne.$$.fragment,e),h(S.$$.fragment,e),h(P.$$.fragment,e),h(xe.$$.fragment,e),h(O.$$.fragment,e),h(D.$$.fragment,e),h(Ee.$$.fragment,e),h(Le.$$.fragment,e),h(K.$$.fragment,e),h(Qe.$$.fragment,e),h(Oe.$$.fragment,e),h(Ke.$$.fragment,e),h(tt.$$.fragment,e),h(lt.$$.fragment,e),h(nt.$$.fragment,e),h(pt.$$.fragment,e),h(it.$$.fragment,e),h(ct.$$.fragment,e),h(ee.$$.fragment,e),h($t.$$.fragment,e),h(ht.$$.fragment,e),h(yt.$$.fragment,e),h(jt.$$.fragment,e),h(wt.$$.fragment,e),h(Ut.$$.fragment,e),h(_t.$$.fragment,e),dl=!1},d(e){e&&(a(p),a(t),a(n),a(m),a(v),a(C),a(j),a(Z),a(L),a(G),a(V),a(k),a(Pt),a(Ot),a(Dt),a(le),a(Kt),a(ae),a(es),a(ne),a(ts),a(ss),a(pe),a(ls),a(as),a(ie),a(ns),a(rs),a(ce),a(ps),a(os),a(de),a(is),a(ms),a(ue),a(cs),a(fs),a(he),a(ds),a($s),a(ye),a(us),a(gs),a(je),a(hs),a(Ms),a(ys),a(we),a(bs),a(js),a(Ue),a(Ts),a(ws),a(Js),a(Ze),a(Us),a(ve),a(_s),a(ks),a(Re),a(Zs),a(Ge),a(vs),a(Cs),a(He),a(Rs),a(Gs),a(Ie),a(Ws),a(Xe),a(Hs),a(Fe),a(Vs),a(Is),a(Xs),a(Fs),a(Ns),a(xs),a(zs),a(Es),a(ze),a(Bs),a(Ys),a(Ls),a(Be),a(As),a(Ye),a(Qs),a(qs),a(Ss),a(Ae),a(Ps),a(Os),a(qe),a(Ds),a(Se),a(Ks),a(X),a(el),a(ot),a(tl),a(sl),a(mt),a(ll),a(al),a(nl),a(ft),a(rl),a(dt),a(pl),a(ol),a(ut),a(il),a(z),a(ml),a(cl),a(kt),a(fl),a(qt)),a(s),M(f,e),M(_,e),M(H,e),M(x,e),M(te,e),M(se,e),M(re,e),M(oe,e),M(me,e),M(fe,e),M($e,e),M(ge,e),M(Me,e),M(be,e),M(Te,e),M(A,e),M(Je,e),M(_e,e),M(ke,e),M(Ce,e),M(We,e),M(Ve,e),M(Q,e),M(q,e),M(Ne,e),M(S,e),M(P,e),M(xe,e),M(O,e),M(D,e),M(Ee,e),M(Le,e),M(K,e),M(Qe,e),M(Oe),M(Ke),M(tt),M(lt),M(nt),M(pt),M(it,e),M(ct,e),M(ee,e),M($t,e),M(ht),M(yt),M(jt),M(wt),M(Ut),M(_t,e)}}}const gn='{"title":"快速上手","local":"快速上手","sections":[{"title":"Pipeline","local":"pipeline","sections":[{"title":"在 pipeline 中使用另一个模型和分词器","local":"在-pipeline-中使用另一个模型和分词器","sections":[],"depth":3}],"depth":2},{"title":"AutoClass","local":"autoclass","sections":[{"title":"AutoTokenizer","local":"autotokenizer","sections":[],"depth":3},{"title":"AutoModel","local":"automodel","sections":[],"depth":3},{"title":"保存模型","local":"保存模型","sections":[],"depth":3}],"depth":2},{"title":"自定义模型构建","local":"自定义模型构建","sections":[],"depth":2},{"title":"Trainer - PyTorch 优化训练循环","local":"trainer---pytorch-优化训练循环","sections":[],"depth":2},{"title":"使用 Tensorflow 训练","local":"使用-tensorflow-训练","sections":[],"depth":2},{"title":"接下来做什么?","local":"接下来做什么","sections":[],"depth":2}],"depth":1}';function hn(w){return Ca(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Un extends Ra{constructor(s){super(),Ga(this,s,hn,un,va,{})}}export{Un as component};
