import{s as je,o as be,n as z}from"../chunks/scheduler.3e4cb221.js";import{S as _e,i as Me,g as u,s as r,r as $,A as ve,h as f,f as e,c as i,j as ge,u as g,x as d,k as ye,y as Te,a as l,v as y,d as h,t as j,w as b}from"../chunks/index.bc693fcb.js";import{T as Fs}from"../chunks/Tip.4df9f752.js";import{C as Z}from"../chunks/CodeBlock.4b1f9331.js";import{F as he,M as Ft}from"../chunks/Markdown.7e12d877.js";import{H as Q}from"../chunks/Heading.fa24041c.js";function we(q){let n,c='你还可以将配置文件保存为字典，甚至只保存自定义配置属性与默认配置属性之间的差异！有关更多详细信息，请参阅 <a href="main_classes/configuration">配置</a> 文档。';return{c(){n=u("p"),n.innerHTML=c},l(a){n=f(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-k41iwq"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:z,d(a){a&&e(n)}}}function qe(q){let n,c="将自定义配置属性加载到模型中：",a,o,_,M,C="这段代码创建了一个具有随机参数而不是预训练权重的模型。在训练该模型之前，您还无法将该模型用于任何用途。训练是一项昂贵且耗时的过程。通常来说，最好使用预训练模型来更快地获得更好的结果，同时仅使用训练所需资源的一小部分。",W,v,J="使用 <code>from_pretrained()</code> 创建预训练模型：",m,T,R,V,G="当加载预训练权重时，如果模型是由 🤗 Transformers 提供的，将自动加载默认模型配置。然而，如果你愿意，仍然可以将默认模型配置的某些或者所有属性替换成你自己的配置：",x,k,U;return o=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRNb2RlbCUwQSUwQW15X2NvbmZpZyUyMCUzRCUyMERpc3RpbEJlcnRDb25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZ5b3VyX21vZGVsX3NhdmVfcGF0aCUyRmNvbmZpZy5qc29uJTIyKSUwQW1vZGVsJTIwJTNEJTIwRGlzdGlsQmVydE1vZGVsKG15X2NvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig.from_pretrained(<span class="hljs-string">&quot;./your_model_save_path/config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertModel(my_config)`,wrap:!1}}),T=new Z({props:{code:"bW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)',wrap:!1}}),k=new Z({props:{code:"bW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwY29uZmlnJTNEbXlfY29uZmlnKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, config=my_config)',wrap:!1}}),{c(){n=u("p"),n.textContent=c,a=r(),$(o.$$.fragment),_=r(),M=u("p"),M.textContent=C,W=r(),v=u("p"),v.innerHTML=J,m=r(),$(T.$$.fragment),R=r(),V=u("p"),V.textContent=G,x=r(),$(k.$$.fragment)},l(p){n=f(p,"P",{"data-svelte-h":!0}),d(n)!=="svelte-1fn6s0p"&&(n.textContent=c),a=i(p),g(o.$$.fragment,p),_=i(p),M=f(p,"P",{"data-svelte-h":!0}),d(M)!=="svelte-1y5tk1f"&&(M.textContent=C),W=i(p),v=f(p,"P",{"data-svelte-h":!0}),d(v)!=="svelte-n7pw95"&&(v.innerHTML=J),m=i(p),g(T.$$.fragment,p),R=i(p),V=f(p,"P",{"data-svelte-h":!0}),d(V)!=="svelte-dvjp91"&&(V.textContent=G),x=i(p),g(k.$$.fragment,p)},m(p,w){l(p,n,w),l(p,a,w),y(o,p,w),l(p,_,w),l(p,M,w),l(p,W,w),l(p,v,w),l(p,m,w),y(T,p,w),l(p,R,w),l(p,V,w),l(p,x,w),y(k,p,w),U=!0},p:z,i(p){U||(h(o.$$.fragment,p),h(T.$$.fragment,p),h(k.$$.fragment,p),U=!0)},o(p){j(o.$$.fragment,p),j(T.$$.fragment,p),j(k.$$.fragment,p),U=!1},d(p){p&&(e(n),e(a),e(_),e(M),e(W),e(v),e(m),e(R),e(V),e(x)),b(o,p),b(T,p),b(k,p)}}}function Ze(q){let n,c;return n=new Ft({props:{$$slots:{default:[qe]},$$scope:{ctx:q}}}),{c(){$(n.$$.fragment)},l(a){g(n.$$.fragment,a)},m(a,o){y(n,a,o),c=!0},p(a,o){const _={};o&2&&(_.$$scope={dirty:o,ctx:a}),n.$set(_)},i(a){c||(h(n.$$.fragment,a),c=!0)},o(a){j(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Je(q){let n,c="将自定义配置属性加载到模型中：",a,o,_,M,C="这段代码创建了一个具有随机参数而不是预训练权重的模型。在训练该模型之前，您还无法将该模型用于任何用途。训练是一项昂贵且耗时的过程。通常来说，最好使用预训练模型来更快地获得更好的结果，同时仅使用训练所需资源的一小部分。",W,v,J="使用 <code>from_pretrained()</code> 创建预训练模型：",m,T,R,V,G="当加载预训练权重时，如果模型是由 🤗 Transformers 提供的，将自动加载默认模型配置。然而，如果你愿意，仍然可以将默认模型配置的某些或者所有属性替换成自己的配置：",x,k,U;return o=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRGlzdGlsQmVydE1vZGVsJTBBJTBBbXlfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydENvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRnlvdXJfbW9kZWxfc2F2ZV9wYXRoJTJGbXlfY29uZmlnLmpzb24lMjIpJTBBdGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRNb2RlbChteV9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFDistilBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig.from_pretrained(<span class="hljs-string">&quot;./your_model_save_path/my_config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertModel(my_config)`,wrap:!1}}),T=new Z({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)',wrap:!1}}),k=new Z({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjBjb25maWclM0RteV9jb25maWcp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, config=my_config)',wrap:!1}}),{c(){n=u("p"),n.textContent=c,a=r(),$(o.$$.fragment),_=r(),M=u("p"),M.textContent=C,W=r(),v=u("p"),v.innerHTML=J,m=r(),$(T.$$.fragment),R=r(),V=u("p"),V.textContent=G,x=r(),$(k.$$.fragment)},l(p){n=f(p,"P",{"data-svelte-h":!0}),d(n)!=="svelte-1fn6s0p"&&(n.textContent=c),a=i(p),g(o.$$.fragment,p),_=i(p),M=f(p,"P",{"data-svelte-h":!0}),d(M)!=="svelte-1y5tk1f"&&(M.textContent=C),W=i(p),v=f(p,"P",{"data-svelte-h":!0}),d(v)!=="svelte-n7pw95"&&(v.innerHTML=J),m=i(p),g(T.$$.fragment,p),R=i(p),V=f(p,"P",{"data-svelte-h":!0}),d(V)!=="svelte-bm53gl"&&(V.textContent=G),x=i(p),g(k.$$.fragment,p)},m(p,w){l(p,n,w),l(p,a,w),y(o,p,w),l(p,_,w),l(p,M,w),l(p,W,w),l(p,v,w),l(p,m,w),y(T,p,w),l(p,R,w),l(p,V,w),l(p,x,w),y(k,p,w),U=!0},p:z,i(p){U||(h(o.$$.fragment,p),h(T.$$.fragment,p),h(k.$$.fragment,p),U=!0)},o(p){j(o.$$.fragment,p),j(T.$$.fragment,p),j(k.$$.fragment,p),U=!1},d(p){p&&(e(n),e(a),e(_),e(M),e(W),e(v),e(m),e(R),e(V),e(x)),b(o,p),b(T,p),b(k,p)}}}function We(q){let n,c;return n=new Ft({props:{$$slots:{default:[Je]},$$scope:{ctx:q}}}),{c(){$(n.$$.fragment)},l(a){g(n.$$.fragment,a)},m(a,o){y(n,a,o),c=!0},p(a,o){const _={};o&2&&(_.$$scope={dirty:o,ctx:a}),n.$set(_)},i(a){c||(h(n.$$.fragment,a),c=!0)},o(a){j(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Ve(q){let n,c="例如，<code>DistilBertForSequenceClassification</code> 是一个带有序列分类头（sequence classification head）的基础 DistilBERT 模型。序列分类头是池化输出之上的线性层。",a,o,_,M,C="通过切换到不同的模型头，可以轻松地将此检查点重复用于其他任务。对于问答任务，你可以使用 <code>DistilBertForQuestionAnswering</code> 模型头。问答头（question answering head）与序列分类头类似，不同点在于它是隐藏状态输出之上的线性层。",W,v,J;return o=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0Rm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),v=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRGb3JRdWVzdGlvbkFuc3dlcmluZyUwQSUwQW1vZGVsJTIwJTNEJTIwRGlzdGlsQmVydEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),{c(){n=u("p"),n.innerHTML=c,a=r(),$(o.$$.fragment),_=r(),M=u("p"),M.innerHTML=C,W=r(),$(v.$$.fragment)},l(m){n=f(m,"P",{"data-svelte-h":!0}),d(n)!=="svelte-16e0zlv"&&(n.innerHTML=c),a=i(m),g(o.$$.fragment,m),_=i(m),M=f(m,"P",{"data-svelte-h":!0}),d(M)!=="svelte-n48y07"&&(M.innerHTML=C),W=i(m),g(v.$$.fragment,m)},m(m,T){l(m,n,T),l(m,a,T),y(o,m,T),l(m,_,T),l(m,M,T),l(m,W,T),y(v,m,T),J=!0},p:z,i(m){J||(h(o.$$.fragment,m),h(v.$$.fragment,m),J=!0)},o(m){j(o.$$.fragment,m),j(v.$$.fragment,m),J=!1},d(m){m&&(e(n),e(a),e(_),e(M),e(W)),b(o,m),b(v,m)}}}function ke(q){let n,c;return n=new Ft({props:{$$slots:{default:[Ve]},$$scope:{ctx:q}}}),{c(){$(n.$$.fragment)},l(a){g(n.$$.fragment,a)},m(a,o){y(n,a,o),c=!0},p(a,o){const _={};o&2&&(_.$$scope={dirty:o,ctx:a}),n.$set(_)},i(a){c||(h(n.$$.fragment,a),c=!0)},o(a){j(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Ce(q){let n,c="例如，<code>TFDistilBertForSequenceClassification</code> 是一个带有序列分类头（sequence classification head）的基础 DistilBERT 模型。序列分类头是池化输出之上的线性层。",a,o,_,M,C="通过切换到不同的模型头,可以轻松地将此检查点重复用于其他任务。对于问答任务，你可以使用 <code>TFDistilBertForQuestionAnswering</code> 模型头。问答头（question answering head）与序列分类头类似，不同点在于它是隐藏状态输出之上的线性层。",W,v,J;return o=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRGlzdGlsQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEF0Zl9tb2RlbCUyMCUzRCUyMFRGRGlzdGlsQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFDistilBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),v=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRGlzdGlsQmVydEZvclF1ZXN0aW9uQW5zd2VyaW5nJTBBJTBBdGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFDistilBertForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),{c(){n=u("p"),n.innerHTML=c,a=r(),$(o.$$.fragment),_=r(),M=u("p"),M.innerHTML=C,W=r(),$(v.$$.fragment)},l(m){n=f(m,"P",{"data-svelte-h":!0}),d(n)!=="svelte-oxpe6x"&&(n.innerHTML=c),a=i(m),g(o.$$.fragment,m),_=i(m),M=f(m,"P",{"data-svelte-h":!0}),d(M)!=="svelte-1yk6r8p"&&(M.innerHTML=C),W=i(m),g(v.$$.fragment,m)},m(m,T){l(m,n,T),l(m,a,T),y(o,m,T),l(m,_,T),l(m,M,T),l(m,W,T),y(v,m,T),J=!0},p:z,i(m){J||(h(o.$$.fragment,m),h(v.$$.fragment,m),J=!0)},o(m){j(o.$$.fragment,m),j(v.$$.fragment,m),J=!1},d(m){m&&(e(n),e(a),e(_),e(M),e(W)),b(o,m),b(v,m)}}}function Re(q){let n,c;return n=new Ft({props:{$$slots:{default:[Ce]},$$scope:{ctx:q}}}),{c(){$(n.$$.fragment)},l(a){g(n.$$.fragment,a)},m(a,o){y(n,a,o),c=!0},p(a,o){const _={};o&2&&(_.$$scope={dirty:o,ctx:a}),n.$set(_)},i(a){c||(h(n.$$.fragment,a),c=!0)},o(a){j(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Ue(q){let n,c='并非每个模型都支持快速分词器。参照这张 <a href="index#supported-frameworks">表格</a> 查看模型是否支持快速分词器。';return{c(){n=u("p"),n.innerHTML=c},l(a){n=f(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-205pqb"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:z,d(a){a&&e(n)}}}function Ge(q){let n,c="默认情况下，<code>AutoTokenizer</code> 将尝试加载快速标记生成器。你可以通过在 <code>from_pretrained</code> 中设置 <code>use_fast=False</code> 以禁用此行为。";return{c(){n=u("p"),n.innerHTML=c},l(a){n=f(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-12jlto4"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:z,d(a){a&&e(n)}}}function xe(q){let n,c="如果您不需要进行任何自定义，只需使用 <code>from_pretrained</code> 方法加载模型的默认图像处理器参数。";return{c(){n=u("p"),n.innerHTML=c},l(a){n=f(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-1tl7krt"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:z,d(a){a&&e(n)}}}function ze(q){let n,c="如果您不需要进行任何自定义，只需使用 <code>from_pretrained</code> 方法加载模型的默认特征提取器参数。";return{c(){n=u("p"),n.innerHTML=c},l(a){n=f(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-paor8k"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:z,d(a){a&&e(n)}}}function Fe(q){let n,c,a,o,_,M,C,W='<a href="model_doc/auto"><code>AutoClass</code></a> 自动推断模型架构并下载预训练的配置和权重。一般来说，我们建议使用 <code>AutoClass</code> 生成与检查点（checkpoint）无关的代码。希望对特定模型参数有更多控制的用户，可以仅从几个基类创建自定义的 🤗 Transformers 模型。这对于任何有兴趣学习、训练或试验 🤗 Transformers 模型的人可能特别有用。通过本指南，深入了解如何不通过 <code>AutoClass</code> 创建自定义模型。了解如何：',v,J,m="<li>加载并自定义模型配置。</li> <li>创建模型架构。</li> <li>为文本创建慢速和快速分词器。</li> <li>为视觉任务创建图像处理器。</li> <li>为音频任务创建特征提取器。</li> <li>为多模态任务创建处理器。</li>",T,R,V,G,x='<a href="main_classes/configuration">配置</a> 涉及到模型的具体属性。每个模型配置都有不同的属性；例如，所有 NLP 模型都共享 <code>hidden_size</code>、<code>num_attention_heads</code>、 <code>num_hidden_layers</code> 和 <code>vocab_size</code> 属性。这些属性用于指定构建模型时的注意力头数量或隐藏层层数。',k,U,p='访问 <code>DistilBertConfig</code> 以更近一步了解 <a href="model_doc/distilbert">DistilBERT</a>，检查它的属性：',w,I,Hs,N,Ht="<code>DistilBertConfig</code> 显示了构建基础 <code>DistilBertModel</code> 所使用的所有默认属性。所有属性都可以进行自定义，为实验创造了空间。例如，您可以将默认模型自定义为：",Xs,P,Xt="<li>使用 <code>activation</code> 参数尝试不同的激活函数。</li> <li>使用 <code>attention_dropout</code> 参数为 attention probabilities 使用更高的 dropout ratio。</li>",Bs,D,Es,S,Bt="预训练模型的属性可以在 <code>from_pretrained()</code> 函数中进行修改：",Ys,A,Ls,K,Et="当你对模型配置满意时，可以使用 <code>save_pretrained()</code> 来保存配置。你的配置文件将以 JSON 文件的形式存储在指定的保存目录中：",Qs,O,Is,ss,Yt="要重用配置文件，请使用 <code>from_pretrained()</code> 进行加载：",Ns,ts,Ps,F,Ds,es,Ss,ls,Lt='接下来，创建一个<a href="main_classes/models">模型</a>。模型，也可泛指架构，定义了每一层网络的行为以及进行的操作。配置中的 <code>num_hidden_layers</code> 等属性用于定义架构。每个模型都共享基类 <code>PreTrainedModel</code> 和一些常用方法，例如调整输入嵌入的大小和修剪自注意力头。此外，所有模型都是 <a href="https://pytorch.org/docs/stable/generated/torch.nn.Module.html" rel="nofollow"><code>torch.nn.Module</code></a>、<a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow"><code>tf.keras.Model</code></a> 或 <a href="https://flax.readthedocs.io/en/latest/flax.linen.html#module" rel="nofollow"><code>flax.linen.Module</code></a> 的子类。这意味着模型与各自框架的用法兼容。',As,H,Ks,ns,Os,as,Qt="此时，你已经有了一个输出<em>隐藏状态</em>的基础 DistilBERT 模型。隐藏状态作为输入传递到模型头以生成最终输出。🤗 Transformers 为每个任务提供不同的模型头，只要模型支持该任务（即，您不能使用 DistilBERT 来执行像翻译这样的序列到序列任务）。",st,X,tt,ps,et,rs,It='在将模型用于文本数据之前，你需要的最后一个基类是 <a href="main_classes/tokenizer">tokenizer</a>，它用于将原始文本转换为张量。🤗 Transformers 支持两种类型的分词器：',lt,is,Nt='<li><code>PreTrainedTokenizer</code>：分词器的Python实现</li> <li><code>PreTrainedTokenizerFast</code>：来自我们基于 Rust 的 <a href="https://huggingface.co/docs/tokenizers/python/latest/" rel="nofollow">🤗 Tokenizer</a> 库的分词器。因为其使用了 Rust 实现，这种分词器类型的速度要快得多，尤其是在批量分词（batch tokenization）的时候。快速分词器还提供其他的方法，例如<em>偏移映射（offset mapping）</em>，它将标记（token）映射到其原始单词或字符。</li>',nt,os,Pt="这两种分词器都支持常用的方法，如编码和解码、添加新标记以及管理特殊标记。",at,B,pt,ms,Dt="如果您训练了自己的分词器，则可以从<em>词表</em>文件创建一个分词器：",rt,cs,it,us,St="请务必记住，自定义分词器生成的词表与预训练模型分词器生成的词表是不同的。如果使用预训练模型，则需要使用预训练模型的词表，否则输入将没有意义。 使用 <code>DistilBertTokenizer</code> 类创建具有预训练模型词表的分词器：",ot,fs,mt,ds,At="使用 <code>DistilBertTokenizerFast</code> 类创建快速分词器：",ct,$s,ut,E,ft,gs,dt,ys,Kt="图像处理器用于处理视觉输入。它继承自 <code>ImageProcessingMixin</code> 基类。",$t,hs,Ot='要使用它，需要创建一个与你使用的模型关联的图像处理器。例如，如果你使用 <a href="model_doc/vit">ViT</a> 进行图像分类，可以创建一个默认的 <code>ViTImageProcessor</code>：',gt,js,yt,Y,ht,bs,se="修改任何 <code>ViTImageProcessor</code> 参数以创建自定义图像处理器：",jt,_s,bt,Ms,_t,vs,te="特征提取器用于处理音频输入。它继承自 <code>FeatureExtractionMixin</code> 基类，亦可继承 <code>SequenceFeatureExtractor</code> 类来处理音频输入。",Mt,Ts,ee='要使用它，创建一个与你使用的模型关联的特征提取器。例如，如果你使用 <a href="model_doc/wav2vec2">Wav2Vec2</a> 进行音频分类，可以创建一个默认的 <code>Wav2Vec2FeatureExtractor</code>：',vt,ws,Tt,L,wt,qs,le="修改任何 <code>Wav2Vec2FeatureExtractor</code> 参数以创建自定义特征提取器：",qt,Zs,Zt,Js,Jt,Ws,ne="对于支持多模式任务的模型，🤗 Transformers 提供了一个处理器类，可以方便地将特征提取器和分词器等处理类包装到单个对象中。例如，让我们使用 <code>Wav2Vec2Processor</code> 来执行自动语音识别任务 (ASR)。 ASR 将音频转录为文本，因此您将需要一个特征提取器和一个分词器。",Wt,Vs,ae="创建一个特征提取器来处理音频输入：",Vt,ks,kt,Cs,pe="创建一个分词器来处理文本输入：",Ct,Rs,Rt,Us,re="将特征提取器和分词器合并到 <code>Wav2Vec2Processor</code> 中：",Ut,Gs,Gt,xs,ie="通过两个基类 - 配置类和模型类 - 以及一个附加的预处理类（分词器、图像处理器、特征提取器或处理器），你可以创建 🤗 Transformers 支持的任何模型。 每个基类都是可配置的，允许你使用所需的特定属性。 你可以轻松设置模型进行训练或修改现有的预训练模型进行微调。",xt,zs,zt;return _=new Q({props:{title:"创建自定义架构",local:"创建自定义架构",headingTag:"h1"}}),R=new Q({props:{title:"配置",local:"配置",headingTag:"h2"}}),I=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRDb25maWclMEElMEFjb25maWclMjAlM0QlMjBEaXN0aWxCZXJ0Q29uZmlnKCklMEFwcmludChjb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>config = DistilBertConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(config)
DistilBertConfig {
  <span class="hljs-string">&quot;activation&quot;</span>: <span class="hljs-string">&quot;gelu&quot;</span>,
  <span class="hljs-string">&quot;attention_dropout&quot;</span>: <span class="hljs-number">0.1</span>,
  <span class="hljs-string">&quot;dim&quot;</span>: <span class="hljs-number">768</span>,
  <span class="hljs-string">&quot;dropout&quot;</span>: <span class="hljs-number">0.1</span>,
  <span class="hljs-string">&quot;hidden_dim&quot;</span>: <span class="hljs-number">3072</span>,
  <span class="hljs-string">&quot;initializer_range&quot;</span>: <span class="hljs-number">0.02</span>,
  <span class="hljs-string">&quot;max_position_embeddings&quot;</span>: <span class="hljs-number">512</span>,
  <span class="hljs-string">&quot;model_type&quot;</span>: <span class="hljs-string">&quot;distilbert&quot;</span>,
  <span class="hljs-string">&quot;n_heads&quot;</span>: <span class="hljs-number">12</span>,
  <span class="hljs-string">&quot;n_layers&quot;</span>: <span class="hljs-number">6</span>,
  <span class="hljs-string">&quot;pad_token_id&quot;</span>: <span class="hljs-number">0</span>,
  <span class="hljs-string">&quot;qa_dropout&quot;</span>: <span class="hljs-number">0.1</span>,
  <span class="hljs-string">&quot;seq_classif_dropout&quot;</span>: <span class="hljs-number">0.2</span>,
  <span class="hljs-string">&quot;sinusoidal_pos_embds&quot;</span>: false,
  <span class="hljs-string">&quot;transformers_version&quot;</span>: <span class="hljs-string">&quot;4.16.2&quot;</span>,
  <span class="hljs-string">&quot;vocab_size&quot;</span>: <span class="hljs-number">30522</span>
}`,wrap:!1}}),D=new Z({props:{code:"bXlfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydENvbmZpZyhhY3RpdmF0aW9uJTNEJTIycmVsdSUyMiUyQyUyMGF0dGVudGlvbl9kcm9wb3V0JTNEMC40KSUwQXByaW50KG15X2NvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig(activation=<span class="hljs-string">&quot;relu&quot;</span>, attention_dropout=<span class="hljs-number">0.4</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(my_config)
DistilBertConfig {
  <span class="hljs-string">&quot;activation&quot;</span>: <span class="hljs-string">&quot;relu&quot;</span>,
  <span class="hljs-string">&quot;attention_dropout&quot;</span>: <span class="hljs-number">0.4</span>,
  <span class="hljs-string">&quot;dim&quot;</span>: <span class="hljs-number">768</span>,
  <span class="hljs-string">&quot;dropout&quot;</span>: <span class="hljs-number">0.1</span>,
  <span class="hljs-string">&quot;hidden_dim&quot;</span>: <span class="hljs-number">3072</span>,
  <span class="hljs-string">&quot;initializer_range&quot;</span>: <span class="hljs-number">0.02</span>,
  <span class="hljs-string">&quot;max_position_embeddings&quot;</span>: <span class="hljs-number">512</span>,
  <span class="hljs-string">&quot;model_type&quot;</span>: <span class="hljs-string">&quot;distilbert&quot;</span>,
  <span class="hljs-string">&quot;n_heads&quot;</span>: <span class="hljs-number">12</span>,
  <span class="hljs-string">&quot;n_layers&quot;</span>: <span class="hljs-number">6</span>,
  <span class="hljs-string">&quot;pad_token_id&quot;</span>: <span class="hljs-number">0</span>,
  <span class="hljs-string">&quot;qa_dropout&quot;</span>: <span class="hljs-number">0.1</span>,
  <span class="hljs-string">&quot;seq_classif_dropout&quot;</span>: <span class="hljs-number">0.2</span>,
  <span class="hljs-string">&quot;sinusoidal_pos_embds&quot;</span>: false,
  <span class="hljs-string">&quot;transformers_version&quot;</span>: <span class="hljs-string">&quot;4.16.2&quot;</span>,
  <span class="hljs-string">&quot;vocab_size&quot;</span>: <span class="hljs-number">30522</span>
}`,wrap:!1}}),A=new Z({props:{code:"bXlfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydENvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjBhY3RpdmF0aW9uJTNEJTIycmVsdSUyMiUyQyUyMGF0dGVudGlvbl9kcm9wb3V0JTNEMC40KQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, activation=<span class="hljs-string">&quot;relu&quot;</span>, attention_dropout=<span class="hljs-number">0.4</span>)',wrap:!1}}),O=new Z({props:{code:"bXlfY29uZmlnLnNhdmVfcHJldHJhaW5lZChzYXZlX2RpcmVjdG9yeSUzRCUyMi4lMkZ5b3VyX21vZGVsX3NhdmVfcGF0aCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>my_config.save_pretrained(save_directory=<span class="hljs-string">&quot;./your_model_save_path&quot;</span>)',wrap:!1}}),ts=new Z({props:{code:"bXlfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydENvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRnlvdXJfbW9kZWxfc2F2ZV9wYXRoJTJGY29uZmlnLmpzb24lMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig.from_pretrained(<span class="hljs-string">&quot;./your_model_save_path/config.json&quot;</span>)',wrap:!1}}),F=new Fs({props:{$$slots:{default:[we]},$$scope:{ctx:q}}}),es=new Q({props:{title:"模型",local:"模型",headingTag:"h2"}}),H=new he({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[We],pytorch:[Ze]},$$scope:{ctx:q}}}),ns=new Q({props:{title:"模型头（Model heads）",local:"模型头model-heads",headingTag:"h3"}}),X=new he({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Re],pytorch:[ke]},$$scope:{ctx:q}}}),ps=new Q({props:{title:"分词器",local:"分词器",headingTag:"h2"}}),B=new Fs({props:{warning:!0,$$slots:{default:[Ue]},$$scope:{ctx:q}}}),cs=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRUb2tlbml6ZXIlMEElMEFteV90b2tlbml6ZXIlMjAlM0QlMjBEaXN0aWxCZXJ0VG9rZW5pemVyKHZvY2FiX2ZpbGUlM0QlMjJteV92b2NhYl9maWxlLnR4dCUyMiUyQyUyMGRvX2xvd2VyX2Nhc2UlM0RGYWxzZSUyQyUyMHBhZGRpbmdfc2lkZSUzRCUyMmxlZnQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>my_tokenizer = DistilBertTokenizer(vocab_file=<span class="hljs-string">&quot;my_vocab_file.txt&quot;</span>, do_lower_case=<span class="hljs-literal">False</span>, padding_side=<span class="hljs-string">&quot;left&quot;</span>)`,wrap:!1}}),fs=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRUb2tlbml6ZXIlMEElMEFzbG93X3Rva2VuaXplciUyMCUzRCUyMERpc3RpbEJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>slow_tokenizer = DistilBertTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),$s=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRUb2tlbml6ZXJGYXN0JTBBJTBBZmFzdF90b2tlbml6ZXIlMjAlM0QlMjBEaXN0aWxCZXJ0VG9rZW5pemVyRmFzdC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DistilBertTokenizerFast

<span class="hljs-meta">&gt;&gt;&gt; </span>fast_tokenizer = DistilBertTokenizerFast.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`,wrap:!1}}),E=new Fs({props:{$$slots:{default:[Ge]},$$scope:{ctx:q}}}),gs=new Q({props:{title:"图像处理器",local:"图像处理器",headingTag:"h2"}}),js=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpVEltYWdlUHJvY2Vzc29yJTBBJTBBdml0X2V4dHJhY3RvciUyMCUzRCUyMFZpVEltYWdlUHJvY2Vzc29yKCklMEFwcmludCh2aXRfZXh0cmFjdG9yKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ViTImageProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>vit_extractor = ViTImageProcessor()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(vit_extractor)
ViTImageProcessor {
  <span class="hljs-string">&quot;do_normalize&quot;</span>: true,
  <span class="hljs-string">&quot;do_resize&quot;</span>: true,
  <span class="hljs-string">&quot;image_processor_type&quot;</span>: <span class="hljs-string">&quot;ViTImageProcessor&quot;</span>,
  <span class="hljs-string">&quot;image_mean&quot;</span>: [
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>
  ],
  <span class="hljs-string">&quot;image_std&quot;</span>: [
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>
  ],
  <span class="hljs-string">&quot;resample&quot;</span>: <span class="hljs-number">2</span>,
  <span class="hljs-string">&quot;size&quot;</span>: <span class="hljs-number">224</span>
}`,wrap:!1}}),Y=new Fs({props:{$$slots:{default:[xe]},$$scope:{ctx:q}}}),_s=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpVEltYWdlUHJvY2Vzc29yJTBBJTBBbXlfdml0X2V4dHJhY3RvciUyMCUzRCUyMFZpVEltYWdlUHJvY2Vzc29yKHJlc2FtcGxlJTNEJTIyUElMLkltYWdlLkJPWCUyMiUyQyUyMGRvX25vcm1hbGl6ZSUzREZhbHNlJTJDJTIwaW1hZ2VfbWVhbiUzRCU1QjAuMyUyQyUyMDAuMyUyQyUyMDAuMyU1RCklMEFwcmludChteV92aXRfZXh0cmFjdG9yKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ViTImageProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>my_vit_extractor = ViTImageProcessor(resample=<span class="hljs-string">&quot;PIL.Image.BOX&quot;</span>, do_normalize=<span class="hljs-literal">False</span>, image_mean=[<span class="hljs-number">0.3</span>, <span class="hljs-number">0.3</span>, <span class="hljs-number">0.3</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(my_vit_extractor)
ViTImageProcessor {
  <span class="hljs-string">&quot;do_normalize&quot;</span>: false,
  <span class="hljs-string">&quot;do_resize&quot;</span>: true,
  <span class="hljs-string">&quot;image_processor_type&quot;</span>: <span class="hljs-string">&quot;ViTImageProcessor&quot;</span>,
  <span class="hljs-string">&quot;image_mean&quot;</span>: [
    <span class="hljs-number">0.3</span>,
    <span class="hljs-number">0.3</span>,
    <span class="hljs-number">0.3</span>
  ],
  <span class="hljs-string">&quot;image_std&quot;</span>: [
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>,
    <span class="hljs-number">0.5</span>
  ],
  <span class="hljs-string">&quot;resample&quot;</span>: <span class="hljs-string">&quot;PIL.Image.BOX&quot;</span>,
  <span class="hljs-string">&quot;size&quot;</span>: <span class="hljs-number">224</span>
}`,wrap:!1}}),Ms=new Q({props:{title:"特征提取器",local:"特征提取器",headingTag:"h2"}}),ws=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRmVhdHVyZUV4dHJhY3RvciUwQSUwQXcydjJfZXh0cmFjdG9yJTIwJTNEJTIwV2F2MlZlYzJGZWF0dXJlRXh0cmFjdG9yKCklMEFwcmludCh3MnYyX2V4dHJhY3Rvcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2FeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>w2v2_extractor = Wav2Vec2FeatureExtractor()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(w2v2_extractor)
Wav2Vec2FeatureExtractor {
  <span class="hljs-string">&quot;do_normalize&quot;</span>: true,
  <span class="hljs-string">&quot;feature_extractor_type&quot;</span>: <span class="hljs-string">&quot;Wav2Vec2FeatureExtractor&quot;</span>,
  <span class="hljs-string">&quot;feature_size&quot;</span>: <span class="hljs-number">1</span>,
  <span class="hljs-string">&quot;padding_side&quot;</span>: <span class="hljs-string">&quot;right&quot;</span>,
  <span class="hljs-string">&quot;padding_value&quot;</span>: <span class="hljs-number">0.0</span>,
  <span class="hljs-string">&quot;return_attention_mask&quot;</span>: false,
  <span class="hljs-string">&quot;sampling_rate&quot;</span>: <span class="hljs-number">16000</span>
}`,wrap:!1}}),L=new Fs({props:{$$slots:{default:[ze]},$$scope:{ctx:q}}}),Zs=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRmVhdHVyZUV4dHJhY3RvciUwQSUwQXcydjJfZXh0cmFjdG9yJTIwJTNEJTIwV2F2MlZlYzJGZWF0dXJlRXh0cmFjdG9yKHNhbXBsaW5nX3JhdGUlM0Q4MDAwJTJDJTIwZG9fbm9ybWFsaXplJTNERmFsc2UpJTBBcHJpbnQodzJ2Ml9leHRyYWN0b3Ip",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2FeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>w2v2_extractor = Wav2Vec2FeatureExtractor(sampling_rate=<span class="hljs-number">8000</span>, do_normalize=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(w2v2_extractor)
Wav2Vec2FeatureExtractor {
  <span class="hljs-string">&quot;do_normalize&quot;</span>: false,
  <span class="hljs-string">&quot;feature_extractor_type&quot;</span>: <span class="hljs-string">&quot;Wav2Vec2FeatureExtractor&quot;</span>,
  <span class="hljs-string">&quot;feature_size&quot;</span>: <span class="hljs-number">1</span>,
  <span class="hljs-string">&quot;padding_side&quot;</span>: <span class="hljs-string">&quot;right&quot;</span>,
  <span class="hljs-string">&quot;padding_value&quot;</span>: <span class="hljs-number">0.0</span>,
  <span class="hljs-string">&quot;return_attention_mask&quot;</span>: false,
  <span class="hljs-string">&quot;sampling_rate&quot;</span>: <span class="hljs-number">8000</span>
}`,wrap:!1}}),Js=new Q({props:{title:"处理器",local:"处理器",headingTag:"h2"}}),ks=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRmVhdHVyZUV4dHJhY3RvciUwQSUwQWZlYXR1cmVfZXh0cmFjdG9yJTIwJTNEJTIwV2F2MlZlYzJGZWF0dXJlRXh0cmFjdG9yKHBhZGRpbmdfdmFsdWUlM0QxLjAlMkMlMjBkb19ub3JtYWxpemUlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2FeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = Wav2Vec2FeatureExtractor(padding_value=<span class="hljs-number">1.0</span>, do_normalize=<span class="hljs-literal">True</span>)`,wrap:!1}}),Rs=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyQ1RDVG9rZW5pemVyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwV2F2MlZlYzJDVENUb2tlbml6ZXIodm9jYWJfZmlsZSUzRCUyMm15X3ZvY2FiX2ZpbGUudHh0JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2CTCTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = Wav2Vec2CTCTokenizer(vocab_file=<span class="hljs-string">&quot;my_vocab_file.txt&quot;</span>)`,wrap:!1}}),Gs=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyUHJvY2Vzc29yJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwV2F2MlZlYzJQcm9jZXNzb3IoZmVhdHVyZV9leHRyYWN0b3IlM0RmZWF0dXJlX2V4dHJhY3RvciUyQyUyMHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2Processor

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = Wav2Vec2Processor(feature_extractor=feature_extractor, tokenizer=tokenizer)`,wrap:!1}}),{c(){n=u("meta"),c=r(),a=u("p"),o=r(),$(_.$$.fragment),M=r(),C=u("p"),C.innerHTML=W,v=r(),J=u("ul"),J.innerHTML=m,T=r(),$(R.$$.fragment),V=r(),G=u("p"),G.innerHTML=x,k=r(),U=u("p"),U.innerHTML=p,w=r(),$(I.$$.fragment),Hs=r(),N=u("p"),N.innerHTML=Ht,Xs=r(),P=u("ul"),P.innerHTML=Xt,Bs=r(),$(D.$$.fragment),Es=r(),S=u("p"),S.innerHTML=Bt,Ys=r(),$(A.$$.fragment),Ls=r(),K=u("p"),K.innerHTML=Et,Qs=r(),$(O.$$.fragment),Is=r(),ss=u("p"),ss.innerHTML=Yt,Ns=r(),$(ts.$$.fragment),Ps=r(),$(F.$$.fragment),Ds=r(),$(es.$$.fragment),Ss=r(),ls=u("p"),ls.innerHTML=Lt,As=r(),$(H.$$.fragment),Ks=r(),$(ns.$$.fragment),Os=r(),as=u("p"),as.innerHTML=Qt,st=r(),$(X.$$.fragment),tt=r(),$(ps.$$.fragment),et=r(),rs=u("p"),rs.innerHTML=It,lt=r(),is=u("ul"),is.innerHTML=Nt,nt=r(),os=u("p"),os.textContent=Pt,at=r(),$(B.$$.fragment),pt=r(),ms=u("p"),ms.innerHTML=Dt,rt=r(),$(cs.$$.fragment),it=r(),us=u("p"),us.innerHTML=St,ot=r(),$(fs.$$.fragment),mt=r(),ds=u("p"),ds.innerHTML=At,ct=r(),$($s.$$.fragment),ut=r(),$(E.$$.fragment),ft=r(),$(gs.$$.fragment),dt=r(),ys=u("p"),ys.innerHTML=Kt,$t=r(),hs=u("p"),hs.innerHTML=Ot,gt=r(),$(js.$$.fragment),yt=r(),$(Y.$$.fragment),ht=r(),bs=u("p"),bs.innerHTML=se,jt=r(),$(_s.$$.fragment),bt=r(),$(Ms.$$.fragment),_t=r(),vs=u("p"),vs.innerHTML=te,Mt=r(),Ts=u("p"),Ts.innerHTML=ee,vt=r(),$(ws.$$.fragment),Tt=r(),$(L.$$.fragment),wt=r(),qs=u("p"),qs.innerHTML=le,qt=r(),$(Zs.$$.fragment),Zt=r(),$(Js.$$.fragment),Jt=r(),Ws=u("p"),Ws.innerHTML=ne,Wt=r(),Vs=u("p"),Vs.textContent=ae,Vt=r(),$(ks.$$.fragment),kt=r(),Cs=u("p"),Cs.textContent=pe,Ct=r(),$(Rs.$$.fragment),Rt=r(),Us=u("p"),Us.innerHTML=re,Ut=r(),$(Gs.$$.fragment),Gt=r(),xs=u("p"),xs.textContent=ie,xt=r(),zs=u("p"),this.h()},l(s){const t=ve("svelte-u9bgzb",document.head);n=f(t,"META",{name:!0,content:!0}),t.forEach(e),c=i(s),a=f(s,"P",{}),ge(a).forEach(e),o=i(s),g(_.$$.fragment,s),M=i(s),C=f(s,"P",{"data-svelte-h":!0}),d(C)!=="svelte-163eq9z"&&(C.innerHTML=W),v=i(s),J=f(s,"UL",{"data-svelte-h":!0}),d(J)!=="svelte-1asek4b"&&(J.innerHTML=m),T=i(s),g(R.$$.fragment,s),V=i(s),G=f(s,"P",{"data-svelte-h":!0}),d(G)!=="svelte-1nly6ic"&&(G.innerHTML=x),k=i(s),U=f(s,"P",{"data-svelte-h":!0}),d(U)!=="svelte-1akqh2h"&&(U.innerHTML=p),w=i(s),g(I.$$.fragment,s),Hs=i(s),N=f(s,"P",{"data-svelte-h":!0}),d(N)!=="svelte-14v2kvo"&&(N.innerHTML=Ht),Xs=i(s),P=f(s,"UL",{"data-svelte-h":!0}),d(P)!=="svelte-13r6eur"&&(P.innerHTML=Xt),Bs=i(s),g(D.$$.fragment,s),Es=i(s),S=f(s,"P",{"data-svelte-h":!0}),d(S)!=="svelte-1b5ytkq"&&(S.innerHTML=Bt),Ys=i(s),g(A.$$.fragment,s),Ls=i(s),K=f(s,"P",{"data-svelte-h":!0}),d(K)!=="svelte-1r2q7uc"&&(K.innerHTML=Et),Qs=i(s),g(O.$$.fragment,s),Is=i(s),ss=f(s,"P",{"data-svelte-h":!0}),d(ss)!=="svelte-dexatr"&&(ss.innerHTML=Yt),Ns=i(s),g(ts.$$.fragment,s),Ps=i(s),g(F.$$.fragment,s),Ds=i(s),g(es.$$.fragment,s),Ss=i(s),ls=f(s,"P",{"data-svelte-h":!0}),d(ls)!=="svelte-5bv5r6"&&(ls.innerHTML=Lt),As=i(s),g(H.$$.fragment,s),Ks=i(s),g(ns.$$.fragment,s),Os=i(s),as=f(s,"P",{"data-svelte-h":!0}),d(as)!=="svelte-qcf0a1"&&(as.innerHTML=Qt),st=i(s),g(X.$$.fragment,s),tt=i(s),g(ps.$$.fragment,s),et=i(s),rs=f(s,"P",{"data-svelte-h":!0}),d(rs)!=="svelte-espr00"&&(rs.innerHTML=It),lt=i(s),is=f(s,"UL",{"data-svelte-h":!0}),d(is)!=="svelte-6kvvo0"&&(is.innerHTML=Nt),nt=i(s),os=f(s,"P",{"data-svelte-h":!0}),d(os)!=="svelte-51pwdw"&&(os.textContent=Pt),at=i(s),g(B.$$.fragment,s),pt=i(s),ms=f(s,"P",{"data-svelte-h":!0}),d(ms)!=="svelte-1f3jbei"&&(ms.innerHTML=Dt),rt=i(s),g(cs.$$.fragment,s),it=i(s),us=f(s,"P",{"data-svelte-h":!0}),d(us)!=="svelte-15lam1s"&&(us.innerHTML=St),ot=i(s),g(fs.$$.fragment,s),mt=i(s),ds=f(s,"P",{"data-svelte-h":!0}),d(ds)!=="svelte-bg238o"&&(ds.innerHTML=At),ct=i(s),g($s.$$.fragment,s),ut=i(s),g(E.$$.fragment,s),ft=i(s),g(gs.$$.fragment,s),dt=i(s),ys=f(s,"P",{"data-svelte-h":!0}),d(ys)!=="svelte-1q5eq9w"&&(ys.innerHTML=Kt),$t=i(s),hs=f(s,"P",{"data-svelte-h":!0}),d(hs)!=="svelte-1evm4el"&&(hs.innerHTML=Ot),gt=i(s),g(js.$$.fragment,s),yt=i(s),g(Y.$$.fragment,s),ht=i(s),bs=f(s,"P",{"data-svelte-h":!0}),d(bs)!=="svelte-y6n2fo"&&(bs.innerHTML=se),jt=i(s),g(_s.$$.fragment,s),bt=i(s),g(Ms.$$.fragment,s),_t=i(s),vs=f(s,"P",{"data-svelte-h":!0}),d(vs)!=="svelte-1u3jb1k"&&(vs.innerHTML=te),Mt=i(s),Ts=f(s,"P",{"data-svelte-h":!0}),d(Ts)!=="svelte-o65i7e"&&(Ts.innerHTML=ee),vt=i(s),g(ws.$$.fragment,s),Tt=i(s),g(L.$$.fragment,s),wt=i(s),qs=f(s,"P",{"data-svelte-h":!0}),d(qs)!=="svelte-wsqmub"&&(qs.innerHTML=le),qt=i(s),g(Zs.$$.fragment,s),Zt=i(s),g(Js.$$.fragment,s),Jt=i(s),Ws=f(s,"P",{"data-svelte-h":!0}),d(Ws)!=="svelte-gboqg0"&&(Ws.innerHTML=ne),Wt=i(s),Vs=f(s,"P",{"data-svelte-h":!0}),d(Vs)!=="svelte-liph8s"&&(Vs.textContent=ae),Vt=i(s),g(ks.$$.fragment,s),kt=i(s),Cs=f(s,"P",{"data-svelte-h":!0}),d(Cs)!=="svelte-v0jq8i"&&(Cs.textContent=pe),Ct=i(s),g(Rs.$$.fragment,s),Rt=i(s),Us=f(s,"P",{"data-svelte-h":!0}),d(Us)!=="svelte-1pme727"&&(Us.innerHTML=re),Ut=i(s),g(Gs.$$.fragment,s),Gt=i(s),xs=f(s,"P",{"data-svelte-h":!0}),d(xs)!=="svelte-11qtpiq"&&(xs.textContent=ie),xt=i(s),zs=f(s,"P",{}),ge(zs).forEach(e),this.h()},h(){ye(n,"name","hf:doc:metadata"),ye(n,"content",He)},m(s,t){Te(document.head,n),l(s,c,t),l(s,a,t),l(s,o,t),y(_,s,t),l(s,M,t),l(s,C,t),l(s,v,t),l(s,J,t),l(s,T,t),y(R,s,t),l(s,V,t),l(s,G,t),l(s,k,t),l(s,U,t),l(s,w,t),y(I,s,t),l(s,Hs,t),l(s,N,t),l(s,Xs,t),l(s,P,t),l(s,Bs,t),y(D,s,t),l(s,Es,t),l(s,S,t),l(s,Ys,t),y(A,s,t),l(s,Ls,t),l(s,K,t),l(s,Qs,t),y(O,s,t),l(s,Is,t),l(s,ss,t),l(s,Ns,t),y(ts,s,t),l(s,Ps,t),y(F,s,t),l(s,Ds,t),y(es,s,t),l(s,Ss,t),l(s,ls,t),l(s,As,t),y(H,s,t),l(s,Ks,t),y(ns,s,t),l(s,Os,t),l(s,as,t),l(s,st,t),y(X,s,t),l(s,tt,t),y(ps,s,t),l(s,et,t),l(s,rs,t),l(s,lt,t),l(s,is,t),l(s,nt,t),l(s,os,t),l(s,at,t),y(B,s,t),l(s,pt,t),l(s,ms,t),l(s,rt,t),y(cs,s,t),l(s,it,t),l(s,us,t),l(s,ot,t),y(fs,s,t),l(s,mt,t),l(s,ds,t),l(s,ct,t),y($s,s,t),l(s,ut,t),y(E,s,t),l(s,ft,t),y(gs,s,t),l(s,dt,t),l(s,ys,t),l(s,$t,t),l(s,hs,t),l(s,gt,t),y(js,s,t),l(s,yt,t),y(Y,s,t),l(s,ht,t),l(s,bs,t),l(s,jt,t),y(_s,s,t),l(s,bt,t),y(Ms,s,t),l(s,_t,t),l(s,vs,t),l(s,Mt,t),l(s,Ts,t),l(s,vt,t),y(ws,s,t),l(s,Tt,t),y(L,s,t),l(s,wt,t),l(s,qs,t),l(s,qt,t),y(Zs,s,t),l(s,Zt,t),y(Js,s,t),l(s,Jt,t),l(s,Ws,t),l(s,Wt,t),l(s,Vs,t),l(s,Vt,t),y(ks,s,t),l(s,kt,t),l(s,Cs,t),l(s,Ct,t),y(Rs,s,t),l(s,Rt,t),l(s,Us,t),l(s,Ut,t),y(Gs,s,t),l(s,Gt,t),l(s,xs,t),l(s,xt,t),l(s,zs,t),zt=!0},p(s,[t]){const oe={};t&2&&(oe.$$scope={dirty:t,ctx:s}),F.$set(oe);const me={};t&2&&(me.$$scope={dirty:t,ctx:s}),H.$set(me);const ce={};t&2&&(ce.$$scope={dirty:t,ctx:s}),X.$set(ce);const ue={};t&2&&(ue.$$scope={dirty:t,ctx:s}),B.$set(ue);const fe={};t&2&&(fe.$$scope={dirty:t,ctx:s}),E.$set(fe);const de={};t&2&&(de.$$scope={dirty:t,ctx:s}),Y.$set(de);const $e={};t&2&&($e.$$scope={dirty:t,ctx:s}),L.$set($e)},i(s){zt||(h(_.$$.fragment,s),h(R.$$.fragment,s),h(I.$$.fragment,s),h(D.$$.fragment,s),h(A.$$.fragment,s),h(O.$$.fragment,s),h(ts.$$.fragment,s),h(F.$$.fragment,s),h(es.$$.fragment,s),h(H.$$.fragment,s),h(ns.$$.fragment,s),h(X.$$.fragment,s),h(ps.$$.fragment,s),h(B.$$.fragment,s),h(cs.$$.fragment,s),h(fs.$$.fragment,s),h($s.$$.fragment,s),h(E.$$.fragment,s),h(gs.$$.fragment,s),h(js.$$.fragment,s),h(Y.$$.fragment,s),h(_s.$$.fragment,s),h(Ms.$$.fragment,s),h(ws.$$.fragment,s),h(L.$$.fragment,s),h(Zs.$$.fragment,s),h(Js.$$.fragment,s),h(ks.$$.fragment,s),h(Rs.$$.fragment,s),h(Gs.$$.fragment,s),zt=!0)},o(s){j(_.$$.fragment,s),j(R.$$.fragment,s),j(I.$$.fragment,s),j(D.$$.fragment,s),j(A.$$.fragment,s),j(O.$$.fragment,s),j(ts.$$.fragment,s),j(F.$$.fragment,s),j(es.$$.fragment,s),j(H.$$.fragment,s),j(ns.$$.fragment,s),j(X.$$.fragment,s),j(ps.$$.fragment,s),j(B.$$.fragment,s),j(cs.$$.fragment,s),j(fs.$$.fragment,s),j($s.$$.fragment,s),j(E.$$.fragment,s),j(gs.$$.fragment,s),j(js.$$.fragment,s),j(Y.$$.fragment,s),j(_s.$$.fragment,s),j(Ms.$$.fragment,s),j(ws.$$.fragment,s),j(L.$$.fragment,s),j(Zs.$$.fragment,s),j(Js.$$.fragment,s),j(ks.$$.fragment,s),j(Rs.$$.fragment,s),j(Gs.$$.fragment,s),zt=!1},d(s){s&&(e(c),e(a),e(o),e(M),e(C),e(v),e(J),e(T),e(V),e(G),e(k),e(U),e(w),e(Hs),e(N),e(Xs),e(P),e(Bs),e(Es),e(S),e(Ys),e(Ls),e(K),e(Qs),e(Is),e(ss),e(Ns),e(Ps),e(Ds),e(Ss),e(ls),e(As),e(Ks),e(Os),e(as),e(st),e(tt),e(et),e(rs),e(lt),e(is),e(nt),e(os),e(at),e(pt),e(ms),e(rt),e(it),e(us),e(ot),e(mt),e(ds),e(ct),e(ut),e(ft),e(dt),e(ys),e($t),e(hs),e(gt),e(yt),e(ht),e(bs),e(jt),e(bt),e(_t),e(vs),e(Mt),e(Ts),e(vt),e(Tt),e(wt),e(qs),e(qt),e(Zt),e(Jt),e(Ws),e(Wt),e(Vs),e(Vt),e(kt),e(Cs),e(Ct),e(Rt),e(Us),e(Ut),e(Gt),e(xs),e(xt),e(zs)),e(n),b(_,s),b(R,s),b(I,s),b(D,s),b(A,s),b(O,s),b(ts,s),b(F,s),b(es,s),b(H,s),b(ns,s),b(X,s),b(ps,s),b(B,s),b(cs,s),b(fs,s),b($s,s),b(E,s),b(gs,s),b(js,s),b(Y,s),b(_s,s),b(Ms,s),b(ws,s),b(L,s),b(Zs,s),b(Js,s),b(ks,s),b(Rs,s),b(Gs,s)}}}const He='{"title":"创建自定义架构","local":"创建自定义架构","sections":[{"title":"配置","local":"配置","sections":[],"depth":2},{"title":"模型","local":"模型","sections":[{"title":"模型头（Model heads）","local":"模型头model-heads","sections":[],"depth":3}],"depth":2},{"title":"分词器","local":"分词器","sections":[],"depth":2},{"title":"图像处理器","local":"图像处理器","sections":[],"depth":2},{"title":"特征提取器","local":"特征提取器","sections":[],"depth":2},{"title":"处理器","local":"处理器","sections":[],"depth":2}],"depth":1}';function Xe(q){return be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ne extends _e{constructor(n){super(),Me(this,n,Xe,Fe,je,{})}}export{Ne as component};
