import{s as Ga,o as Ra,n as I}from"../chunks/scheduler.9991993c.js";import{S as Wa,i as Ha,g as y,s as o,r as d,A as Va,h as b,f as a,c as i,j as z,u as $,x as j,k as va,y as J,a as n,v as u,d as h,t as g,w as M}from"../chunks/index.7fc9a5e7.js";import{T as Pt}from"../chunks/Tip.9de92fc6.js";import{Y as Ca}from"../chunks/Youtube.7934cf81.js";import{C as _}from"../chunks/CodeBlock.e11cba92.js";import{D as Ia}from"../chunks/DocNotebookDropdown.a0cb4c0f.js";import{F as Xt,M as E}from"../chunks/Markdown.87f31c7e.js";import{H as B,E as Xa}from"../chunks/EditOnGithub.84ab7f0e.js";function Fa(w){let s,p;return s=new _({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRvcmNo",highlighted:"pip install torch",wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function za(w){let s,p;return s=new E({props:{$$slots:{default:[Fa]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Na(w){let s,p;return s=new _({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRlbnNvcmZsb3c=",highlighted:"pip install tensorflow",wrap:!1}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}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,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Ea(w){let s,p="使用 <code>AutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 来加载预训练模型和它关联的分词器（更多信息可以参考下一节的 <code>AutoClass</code>）：",t,r,f;return r=new _({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(r.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),j(s)!=="svelte-16qd42h"&&(s.innerHTML=p),t=i(m),$(r.$$.fragment,m)},m(m,k){n(m,s,k),n(m,t,k),u(r,m,k),f=!0},p:I,i(m){f||(h(r.$$.fragment,m),f=!0)},o(m){g(r.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(r,m)}}}function Ya(w){let s,p;return s=new E({props:{$$slots:{default:[Ea]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Ba(w){let s,p="使用 <code>TFAutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 来加载预训练模型和它关联的分词器（更多信息可以参考下一节的 <code>TFAutoClass</code>）：",t,r,f;return r=new _({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(r.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1scc1z5"&&(s.innerHTML=p),t=i(m),$(r.$$.fragment,m)},m(m,k){n(m,s,k),n(m,t,k),u(r,m,k),f=!0},p:I,i(m){f||(h(r.$$.fragment,m),f=!0)},o(m){g(r.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(r,m)}}}function La(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,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Aa(w){let s,p;return s=new _({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,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Qa(w){let s,p;return s=new E({props:{$$slots:{default:[Aa]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function qa(w){let s,p;return s=new _({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,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Sa(w){let s,p;return s=new E({props:{$$slots:{default:[qa]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function Pa(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}),j(s)!=="svelte-l21b6c"&&(s.innerHTML=p)},m(t,r){n(t,s,r)},p:I,d(t){t&&a(s)}}}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}),j(s)!=="svelte-1mg580k"&&(s.innerHTML=p)},m(t,r){n(t,s,r)},p:I,d(t){t&&a(s)}}}function Da(w){let s,p="🤗 Transformers 提供了一种简单统一的方式来加载预训练的实例. 这表示你可以像加载 <code>AutoTokenizer</code> 一样加载 <code>AutoModel</code>。唯一不同的地方是为你的任务选择正确的<code>AutoModel</code>。对于文本（或序列）分类，你应该加载<code>AutoModelForSequenceClassification</code>：",t,r,f,m,k,v,C="现在可以把预处理好的输入批次直接送进模型。你只需要通过 <code>**</code> 来解包字典:",G,T,Z,W,L="模型在 <code>logits</code> 属性输出最终的激活结果. 在 <code>logits</code> 上应用 softmax 函数来查询概率:",H,R,V;return r=new _({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 Pt({props:{$$slots:{default:[Oa]},$$scope:{ctx:w}}}),T=new _({props:{code:"cHRfb3V0cHV0cyUyMCUzRCUyMHB0X21vZGVsKCoqcHRfYmF0Y2gp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_outputs = pt_model(**pt_batch)',wrap:!1}}),R=new _({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(r.$$.fragment),f=o(),d(m.$$.fragment),k=o(),v=y("p"),v.innerHTML=C,G=o(),d(T.$$.fragment),Z=o(),W=y("p"),W.innerHTML=L,H=o(),d(R.$$.fragment)},l(c){s=b(c,"P",{"data-svelte-h":!0}),j(s)!=="svelte-7kcz0m"&&(s.innerHTML=p),t=i(c),$(r.$$.fragment,c),f=i(c),$(m.$$.fragment,c),k=i(c),v=b(c,"P",{"data-svelte-h":!0}),j(v)!=="svelte-1q5w0a3"&&(v.innerHTML=C),G=i(c),$(T.$$.fragment,c),Z=i(c),W=b(c,"P",{"data-svelte-h":!0}),j(W)!=="svelte-ianwj2"&&(W.innerHTML=L),H=i(c),$(R.$$.fragment,c)},m(c,U){n(c,s,U),n(c,t,U),u(r,c,U),n(c,f,U),u(m,c,U),n(c,k,U),n(c,v,U),n(c,G,U),u(T,c,U),n(c,Z,U),n(c,W,U),n(c,H,U),u(R,c,U),V=!0},p(c,U){const N={};U&2&&(N.$$scope={dirty:U,ctx:c}),m.$set(N)},i(c){V||(h(r.$$.fragment,c),h(m.$$.fragment,c),h(T.$$.fragment,c),h(R.$$.fragment,c),V=!0)},o(c){g(r.$$.fragment,c),g(m.$$.fragment,c),g(T.$$.fragment,c),g(R.$$.fragment,c),V=!1},d(c){c&&(a(s),a(t),a(f),a(k),a(v),a(G),a(Z),a(W),a(H)),M(r,c),M(m,c),M(T,c),M(R,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,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function en(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}),j(s)!=="svelte-1mg580k"&&(s.innerHTML=p)},m(t,r){n(t,s,r)},p:I,d(t){t&&a(s)}}}function tn(w){let s,p="🤗 Transformers 提供了一种简单统一的方式来加载预训练的实例。这表示你可以像加载 <code>AutoTokenizer</code> 一样加载 <code>TFAutoModel</code>。唯一不同的地方是为你的任务选择正确的 <code>TFAutoModel</code>，对于文本（或序列）分类，你应该加载 <code>TFAutoModelForSequenceClassification</code>：",t,r,f,m,k,v,C="现在通过直接将字典的键传给张量，将预处理的输入批次传给模型。",G,T,Z,W,L="模型在 <code>logits</code> 属性输出最终的激活结果。在 <code>logits</code> 上应用softmax函数来查询概率：",H,R,V;return r=new _({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 Pt({props:{$$slots:{default:[en]},$$scope:{ctx:w}}}),T=new _({props:{code:"dGZfb3V0cHV0cyUyMCUzRCUyMHRmX21vZGVsKHRmX2JhdGNoKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_outputs = tf_model(tf_batch)',wrap:!1}}),R=new _({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(r.$$.fragment),f=o(),d(m.$$.fragment),k=o(),v=y("p"),v.textContent=C,G=o(),d(T.$$.fragment),Z=o(),W=y("p"),W.innerHTML=L,H=o(),d(R.$$.fragment)},l(c){s=b(c,"P",{"data-svelte-h":!0}),j(s)!=="svelte-koi20"&&(s.innerHTML=p),t=i(c),$(r.$$.fragment,c),f=i(c),$(m.$$.fragment,c),k=i(c),v=b(c,"P",{"data-svelte-h":!0}),j(v)!=="svelte-16cvbg6"&&(v.textContent=C),G=i(c),$(T.$$.fragment,c),Z=i(c),W=b(c,"P",{"data-svelte-h":!0}),j(W)!=="svelte-1aahzm4"&&(W.innerHTML=L),H=i(c),$(R.$$.fragment,c)},m(c,U){n(c,s,U),n(c,t,U),u(r,c,U),n(c,f,U),u(m,c,U),n(c,k,U),n(c,v,U),n(c,G,U),u(T,c,U),n(c,Z,U),n(c,W,U),n(c,H,U),u(R,c,U),V=!0},p(c,U){const N={};U&2&&(N.$$scope={dirty:U,ctx:c}),m.$set(N)},i(c){V||(h(r.$$.fragment,c),h(m.$$.fragment,c),h(T.$$.fragment,c),h(R.$$.fragment,c),V=!0)},o(c){g(r.$$.fragment,c),g(m.$$.fragment,c),g(T.$$.fragment,c),g(R.$$.fragment,c),V=!1},d(c){c&&(a(s),a(t),a(f),a(k),a(v),a(G),a(Z),a(W),a(H)),M(r,c),M(m,c),M(T,c),M(R,c)}}}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,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function ln(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}),j(s)!=="svelte-pdy338"&&(s.innerHTML=p)},m(t,r){n(t,s,r)},p:I,d(t){t&&a(s)}}}function an(w){let s,p='当你的模型微调完成，你就可以使用 <a href="/docs/transformers/main/zh/main_classes/model#transformers.PreTrainedModel.save_pretrained">PreTrainedModel.save_pretrained()</a> 把它和它的分词器保存下来：',t,r,f,m,k='当你准备再次使用这个模型时，就可以使用 <a href="/docs/transformers/main/zh/main_classes/model#transformers.PreTrainedModel.from_pretrained">PreTrainedModel.from_pretrained()</a> 加载它了：',v,C,G;return r=new _({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 _({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(r.$$.fragment),f=o(),m=y("p"),m.innerHTML=k,v=o(),d(C.$$.fragment)},l(T){s=b(T,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1h1ryry"&&(s.innerHTML=p),t=i(T),$(r.$$.fragment,T),f=i(T),m=b(T,"P",{"data-svelte-h":!0}),j(m)!=="svelte-134z9py"&&(m.innerHTML=k),v=i(T),$(C.$$.fragment,T)},m(T,Z){n(T,s,Z),n(T,t,Z),u(r,T,Z),n(T,f,Z),n(T,m,Z),n(T,v,Z),u(C,T,Z),G=!0},p:I,i(T){G||(h(r.$$.fragment,T),h(C.$$.fragment,T),G=!0)},o(T){g(r.$$.fragment,T),g(C.$$.fragment,T),G=!1},d(T){T&&(a(s),a(t),a(f),a(m),a(v)),M(r,T),M(C,T)}}}function nn(w){let s,p;return s=new E({props:{$$slots:{default:[an]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function rn(w){let s,p='当你的模型微调完成，你就可以使用 <a href="/docs/transformers/main/zh/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">TFPreTrainedModel.save_pretrained()</a> 把它和它的分词器保存下来：',t,r,f,m,k='当你准备再次使用这个模型时，就可以使用 <a href="/docs/transformers/main/zh/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">TFPreTrainedModel.from_pretrained()</a> 加载它了：',v,C,G;return r=new _({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 _({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(r.$$.fragment),f=o(),m=y("p"),m.innerHTML=k,v=o(),d(C.$$.fragment)},l(T){s=b(T,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1xxt8fu"&&(s.innerHTML=p),t=i(T),$(r.$$.fragment,T),f=i(T),m=b(T,"P",{"data-svelte-h":!0}),j(m)!=="svelte-1j9gjai"&&(m.innerHTML=k),v=i(T),$(C.$$.fragment,T)},m(T,Z){n(T,s,Z),n(T,t,Z),u(r,T,Z),n(T,f,Z),n(T,m,Z),n(T,v,Z),u(C,T,Z),G=!0},p:I,i(T){G||(h(r.$$.fragment,T),h(C.$$.fragment,T),G=!0)},o(T){g(r.$$.fragment,T),g(C.$$.fragment,T),G=!1},d(T){T&&(a(s),a(t),a(f),a(m),a(v)),M(r,T),M(C,T)}}}function pn(w){let s,p;return s=new E({props:{$$slots:{default:[rn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function on(w){let s,p;return s=new _({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,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function mn(w){let s,p;return s=new E({props:{$$slots:{default:[on]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function cn(w){let s,p;return s=new _({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,r){u(s,t,r),p=!0},p:I,i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function fn(w){let s,p;return s=new E({props:{$$slots:{default:[cn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function dn(w){let s,p="使用 <code>AutoModel.from_config()</code> 根据你的自定义配置创建一个模型：",t,r,f;return r=new _({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(r.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),j(s)!=="svelte-kq2sqw"&&(s.innerHTML=p),t=i(m),$(r.$$.fragment,m)},m(m,k){n(m,s,k),n(m,t,k),u(r,m,k),f=!0},p:I,i(m){f||(h(r.$$.fragment,m),f=!0)},o(m){g(r.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(r,m)}}}function $n(w){let s,p;return s=new E({props:{$$slots:{default:[dn]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function un(w){let s,p="使用 <code>TFAutoModel.from_config()</code> 根据你的自定义配置创建一个模型：",t,r,f;return r=new _({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(r.$$.fragment)},l(m){s=b(m,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1obn2o6"&&(s.innerHTML=p),t=i(m),$(r.$$.fragment,m)},m(m,k){n(m,s,k),n(m,t,k),u(r,m,k),f=!0},p:I,i(m){f||(h(r.$$.fragment,m),f=!0)},o(m){g(r.$$.fragment,m),f=!1},d(m){m&&(a(s),a(t)),M(r,m)}}}function hn(w){let s,p;return s=new E({props:{$$slots:{default:[un]},$$scope:{ctx:w}}}),{c(){d(s.$$.fragment)},l(t){$(s.$$.fragment,t)},m(t,r){u(s,t,r),p=!0},p(t,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:t}),s.$set(f)},i(t){p||(h(s.$$.fragment,t),p=!0)},o(t){g(s.$$.fragment,t),p=!1},d(t){M(s,t)}}}function gn(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}),j(s)!=="svelte-d3rcx4"&&(s.innerHTML=p)},m(t,r){n(t,s,r)},p:I,d(t){t&&a(s)}}}function Mn(w){let s,p,t,r,f,m,k,v,C,G='快来使用 🤗 Transformers 吧！无论你是开发人员还是日常用户，这篇快速上手教程都将帮助你入门并且向你展示如何使用 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 进行推理，使用 <a href="./model_doc/auto">AutoClass</a> 加载一个预训练模型和预处理器，以及使用 PyTorch 或 TensorFlow 快速训练一个模型。如果你是一个初学者，我们建议你接下来查看我们的教程或者<a href="https://huggingface.co/course/chapter1/1" rel="nofollow">课程</a>，来更深入地了解在这里介绍到的概念。',T,Z,W="在开始之前，确保你已经安装了所有必要的库：",L,H,R,V,c="你还需要安装喜欢的机器学习框架：",U,N,Ot,te,Dt,se,Kt,le,zl='使用 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 是利用预训练模型进行推理的最简单的方式。你能够将 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 开箱即用地用于跨不同模态的多种任务。来看看它支持的任务列表：',es,ae,Nl="<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>",ts,ne,xl='创建一个 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 实例并且指定你想要将它用于的任务，就可以开始了。你可以将 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 用于任何一个上面提到的任务，如果想知道支持的任务的完整列表，可以查阅 <a href="./main_classes/pipelines">pipeline API 参考</a>。不过, 在这篇教程中，你将把 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 用在一个情感分析示例上：',ss,re,ls,pe,El='<a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 会下载并缓存一个用于情感分析的默认的<a href="https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english" rel="nofollow">预训练模型</a>和分词器。现在你可以在目标文本上使用 <code>classifier</code> 了：',as,oe,ns,ie,Yl='如果你有不止一个输入，可以把所有输入放入一个列表然后传给<a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>，它将会返回一个字典列表：',rs,me,ps,ce,Bl='<a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 也可以为任何你喜欢的任务遍历整个数据集。在下面这个示例中，让我们选择自动语音识别作为我们的任务：',os,fe,is,de,Ll='加载一个你想遍历的音频数据集（查阅 🤗 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> 数据集：',ms,$e,cs,ue,Al='你需要确保数据集中的音频的采样率与 <a href="https://huggingface.co/facebook/wav2vec2-base-960h" rel="nofollow"><code>facebook/wav2vec2-base-960h</code></a> 训练用到的音频的采样率一致：',fs,he,ds,ge,Ql=`当调用 <code>&quot;audio&quot;</code> 列时, 音频文件将会自动加载并重采样。
从前四个样本中提取原始波形数组，将它作为列表传给 pipeline：`,$s,Me,us,ye,ql='对于输入非常庞大的大型数据集（比如语音或视觉），你会想到使用一个生成器，而不是一个将所有输入都加载进内存的列表。查阅 <a href="./main_classes/pipelines">pipeline API 参考</a> 来获取更多信息。',hs,be,gs,Te,Sl='<a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 可以容纳 <a href="https://huggingface.co/models" rel="nofollow">Hub</a> 中的任何模型，这让 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 更容易适用于其他用例。比如，你想要一个能够处理法语文本的模型，就可以使用 Hub 上的标记来筛选出合适的模型。靠前的筛选结果会返回一个为情感分析微调的多语言的 <a href="https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment" rel="nofollow">BERT 模型</a>，你可以将它用于法语文本：',Ms,je,ys,A,bs,we,Pl='在 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 中指定模型和分词器，现在你就可以在法语文本上使用 <code>classifier</code> 了：',Ts,_e,js,Je,Ol='如果你没有找到适合你的模型，就需要在你的数据上微调一个预训练模型了。查看 <a href="./training">微调教程</a> 来学习怎样进行微调。最后，微调完模型后，考虑一下在 Hub 上与社区 <a href="./model_sharing">分享</a> 这个模型，把机器学习普及到每一个人! 🤗',ws,ke,_s,Ue,Js,Ze,Dl='在幕后，是由 <code>AutoModelForSequenceClassification</code> 和 <code>AutoTokenizer</code> 一起支持你在上面用到的 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>。<a href="./model_doc/auto">AutoClass</a> 是一个能够通过预训练模型的名称或路径自动查找其架构的快捷方式。你只需要为你的任务选择合适的 <code>AutoClass</code> 和它关联的预处理类。',ks,ve,Kl='让我们回过头来看上一节的示例，看看怎样使用 <code>AutoClass</code> 来重现使用 <a href="/docs/transformers/main/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 的结果。',Us,Ce,Zs,Ge,ea='分词器负责预处理文本，将文本转换为用于输入模型的数字数组。有多个用来管理分词过程的规则，包括如何拆分单词和在什么样的级别上拆分单词（在 <a href="./tokenizer_summary">分词器总结</a> 学习更多关于分词的信息）。要记住最重要的是你需要实例化的分词器要与模型的名称相同, 来确保和模型训练时使用相同的分词规则。',vs,Re,ta="使用 <code>AutoTokenizer</code> 加载一个分词器:",Cs,We,Gs,He,sa="将文本传入分词器：",Rs,Ve,Ws,Ie,la="分词器返回了含有如下内容的字典:",Hs,Xe,aa='<li><a href="./glossary#input-ids">input_ids</a>：用数字表示的 token。</li> <li><a href=".glossary#attention-mask">attention_mask</a>：应该关注哪些 token 的指示。</li>',Vs,Fe,na="分词器也可以接受列表作为输入，并填充和截断文本，返回具有统一长度的批次：",Is,Q,Xs,q,Fs,ze,zs,S,Ns,P,xs,Ne,Es,O,Ys,xe,ra="🤗 Transformers 有一个特别酷的功能，它能够保存一个模型，并且将它加载为 PyTorch 或 TensorFlow 模型。<code>from_pt</code> 或 <code>from_tf</code> 参数可以将模型从一个框架转换为另一个框架：",Bs,D,Ls,Ee,As,Ye,pa="你可以修改模型的配置类来改变模型的构建方式。配置指明了模型的属性，比如隐藏层或者注意力头的数量。当你从自定义的配置类初始化模型时，你就开始自定义模型构建了。模型属性是随机初始化的，你需要先训练模型，然后才能得到有意义的结果。",Qs,Be,oa="通过导入 <code>AutoConfig</code> 来开始，之后加载你想修改的预训练模型。在 <code>AutoConfig.from_pretrained()</code> 中，你能够指定想要修改的属性，比如注意力头的数量：",qs,Le,Ss,K,Ps,Ae,ia='查阅 <a href="./create_a_model">创建一个自定义结构</a> 指南获取更多关于构建自定义配置的信息。',Os,Qe,Ds,qe,ma='所有的模型都是标准的 <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> 类，它包含了基础的训练循环并且为诸如分布式训练，混合精度等特性增加了额外的功能。',Ks,Se,ca="取决于你的任务, 你通常可以传递以下的参数给 <code>Trainer</code>：",el,X,Pe,Ft,fa='<a href="/docs/transformers/main/zh/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a> 或者 <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow"><code>torch.nn.Module</code></a>：',yl,Oe,bl,De,zt,da="<code>TrainingArguments</code> 含有你可以修改的模型超参数，比如学习率，批次大小和训练时的迭代次数。如果你没有指定训练参数，那么它会使用默认值：",Tl,Ke,jl,et,Nt,$a="一个预处理类，比如分词器，特征提取器或者处理器：",wl,tt,_l,st,xt,ua="加载一个数据集：",Jl,lt,kl,at,Et,ha="创建一个给数据集分词的函数，并且使用 <code>map</code> 应用到整个数据集：",Ul,nt,Zl,rt,Yt,ga='用来从数据集中创建批次的 <a href="/docs/transformers/main/zh/main_classes/data_collator#transformers.DataCollatorWithPadding">DataCollatorWithPadding</a>：',vl,pt,tl,ot,Ma="现在把所有的类传给 <code>Trainer</code>：",sl,it,ll,mt,ya="一切准备就绪后，调用 <code>train()</code> 进行训练：",al,ct,nl,ee,rl,ft,ba="你可以通过子类化 <code>Trainer</code> 中的方法来自定义训练循环。这样你就可以自定义像损失函数，优化器和调度器这样的特性。查阅 <code>Trainer</code> 参考手册了解哪些方法能够被子类化。",pl,dt,Ta='另一个自定义训练循环的方式是通过<a href="./main_classes/callbacks">回调</a>。你可以使用回调来与其他库集成，查看训练循环来报告进度或提前结束训练。回调不会修改训练循环。如果想自定义损失函数等，就需要子类化 <code>Trainer</code> 了。',ol,$t,il,ut,ja='所有模型都是标准的 <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 提供了 <a href="/docs/transformers/main/zh/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> 方法来轻松地将数据集加载为 <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> 方法马上开始训练。',ml,x,ht,Bt,wa='使用 <a href="/docs/transformers/main/zh/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a> 或者 <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow"><code>tf.keras.Model</code></a> 来开始：',Cl,gt,Gl,Mt,Lt,_a="一个预处理类，比如分词器，特征提取器或者处理器：",Rl,yt,Wl,bt,At,Ja="创建一个给数据集分词的函数",Hl,Tt,Vl,jt,Qt,ka='使用 <code>map</code> 将分词器应用到整个数据集，之后将数据集和分词器传给 <a href="/docs/transformers/main/zh/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>。如果你需要的话，也可以在这里改变批次大小和是否打乱数据集：',Il,wt,Xl,_t,qt,Ua="一切准备就绪后，调用 <code>compile</code> 和 <code>fit</code> 开始训练：",Fl,Jt,cl,kt,fl,Ut,Za="现在你已经完成了 🤗 Transformers 的快速上手教程，来看看我们的指南并且学习如何做一些更具体的事情，比如写一个自定义模型，为某个任务微调一个模型以及如何使用脚本来训练模型。如果你有兴趣了解更多 🤗 Transformers 的核心章节，那就喝杯咖啡然后来看看我们的概念指南吧！",dl,Zt,$l,St,ul;return f=new B({props:{title:"快速上手",local:"快速上手",headingTag:"h1"}}),k=new Ia({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 _({props:{code:"IXBpcCUyMGluc3RhbGwlMjB0cmFuc2Zvcm1lcnMlMjBkYXRhc2V0cyUyMGV2YWx1YXRlJTIwYWNjZWxlcmF0ZQ==",highlighted:"!pip install transformers datasets evaluate accelerate",wrap:!1}}),N=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[xa],pytorch:[za]},$$scope:{ctx:w}}}),te=new B({props:{title:"Pipeline",local:"pipeline",headingTag:"h2"}}),se=new Ca({props:{id:"tiZFewofSLM"}}),re=new _({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 _({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 _({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 _({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 _({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}}),he=new _({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 _({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 B({props:{title:"在 pipeline 中使用另一个模型和分词器",local:"在-pipeline-中使用另一个模型和分词器",headingTag:"h3"}}),je=new _({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 Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[La],pytorch:[Ya]},$$scope:{ctx:w}}}),_e=new _({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}}),ke=new B({props:{title:"AutoClass",local:"autoclass",headingTag:"h2"}}),Ue=new Ca({props:{id:"AhChOFRegn4"}}),Ce=new B({props:{title:"AutoTokenizer",local:"autotokenizer",headingTag:"h3"}}),We=new _({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 _({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 Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Sa],pytorch:[Qa]},$$scope:{ctx:w}}}),q=new Pt({props:{$$slots:{default:[Pa]},$$scope:{ctx:w}}}),ze=new B({props:{title:"AutoModel",local:"automodel",headingTag:"h3"}}),S=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[sn],pytorch:[Ka]},$$scope:{ctx:w}}}),P=new Pt({props:{$$slots:{default:[ln]},$$scope:{ctx:w}}}),Ne=new B({props:{title:"保存模型",local:"保存模型",headingTag:"h3"}}),O=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[pn],pytorch:[nn]},$$scope:{ctx:w}}}),D=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[fn],pytorch:[mn]},$$scope:{ctx:w}}}),Ee=new B({props:{title:"自定义模型构建",local:"自定义模型构建",headingTag:"h2"}}),Le=new _({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFteV9jb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjBuX2hlYWRzJTNEMTIp",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/distilbert-base-uncased&quot;</span>, n_heads=<span class="hljs-number">12</span>)`,wrap:!1}}),K=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[hn],pytorch:[$n]},$$scope:{ctx:w}}}),Qe=new B({props:{title:"Trainer - PyTorch 优化训练循环",local:"trainer---pytorch-优化训练循环",headingTag:"h2"}}),Oe=new _({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),Ke=new _({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 _({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),lt=new _({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 _({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 _({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 _({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 _({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()',wrap:!1}}),ee=new Pt({props:{$$slots:{default:[gn]},$$scope:{ctx:w}}}),$t=new B({props:{title:"使用 Tensorflow 训练",local:"使用-tensorflow-训练",headingTag:"h2"}}),gt=new _({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),yt=new _({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),Tt=new _({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 _({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}}),Jt=new _({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}}),kt=new B({props:{title:"接下来做什么?",local:"接下来做什么",headingTag:"h2"}}),Zt=new Xa({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/quicktour.md"}}),{c(){s=y("meta"),p=o(),t=y("p"),r=o(),d(f.$$.fragment),m=o(),d(k.$$.fragment),v=o(),C=y("p"),C.innerHTML=G,T=o(),Z=y("p"),Z.textContent=W,L=o(),d(H.$$.fragment),R=o(),V=y("p"),V.textContent=c,U=o(),d(N.$$.fragment),Ot=o(),d(te.$$.fragment),Dt=o(),d(se.$$.fragment),Kt=o(),le=y("p"),le.innerHTML=zl,es=o(),ae=y("table"),ae.innerHTML=Nl,ts=o(),ne=y("p"),ne.innerHTML=xl,ss=o(),d(re.$$.fragment),ls=o(),pe=y("p"),pe.innerHTML=El,as=o(),d(oe.$$.fragment),ns=o(),ie=y("p"),ie.innerHTML=Yl,rs=o(),d(me.$$.fragment),ps=o(),ce=y("p"),ce.innerHTML=Bl,os=o(),d(fe.$$.fragment),is=o(),de=y("p"),de.innerHTML=Ll,ms=o(),d($e.$$.fragment),cs=o(),ue=y("p"),ue.innerHTML=Al,fs=o(),d(he.$$.fragment),ds=o(),ge=y("p"),ge.innerHTML=Ql,$s=o(),d(Me.$$.fragment),us=o(),ye=y("p"),ye.innerHTML=ql,hs=o(),d(be.$$.fragment),gs=o(),Te=y("p"),Te.innerHTML=Sl,Ms=o(),d(je.$$.fragment),ys=o(),d(A.$$.fragment),bs=o(),we=y("p"),we.innerHTML=Pl,Ts=o(),d(_e.$$.fragment),js=o(),Je=y("p"),Je.innerHTML=Ol,ws=o(),d(ke.$$.fragment),_s=o(),d(Ue.$$.fragment),Js=o(),Ze=y("p"),Ze.innerHTML=Dl,ks=o(),ve=y("p"),ve.innerHTML=Kl,Us=o(),d(Ce.$$.fragment),Zs=o(),Ge=y("p"),Ge.innerHTML=ea,vs=o(),Re=y("p"),Re.innerHTML=ta,Cs=o(),d(We.$$.fragment),Gs=o(),He=y("p"),He.textContent=sa,Rs=o(),d(Ve.$$.fragment),Ws=o(),Ie=y("p"),Ie.textContent=la,Hs=o(),Xe=y("ul"),Xe.innerHTML=aa,Vs=o(),Fe=y("p"),Fe.textContent=na,Is=o(),d(Q.$$.fragment),Xs=o(),d(q.$$.fragment),Fs=o(),d(ze.$$.fragment),zs=o(),d(S.$$.fragment),Ns=o(),d(P.$$.fragment),xs=o(),d(Ne.$$.fragment),Es=o(),d(O.$$.fragment),Ys=o(),xe=y("p"),xe.innerHTML=ra,Bs=o(),d(D.$$.fragment),Ls=o(),d(Ee.$$.fragment),As=o(),Ye=y("p"),Ye.textContent=pa,Qs=o(),Be=y("p"),Be.innerHTML=oa,qs=o(),d(Le.$$.fragment),Ss=o(),d(K.$$.fragment),Ps=o(),Ae=y("p"),Ae.innerHTML=ia,Os=o(),d(Qe.$$.fragment),Ds=o(),qe=y("p"),qe.innerHTML=ma,Ks=o(),Se=y("p"),Se.innerHTML=ca,el=o(),X=y("ol"),Pe=y("li"),Ft=y("p"),Ft.innerHTML=fa,yl=o(),d(Oe.$$.fragment),bl=o(),De=y("li"),zt=y("p"),zt.innerHTML=da,Tl=o(),d(Ke.$$.fragment),jl=o(),et=y("li"),Nt=y("p"),Nt.textContent=$a,wl=o(),d(tt.$$.fragment),_l=o(),st=y("li"),xt=y("p"),xt.textContent=ua,Jl=o(),d(lt.$$.fragment),kl=o(),at=y("li"),Et=y("p"),Et.innerHTML=ha,Ul=o(),d(nt.$$.fragment),Zl=o(),rt=y("li"),Yt=y("p"),Yt.innerHTML=ga,vl=o(),d(pt.$$.fragment),tl=o(),ot=y("p"),ot.innerHTML=Ma,sl=o(),d(it.$$.fragment),ll=o(),mt=y("p"),mt.innerHTML=ya,al=o(),d(ct.$$.fragment),nl=o(),d(ee.$$.fragment),rl=o(),ft=y("p"),ft.innerHTML=ba,pl=o(),dt=y("p"),dt.innerHTML=Ta,ol=o(),d($t.$$.fragment),il=o(),ut=y("p"),ut.innerHTML=ja,ml=o(),x=y("ol"),ht=y("li"),Bt=y("p"),Bt.innerHTML=wa,Cl=o(),d(gt.$$.fragment),Gl=o(),Mt=y("li"),Lt=y("p"),Lt.textContent=_a,Rl=o(),d(yt.$$.fragment),Wl=o(),bt=y("li"),At=y("p"),At.textContent=Ja,Hl=o(),d(Tt.$$.fragment),Vl=o(),jt=y("li"),Qt=y("p"),Qt.innerHTML=ka,Il=o(),d(wt.$$.fragment),Xl=o(),_t=y("li"),qt=y("p"),qt.innerHTML=Ua,Fl=o(),d(Jt.$$.fragment),cl=o(),d(kt.$$.fragment),fl=o(),Ut=y("p"),Ut.textContent=Za,dl=o(),d(Zt.$$.fragment),$l=o(),St=y("p"),this.h()},l(e){const l=Va("svelte-u9bgzb",document.head);s=b(l,"META",{name:!0,content:!0}),l.forEach(a),p=i(e),t=b(e,"P",{}),z(t).forEach(a),r=i(e),$(f.$$.fragment,e),m=i(e),$(k.$$.fragment,e),v=i(e),C=b(e,"P",{"data-svelte-h":!0}),j(C)!=="svelte-1yuzc54"&&(C.innerHTML=G),T=i(e),Z=b(e,"P",{"data-svelte-h":!0}),j(Z)!=="svelte-10awe57"&&(Z.textContent=W),L=i(e),$(H.$$.fragment,e),R=i(e),V=b(e,"P",{"data-svelte-h":!0}),j(V)!=="svelte-1qrldcv"&&(V.textContent=c),U=i(e),$(N.$$.fragment,e),Ot=i(e),$(te.$$.fragment,e),Dt=i(e),$(se.$$.fragment,e),Kt=i(e),le=b(e,"P",{"data-svelte-h":!0}),j(le)!=="svelte-ad22ek"&&(le.innerHTML=zl),es=i(e),ae=b(e,"TABLE",{"data-svelte-h":!0}),j(ae)!=="svelte-1cgfltn"&&(ae.innerHTML=Nl),ts=i(e),ne=b(e,"P",{"data-svelte-h":!0}),j(ne)!=="svelte-1bed2pj"&&(ne.innerHTML=xl),ss=i(e),$(re.$$.fragment,e),ls=i(e),pe=b(e,"P",{"data-svelte-h":!0}),j(pe)!=="svelte-145ftm9"&&(pe.innerHTML=El),as=i(e),$(oe.$$.fragment,e),ns=i(e),ie=b(e,"P",{"data-svelte-h":!0}),j(ie)!=="svelte-a2wfxd"&&(ie.innerHTML=Yl),rs=i(e),$(me.$$.fragment,e),ps=i(e),ce=b(e,"P",{"data-svelte-h":!0}),j(ce)!=="svelte-lsjq5w"&&(ce.innerHTML=Bl),os=i(e),$(fe.$$.fragment,e),is=i(e),de=b(e,"P",{"data-svelte-h":!0}),j(de)!=="svelte-1x73msc"&&(de.innerHTML=Ll),ms=i(e),$($e.$$.fragment,e),cs=i(e),ue=b(e,"P",{"data-svelte-h":!0}),j(ue)!=="svelte-1xxvdtf"&&(ue.innerHTML=Al),fs=i(e),$(he.$$.fragment,e),ds=i(e),ge=b(e,"P",{"data-svelte-h":!0}),j(ge)!=="svelte-pyqv34"&&(ge.innerHTML=Ql),$s=i(e),$(Me.$$.fragment,e),us=i(e),ye=b(e,"P",{"data-svelte-h":!0}),j(ye)!=="svelte-1cip30a"&&(ye.innerHTML=ql),hs=i(e),$(be.$$.fragment,e),gs=i(e),Te=b(e,"P",{"data-svelte-h":!0}),j(Te)!=="svelte-6on4de"&&(Te.innerHTML=Sl),Ms=i(e),$(je.$$.fragment,e),ys=i(e),$(A.$$.fragment,e),bs=i(e),we=b(e,"P",{"data-svelte-h":!0}),j(we)!=="svelte-1jet3ts"&&(we.innerHTML=Pl),Ts=i(e),$(_e.$$.fragment,e),js=i(e),Je=b(e,"P",{"data-svelte-h":!0}),j(Je)!=="svelte-uyj2qy"&&(Je.innerHTML=Ol),ws=i(e),$(ke.$$.fragment,e),_s=i(e),$(Ue.$$.fragment,e),Js=i(e),Ze=b(e,"P",{"data-svelte-h":!0}),j(Ze)!=="svelte-1tbj0ny"&&(Ze.innerHTML=Dl),ks=i(e),ve=b(e,"P",{"data-svelte-h":!0}),j(ve)!=="svelte-zht2o2"&&(ve.innerHTML=Kl),Us=i(e),$(Ce.$$.fragment,e),Zs=i(e),Ge=b(e,"P",{"data-svelte-h":!0}),j(Ge)!=="svelte-pupyjv"&&(Ge.innerHTML=ea),vs=i(e),Re=b(e,"P",{"data-svelte-h":!0}),j(Re)!=="svelte-1iigdiw"&&(Re.innerHTML=ta),Cs=i(e),$(We.$$.fragment,e),Gs=i(e),He=b(e,"P",{"data-svelte-h":!0}),j(He)!=="svelte-bt7849"&&(He.textContent=sa),Rs=i(e),$(Ve.$$.fragment,e),Ws=i(e),Ie=b(e,"P",{"data-svelte-h":!0}),j(Ie)!=="svelte-1dcb4pt"&&(Ie.textContent=la),Hs=i(e),Xe=b(e,"UL",{"data-svelte-h":!0}),j(Xe)!=="svelte-1hv4uqa"&&(Xe.innerHTML=aa),Vs=i(e),Fe=b(e,"P",{"data-svelte-h":!0}),j(Fe)!=="svelte-hbhd9z"&&(Fe.textContent=na),Is=i(e),$(Q.$$.fragment,e),Xs=i(e),$(q.$$.fragment,e),Fs=i(e),$(ze.$$.fragment,e),zs=i(e),$(S.$$.fragment,e),Ns=i(e),$(P.$$.fragment,e),xs=i(e),$(Ne.$$.fragment,e),Es=i(e),$(O.$$.fragment,e),Ys=i(e),xe=b(e,"P",{"data-svelte-h":!0}),j(xe)!=="svelte-rne23r"&&(xe.innerHTML=ra),Bs=i(e),$(D.$$.fragment,e),Ls=i(e),$(Ee.$$.fragment,e),As=i(e),Ye=b(e,"P",{"data-svelte-h":!0}),j(Ye)!=="svelte-1v6i9vn"&&(Ye.textContent=pa),Qs=i(e),Be=b(e,"P",{"data-svelte-h":!0}),j(Be)!=="svelte-15b3fgp"&&(Be.innerHTML=oa),qs=i(e),$(Le.$$.fragment,e),Ss=i(e),$(K.$$.fragment,e),Ps=i(e),Ae=b(e,"P",{"data-svelte-h":!0}),j(Ae)!=="svelte-n1ja8b"&&(Ae.innerHTML=ia),Os=i(e),$(Qe.$$.fragment,e),Ds=i(e),qe=b(e,"P",{"data-svelte-h":!0}),j(qe)!=="svelte-1bwvvy5"&&(qe.innerHTML=ma),Ks=i(e),Se=b(e,"P",{"data-svelte-h":!0}),j(Se)!=="svelte-1mmhf7y"&&(Se.innerHTML=ca),el=i(e),X=b(e,"OL",{});var F=z(X);Pe=b(F,"LI",{});var vt=z(Pe);Ft=b(vt,"P",{"data-svelte-h":!0}),j(Ft)!=="svelte-rtad3z"&&(Ft.innerHTML=fa),yl=i(vt),$(Oe.$$.fragment,vt),vt.forEach(a),bl=i(F),De=b(F,"LI",{});var Ct=z(De);zt=b(Ct,"P",{"data-svelte-h":!0}),j(zt)!=="svelte-gaji1x"&&(zt.innerHTML=da),Tl=i(Ct),$(Ke.$$.fragment,Ct),Ct.forEach(a),jl=i(F),et=b(F,"LI",{});var Gt=z(et);Nt=b(Gt,"P",{"data-svelte-h":!0}),j(Nt)!=="svelte-hspqy3"&&(Nt.textContent=$a),wl=i(Gt),$(tt.$$.fragment,Gt),Gt.forEach(a),_l=i(F),st=b(F,"LI",{});var Rt=z(st);xt=b(Rt,"P",{"data-svelte-h":!0}),j(xt)!=="svelte-wmvqzp"&&(xt.textContent=ua),Jl=i(Rt),$(lt.$$.fragment,Rt),Rt.forEach(a),kl=i(F),at=b(F,"LI",{});var Wt=z(at);Et=b(Wt,"P",{"data-svelte-h":!0}),j(Et)!=="svelte-nju1yy"&&(Et.innerHTML=ha),Ul=i(Wt),$(nt.$$.fragment,Wt),Wt.forEach(a),Zl=i(F),rt=b(F,"LI",{});var Ht=z(rt);Yt=b(Ht,"P",{"data-svelte-h":!0}),j(Yt)!=="svelte-1esdjf4"&&(Yt.innerHTML=ga),vl=i(Ht),$(pt.$$.fragment,Ht),Ht.forEach(a),F.forEach(a),tl=i(e),ot=b(e,"P",{"data-svelte-h":!0}),j(ot)!=="svelte-15smi2d"&&(ot.innerHTML=Ma),sl=i(e),$(it.$$.fragment,e),ll=i(e),mt=b(e,"P",{"data-svelte-h":!0}),j(mt)!=="svelte-1si5m9v"&&(mt.innerHTML=ya),al=i(e),$(ct.$$.fragment,e),nl=i(e),$(ee.$$.fragment,e),rl=i(e),ft=b(e,"P",{"data-svelte-h":!0}),j(ft)!=="svelte-gx0dd1"&&(ft.innerHTML=ba),pl=i(e),dt=b(e,"P",{"data-svelte-h":!0}),j(dt)!=="svelte-814nns"&&(dt.innerHTML=Ta),ol=i(e),$($t.$$.fragment,e),il=i(e),ut=b(e,"P",{"data-svelte-h":!0}),j(ut)!=="svelte-e70lvb"&&(ut.innerHTML=ja),ml=i(e),x=b(e,"OL",{});var Y=z(x);ht=b(Y,"LI",{});var Vt=z(ht);Bt=b(Vt,"P",{"data-svelte-h":!0}),j(Bt)!=="svelte-17z9jst"&&(Bt.innerHTML=wa),Cl=i(Vt),$(gt.$$.fragment,Vt),Vt.forEach(a),Gl=i(Y),Mt=b(Y,"LI",{});var It=z(Mt);Lt=b(It,"P",{"data-svelte-h":!0}),j(Lt)!=="svelte-hspqy3"&&(Lt.textContent=_a),Rl=i(It),$(yt.$$.fragment,It),It.forEach(a),Wl=i(Y),bt=b(Y,"LI",{});var hl=z(bt);At=b(hl,"P",{"data-svelte-h":!0}),j(At)!=="svelte-jf0jr8"&&(At.textContent=Ja),Hl=i(hl),$(Tt.$$.fragment,hl),hl.forEach(a),Vl=i(Y),jt=b(Y,"LI",{});var gl=z(jt);Qt=b(gl,"P",{"data-svelte-h":!0}),j(Qt)!=="svelte-f7iu5h"&&(Qt.innerHTML=ka),Il=i(gl),$(wt.$$.fragment,gl),gl.forEach(a),Xl=i(Y),_t=b(Y,"LI",{});var Ml=z(_t);qt=b(Ml,"P",{"data-svelte-h":!0}),j(qt)!=="svelte-inq7rl"&&(qt.innerHTML=Ua),Fl=i(Ml),$(Jt.$$.fragment,Ml),Ml.forEach(a),Y.forEach(a),cl=i(e),$(kt.$$.fragment,e),fl=i(e),Ut=b(e,"P",{"data-svelte-h":!0}),j(Ut)!=="svelte-t3rs4b"&&(Ut.textContent=Za),dl=i(e),$(Zt.$$.fragment,e),$l=i(e),St=b(e,"P",{}),z(St).forEach(a),this.h()},h(){va(s,"name","hf:doc:metadata"),va(s,"content",yn)},m(e,l){J(document.head,s),n(e,p,l),n(e,t,l),n(e,r,l),u(f,e,l),n(e,m,l),u(k,e,l),n(e,v,l),n(e,C,l),n(e,T,l),n(e,Z,l),n(e,L,l),u(H,e,l),n(e,R,l),n(e,V,l),n(e,U,l),u(N,e,l),n(e,Ot,l),u(te,e,l),n(e,Dt,l),u(se,e,l),n(e,Kt,l),n(e,le,l),n(e,es,l),n(e,ae,l),n(e,ts,l),n(e,ne,l),n(e,ss,l),u(re,e,l),n(e,ls,l),n(e,pe,l),n(e,as,l),u(oe,e,l),n(e,ns,l),n(e,ie,l),n(e,rs,l),u(me,e,l),n(e,ps,l),n(e,ce,l),n(e,os,l),u(fe,e,l),n(e,is,l),n(e,de,l),n(e,ms,l),u($e,e,l),n(e,cs,l),n(e,ue,l),n(e,fs,l),u(he,e,l),n(e,ds,l),n(e,ge,l),n(e,$s,l),u(Me,e,l),n(e,us,l),n(e,ye,l),n(e,hs,l),u(be,e,l),n(e,gs,l),n(e,Te,l),n(e,Ms,l),u(je,e,l),n(e,ys,l),u(A,e,l),n(e,bs,l),n(e,we,l),n(e,Ts,l),u(_e,e,l),n(e,js,l),n(e,Je,l),n(e,ws,l),u(ke,e,l),n(e,_s,l),u(Ue,e,l),n(e,Js,l),n(e,Ze,l),n(e,ks,l),n(e,ve,l),n(e,Us,l),u(Ce,e,l),n(e,Zs,l),n(e,Ge,l),n(e,vs,l),n(e,Re,l),n(e,Cs,l),u(We,e,l),n(e,Gs,l),n(e,He,l),n(e,Rs,l),u(Ve,e,l),n(e,Ws,l),n(e,Ie,l),n(e,Hs,l),n(e,Xe,l),n(e,Vs,l),n(e,Fe,l),n(e,Is,l),u(Q,e,l),n(e,Xs,l),u(q,e,l),n(e,Fs,l),u(ze,e,l),n(e,zs,l),u(S,e,l),n(e,Ns,l),u(P,e,l),n(e,xs,l),u(Ne,e,l),n(e,Es,l),u(O,e,l),n(e,Ys,l),n(e,xe,l),n(e,Bs,l),u(D,e,l),n(e,Ls,l),u(Ee,e,l),n(e,As,l),n(e,Ye,l),n(e,Qs,l),n(e,Be,l),n(e,qs,l),u(Le,e,l),n(e,Ss,l),u(K,e,l),n(e,Ps,l),n(e,Ae,l),n(e,Os,l),u(Qe,e,l),n(e,Ds,l),n(e,qe,l),n(e,Ks,l),n(e,Se,l),n(e,el,l),n(e,X,l),J(X,Pe),J(Pe,Ft),J(Pe,yl),u(Oe,Pe,null),J(X,bl),J(X,De),J(De,zt),J(De,Tl),u(Ke,De,null),J(X,jl),J(X,et),J(et,Nt),J(et,wl),u(tt,et,null),J(X,_l),J(X,st),J(st,xt),J(st,Jl),u(lt,st,null),J(X,kl),J(X,at),J(at,Et),J(at,Ul),u(nt,at,null),J(X,Zl),J(X,rt),J(rt,Yt),J(rt,vl),u(pt,rt,null),n(e,tl,l),n(e,ot,l),n(e,sl,l),u(it,e,l),n(e,ll,l),n(e,mt,l),n(e,al,l),u(ct,e,l),n(e,nl,l),u(ee,e,l),n(e,rl,l),n(e,ft,l),n(e,pl,l),n(e,dt,l),n(e,ol,l),u($t,e,l),n(e,il,l),n(e,ut,l),n(e,ml,l),n(e,x,l),J(x,ht),J(ht,Bt),J(ht,Cl),u(gt,ht,null),J(x,Gl),J(x,Mt),J(Mt,Lt),J(Mt,Rl),u(yt,Mt,null),J(x,Wl),J(x,bt),J(bt,At),J(bt,Hl),u(Tt,bt,null),J(x,Vl),J(x,jt),J(jt,Qt),J(jt,Il),u(wt,jt,null),J(x,Xl),J(x,_t),J(_t,qt),J(_t,Fl),u(Jt,_t,null),n(e,cl,l),u(kt,e,l),n(e,fl,l),n(e,Ut,l),n(e,dl,l),u(Zt,e,l),n(e,$l,l),n(e,St,l),ul=!0},p(e,[l]){const F={};l&2&&(F.$$scope={dirty:l,ctx:e}),N.$set(F);const vt={};l&2&&(vt.$$scope={dirty:l,ctx:e}),A.$set(vt);const Ct={};l&2&&(Ct.$$scope={dirty:l,ctx:e}),Q.$set(Ct);const Gt={};l&2&&(Gt.$$scope={dirty:l,ctx:e}),q.$set(Gt);const Rt={};l&2&&(Rt.$$scope={dirty:l,ctx:e}),S.$set(Rt);const Wt={};l&2&&(Wt.$$scope={dirty:l,ctx:e}),P.$set(Wt);const Ht={};l&2&&(Ht.$$scope={dirty:l,ctx:e}),O.$set(Ht);const Y={};l&2&&(Y.$$scope={dirty:l,ctx:e}),D.$set(Y);const Vt={};l&2&&(Vt.$$scope={dirty:l,ctx:e}),K.$set(Vt);const It={};l&2&&(It.$$scope={dirty:l,ctx:e}),ee.$set(It)},i(e){ul||(h(f.$$.fragment,e),h(k.$$.fragment,e),h(H.$$.fragment,e),h(N.$$.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(he.$$.fragment,e),h(Me.$$.fragment,e),h(be.$$.fragment,e),h(je.$$.fragment,e),h(A.$$.fragment,e),h(_e.$$.fragment,e),h(ke.$$.fragment,e),h(Ue.$$.fragment,e),h(Ce.$$.fragment,e),h(We.$$.fragment,e),h(Ve.$$.fragment,e),h(Q.$$.fragment,e),h(q.$$.fragment,e),h(ze.$$.fragment,e),h(S.$$.fragment,e),h(P.$$.fragment,e),h(Ne.$$.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(gt.$$.fragment,e),h(yt.$$.fragment,e),h(Tt.$$.fragment,e),h(wt.$$.fragment,e),h(Jt.$$.fragment,e),h(kt.$$.fragment,e),h(Zt.$$.fragment,e),ul=!0)},o(e){g(f.$$.fragment,e),g(k.$$.fragment,e),g(H.$$.fragment,e),g(N.$$.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(he.$$.fragment,e),g(Me.$$.fragment,e),g(be.$$.fragment,e),g(je.$$.fragment,e),g(A.$$.fragment,e),g(_e.$$.fragment,e),g(ke.$$.fragment,e),g(Ue.$$.fragment,e),g(Ce.$$.fragment,e),g(We.$$.fragment,e),g(Ve.$$.fragment,e),g(Q.$$.fragment,e),g(q.$$.fragment,e),g(ze.$$.fragment,e),g(S.$$.fragment,e),g(P.$$.fragment,e),g(Ne.$$.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(gt.$$.fragment,e),g(yt.$$.fragment,e),g(Tt.$$.fragment,e),g(wt.$$.fragment,e),g(Jt.$$.fragment,e),g(kt.$$.fragment,e),g(Zt.$$.fragment,e),ul=!1},d(e){e&&(a(p),a(t),a(r),a(m),a(v),a(C),a(T),a(Z),a(L),a(R),a(V),a(U),a(Ot),a(Dt),a(Kt),a(le),a(es),a(ae),a(ts),a(ne),a(ss),a(ls),a(pe),a(as),a(ns),a(ie),a(rs),a(ps),a(ce),a(os),a(is),a(de),a(ms),a(cs),a(ue),a(fs),a(ds),a(ge),a($s),a(us),a(ye),a(hs),a(gs),a(Te),a(Ms),a(ys),a(bs),a(we),a(Ts),a(js),a(Je),a(ws),a(_s),a(Js),a(Ze),a(ks),a(ve),a(Us),a(Zs),a(Ge),a(vs),a(Re),a(Cs),a(Gs),a(He),a(Rs),a(Ws),a(Ie),a(Hs),a(Xe),a(Vs),a(Fe),a(Is),a(Xs),a(Fs),a(zs),a(Ns),a(xs),a(Es),a(Ys),a(xe),a(Bs),a(Ls),a(As),a(Ye),a(Qs),a(Be),a(qs),a(Ss),a(Ps),a(Ae),a(Os),a(Ds),a(qe),a(Ks),a(Se),a(el),a(X),a(tl),a(ot),a(sl),a(ll),a(mt),a(al),a(nl),a(rl),a(ft),a(pl),a(dt),a(ol),a(il),a(ut),a(ml),a(x),a(cl),a(fl),a(Ut),a(dl),a($l),a(St)),a(s),M(f,e),M(k,e),M(H,e),M(N,e),M(te,e),M(se,e),M(re,e),M(oe,e),M(me,e),M(fe,e),M($e,e),M(he,e),M(Me,e),M(be,e),M(je,e),M(A,e),M(_e,e),M(ke,e),M(Ue,e),M(Ce,e),M(We,e),M(Ve,e),M(Q,e),M(q,e),M(ze,e),M(S,e),M(P,e),M(Ne,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(gt),M(yt),M(Tt),M(wt),M(Jt),M(kt,e),M(Zt,e)}}}const yn='{"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 bn(w){return Ra(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vn extends Wa{constructor(s){super(),Ha(this,s,bn,Mn,Ga,{})}}export{vn as component};
