import{s as _e,o as Me,n as x}from"../chunks/scheduler.9991993c.js";import{S as Te,i as ve,g as f,s as p,r as d,A as Ze,h as u,f as e,c as i,j as ye,u as $,x as j,k as be,y as we,a as l,v as g,d as h,t as y,w as b}from"../chunks/index.7fc9a5e7.js";import{T as Fs}from"../chunks/Tip.9de92fc6.js";import{C as q}from"../chunks/CodeBlock.e11cba92.js";import{F as je,M as Xt}from"../chunks/Markdown.87f31c7e.js";import{H as Q,E as qe}from"../chunks/EditOnGithub.84ab7f0e.js";function Je(w){let n,c='你还可以将配置文件保存为字典，甚至只保存自定义配置属性与默认配置属性之间的差异！有关更多详细信息，请参阅 <a href="main_classes/configuration">配置</a> 文档。';return{c(){n=f("p"),n.innerHTML=c},l(a){n=u(a,"P",{"data-svelte-h":!0}),j(n)!=="svelte-k41iwq"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:x,d(a){a&&e(n)}}}function ke(w){let n,c="将自定义配置属性加载到模型中：",a,o,_,M,W="这段代码创建了一个具有随机参数而不是预训练权重的模型。在训练该模型之前，您还无法将该模型用于任何用途。训练是一项昂贵且耗时的过程。通常来说，最好使用预训练模型来更快地获得更好的结果，同时仅使用训练所需资源的一小部分。",k,T,J='使用 <a href="/docs/transformers/pr_31098/zh/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> 创建预训练模型：',m,v,U,R,z="当加载预训练权重时，如果模型是由 🤗 Transformers 提供的，将自动加载默认模型配置。然而，如果你愿意，仍然可以将默认模型配置的某些或者所有属性替换成你自己的配置：",G,C,V;return o=new q({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}}),v=new q({props:{code:"bW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)',wrap:!1}}),C=new q({props:{code:"bW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMGNvbmZpZyUzRG15X2NvbmZpZyk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = DistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, config=my_config)',wrap:!1}}),{c(){n=f("p"),n.textContent=c,a=p(),d(o.$$.fragment),_=p(),M=f("p"),M.textContent=W,k=p(),T=f("p"),T.innerHTML=J,m=p(),d(v.$$.fragment),U=p(),R=f("p"),R.textContent=z,G=p(),d(C.$$.fragment)},l(r){n=u(r,"P",{"data-svelte-h":!0}),j(n)!=="svelte-1fn6s0p"&&(n.textContent=c),a=i(r),$(o.$$.fragment,r),_=i(r),M=u(r,"P",{"data-svelte-h":!0}),j(M)!=="svelte-1y5tk1f"&&(M.textContent=W),k=i(r),T=u(r,"P",{"data-svelte-h":!0}),j(T)!=="svelte-1xp2mfk"&&(T.innerHTML=J),m=i(r),$(v.$$.fragment,r),U=i(r),R=u(r,"P",{"data-svelte-h":!0}),j(R)!=="svelte-dvjp91"&&(R.textContent=z),G=i(r),$(C.$$.fragment,r)},m(r,Z){l(r,n,Z),l(r,a,Z),g(o,r,Z),l(r,_,Z),l(r,M,Z),l(r,k,Z),l(r,T,Z),l(r,m,Z),g(v,r,Z),l(r,U,Z),l(r,R,Z),l(r,G,Z),g(C,r,Z),V=!0},p:x,i(r){V||(h(o.$$.fragment,r),h(v.$$.fragment,r),h(C.$$.fragment,r),V=!0)},o(r){y(o.$$.fragment,r),y(v.$$.fragment,r),y(C.$$.fragment,r),V=!1},d(r){r&&(e(n),e(a),e(_),e(M),e(k),e(T),e(m),e(U),e(R),e(G)),b(o,r),b(v,r),b(C,r)}}}function Re(w){let n,c;return n=new Xt({props:{$$slots:{default:[ke]},$$scope:{ctx:w}}}),{c(){d(n.$$.fragment)},l(a){$(n.$$.fragment,a)},m(a,o){g(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){y(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Ce(w){let n,c="将自定义配置属性加载到模型中：",a,o,_,M,W="这段代码创建了一个具有随机参数而不是预训练权重的模型。在训练该模型之前，您还无法将该模型用于任何用途。训练是一项昂贵且耗时的过程。通常来说，最好使用预训练模型来更快地获得更好的结果，同时仅使用训练所需资源的一小部分。",k,T,J='使用 <a href="/docs/transformers/pr_31098/zh/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> 创建预训练模型：',m,v,U,R,z="当加载预训练权重时，如果模型是由 🤗 Transformers 提供的，将自动加载默认模型配置。然而，如果你愿意，仍然可以将默认模型配置的某些或者所有属性替换成自己的配置：",G,C,V;return o=new q({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}}),v=new q({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)',wrap:!1}}),C=new q({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwY29uZmlnJTNEbXlfY29uZmlnKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertModel.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, config=my_config)',wrap:!1}}),{c(){n=f("p"),n.textContent=c,a=p(),d(o.$$.fragment),_=p(),M=f("p"),M.textContent=W,k=p(),T=f("p"),T.innerHTML=J,m=p(),d(v.$$.fragment),U=p(),R=f("p"),R.textContent=z,G=p(),d(C.$$.fragment)},l(r){n=u(r,"P",{"data-svelte-h":!0}),j(n)!=="svelte-1fn6s0p"&&(n.textContent=c),a=i(r),$(o.$$.fragment,r),_=i(r),M=u(r,"P",{"data-svelte-h":!0}),j(M)!=="svelte-1y5tk1f"&&(M.textContent=W),k=i(r),T=u(r,"P",{"data-svelte-h":!0}),j(T)!=="svelte-1svjbj6"&&(T.innerHTML=J),m=i(r),$(v.$$.fragment,r),U=i(r),R=u(r,"P",{"data-svelte-h":!0}),j(R)!=="svelte-bm53gl"&&(R.textContent=z),G=i(r),$(C.$$.fragment,r)},m(r,Z){l(r,n,Z),l(r,a,Z),g(o,r,Z),l(r,_,Z),l(r,M,Z),l(r,k,Z),l(r,T,Z),l(r,m,Z),g(v,r,Z),l(r,U,Z),l(r,R,Z),l(r,G,Z),g(C,r,Z),V=!0},p:x,i(r){V||(h(o.$$.fragment,r),h(v.$$.fragment,r),h(C.$$.fragment,r),V=!0)},o(r){y(o.$$.fragment,r),y(v.$$.fragment,r),y(C.$$.fragment,r),V=!1},d(r){r&&(e(n),e(a),e(_),e(M),e(k),e(T),e(m),e(U),e(R),e(G)),b(o,r),b(v,r),b(C,r)}}}function We(w){let n,c;return n=new Xt({props:{$$slots:{default:[Ce]},$$scope:{ctx:w}}}),{c(){d(n.$$.fragment)},l(a){$(n.$$.fragment,a)},m(a,o){g(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){y(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function Ue(w){let n,c="例如，<code>DistilBertForSequenceClassification</code> 是一个带有序列分类头（sequence classification head）的基础 DistilBERT 模型。序列分类头是池化输出之上的线性层。",a,o,_,M,W="通过切换到不同的模型头，可以轻松地将此检查点重复用于其他任务。对于问答任务，你可以使用 <code>DistilBertForQuestionAnswering</code> 模型头。问答头（question answering head）与序列分类头类似，不同点在于它是隐藏状态输出之上的线性层。",k,T,J;return o=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0Rm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),T=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRGb3JRdWVzdGlvbkFuc3dlcmluZyUwQSUwQW1vZGVsJTIwJTNEJTIwRGlzdGlsQmVydEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=c,a=p(),d(o.$$.fragment),_=p(),M=f("p"),M.innerHTML=W,k=p(),d(T.$$.fragment)},l(m){n=u(m,"P",{"data-svelte-h":!0}),j(n)!=="svelte-16e0zlv"&&(n.innerHTML=c),a=i(m),$(o.$$.fragment,m),_=i(m),M=u(m,"P",{"data-svelte-h":!0}),j(M)!=="svelte-n48y07"&&(M.innerHTML=W),k=i(m),$(T.$$.fragment,m)},m(m,v){l(m,n,v),l(m,a,v),g(o,m,v),l(m,_,v),l(m,M,v),l(m,k,v),g(T,m,v),J=!0},p:x,i(m){J||(h(o.$$.fragment,m),h(T.$$.fragment,m),J=!0)},o(m){y(o.$$.fragment,m),y(T.$$.fragment,m),J=!1},d(m){m&&(e(n),e(a),e(_),e(M),e(k)),b(o,m),b(T,m)}}}function Ve(w){let n,c;return n=new Xt({props:{$$slots:{default:[Ue]},$$scope:{ctx:w}}}),{c(){d(n.$$.fragment)},l(a){$(n.$$.fragment,a)},m(a,o){g(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){y(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function ze(w){let n,c="例如，<code>TFDistilBertForSequenceClassification</code> 是一个带有序列分类头（sequence classification head）的基础 DistilBERT 模型。序列分类头是池化输出之上的线性层。",a,o,_,M,W="通过切换到不同的模型头,可以轻松地将此检查点重复用于其他任务。对于问答任务，你可以使用 <code>TFDistilBertForQuestionAnswering</code> 模型头。问答头（question answering head）与序列分类头类似，不同点在于它是隐藏状态输出之上的线性层。",k,T,J;return o=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRGlzdGlsQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEF0Zl9tb2RlbCUyMCUzRCUyMFRGRGlzdGlsQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),T=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRGlzdGlsQmVydEZvclF1ZXN0aW9uQW5zd2VyaW5nJTBBJTBBdGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=c,a=p(),d(o.$$.fragment),_=p(),M=f("p"),M.innerHTML=W,k=p(),d(T.$$.fragment)},l(m){n=u(m,"P",{"data-svelte-h":!0}),j(n)!=="svelte-oxpe6x"&&(n.innerHTML=c),a=i(m),$(o.$$.fragment,m),_=i(m),M=u(m,"P",{"data-svelte-h":!0}),j(M)!=="svelte-1yk6r8p"&&(M.innerHTML=W),k=i(m),$(T.$$.fragment,m)},m(m,v){l(m,n,v),l(m,a,v),g(o,m,v),l(m,_,v),l(m,M,v),l(m,k,v),g(T,m,v),J=!0},p:x,i(m){J||(h(o.$$.fragment,m),h(T.$$.fragment,m),J=!0)},o(m){y(o.$$.fragment,m),y(T.$$.fragment,m),J=!1},d(m){m&&(e(n),e(a),e(_),e(M),e(k)),b(o,m),b(T,m)}}}function Ge(w){let n,c;return n=new Xt({props:{$$slots:{default:[ze]},$$scope:{ctx:w}}}),{c(){d(n.$$.fragment)},l(a){$(n.$$.fragment,a)},m(a,o){g(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){y(n.$$.fragment,a),c=!1},d(a){b(n,a)}}}function xe(w){let n,c='并非每个模型都支持快速分词器。参照这张 <a href="index#supported-frameworks">表格</a> 查看模型是否支持快速分词器。';return{c(){n=f("p"),n.innerHTML=c},l(a){n=u(a,"P",{"data-svelte-h":!0}),j(n)!=="svelte-205pqb"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:x,d(a){a&&e(n)}}}function He(w){let n,c="默认情况下，<code>AutoTokenizer</code> 将尝试加载快速标记生成器。你可以通过在 <code>from_pretrained</code> 中设置 <code>use_fast=False</code> 以禁用此行为。";return{c(){n=f("p"),n.innerHTML=c},l(a){n=u(a,"P",{"data-svelte-h":!0}),j(n)!=="svelte-12jlto4"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:x,d(a){a&&e(n)}}}function Fe(w){let n,c="如果您不需要进行任何自定义，只需使用 <code>from_pretrained</code> 方法加载模型的默认图像处理器参数。";return{c(){n=f("p"),n.innerHTML=c},l(a){n=u(a,"P",{"data-svelte-h":!0}),j(n)!=="svelte-1tl7krt"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:x,d(a){a&&e(n)}}}function Xe(w){let n,c="如果您不需要进行任何自定义，只需使用 <code>from_pretrained</code> 方法加载模型的默认特征提取器参数。";return{c(){n=f("p"),n.innerHTML=c},l(a){n=u(a,"P",{"data-svelte-h":!0}),j(n)!=="svelte-paor8k"&&(n.innerHTML=c)},m(a,o){l(a,n,o)},p:x,d(a){a&&e(n)}}}function Be(w){let n,c,a,o,_,M,W,k='<a href="model_doc/auto"><code>AutoClass</code></a> 自动推断模型架构并下载预训练的配置和权重。一般来说，我们建议使用 <code>AutoClass</code> 生成与检查点（checkpoint）无关的代码。希望对特定模型参数有更多控制的用户，可以仅从几个基类创建自定义的 🤗 Transformers 模型。这对于任何有兴趣学习、训练或试验 🤗 Transformers 模型的人可能特别有用。通过本指南，深入了解如何不通过 <code>AutoClass</code> 创建自定义模型。了解如何：',T,J,m="<li>加载并自定义模型配置。</li> <li>创建模型架构。</li> <li>为文本创建慢速和快速分词器。</li> <li>为视觉任务创建图像处理器。</li> <li>为音频任务创建特征提取器。</li> <li>为多模态任务创建处理器。</li>",v,U,R,z,G='<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> 属性。这些属性用于指定构建模型时的注意力头数量或隐藏层层数。',C,V,r='访问 <code>DistilBertConfig</code> 以更近一步了解 <a href="model_doc/distilbert">DistilBERT</a>，检查它的属性：',Z,P,Xs,N,Bt="<code>DistilBertConfig</code> 显示了构建基础 <code>DistilBertModel</code> 所使用的所有默认属性。所有属性都可以进行自定义，为实验创造了空间。例如，您可以将默认模型自定义为：",Bs,I,Et="<li>使用 <code>activation</code> 参数尝试不同的激活函数。</li> <li>使用 <code>attention_dropout</code> 参数为 attention probabilities 使用更高的 dropout ratio。</li>",Es,D,Ys,S,Yt='预训练模型的属性可以在 <a href="/docs/transformers/pr_31098/zh/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a> 函数中进行修改：',Ls,A,Qs,K,Lt='当你对模型配置满意时，可以使用 <a href="/docs/transformers/pr_31098/zh/main_classes/configuration#transformers.PretrainedConfig.save_pretrained">save_pretrained()</a> 来保存配置。你的配置文件将以 JSON 文件的形式存储在指定的保存目录中：',Ps,O,Ns,ss,Qt='要重用配置文件，请使用 <a href="/docs/transformers/pr_31098/zh/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a> 进行加载：',Is,ts,Ds,H,Ss,es,As,ls,Pt='接下来，创建一个<a href="main_classes/models">模型</a>。模型，也可泛指架构，定义了每一层网络的行为以及进行的操作。配置中的 <code>num_hidden_layers</code> 等属性用于定义架构。每个模型都共享基类 <a href="/docs/transformers/pr_31098/zh/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a> 和一些常用方法，例如调整输入嵌入的大小和修剪自注意力头。此外，所有模型都是 <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/api_reference/flax.linen/module.html" rel="nofollow"><code>flax.linen.Module</code></a> 的子类。这意味着模型与各自框架的用法兼容。',Ks,F,Os,ns,st,as,Nt="此时，你已经有了一个输出<em>隐藏状态</em>的基础 DistilBERT 模型。隐藏状态作为输入传递到模型头以生成最终输出。🤗 Transformers 为每个任务提供不同的模型头，只要模型支持该任务（即，您不能使用 DistilBERT 来执行像翻译这样的序列到序列任务）。",tt,X,et,rs,lt,ps,It='在将模型用于文本数据之前，你需要的最后一个基类是 <a href="main_classes/tokenizer">tokenizer</a>，它用于将原始文本转换为张量。🤗 Transformers 支持两种类型的分词器：',nt,is,Dt='<li><a href="/docs/transformers/pr_31098/zh/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>：分词器的Python实现</li> <li><a href="/docs/transformers/pr_31098/zh/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a>：来自我们基于 Rust 的 <a href="https://huggingface.co/docs/tokenizers/python/latest/" rel="nofollow">🤗 Tokenizer</a> 库的分词器。因为其使用了 Rust 实现，这种分词器类型的速度要快得多，尤其是在批量分词（batch tokenization）的时候。快速分词器还提供其他的方法，例如<em>偏移映射（offset mapping）</em>，它将标记（token）映射到其原始单词或字符。</li>',at,os,St="这两种分词器都支持常用的方法，如编码和解码、添加新标记以及管理特殊标记。",rt,B,pt,ms,At="如果您训练了自己的分词器，则可以从<em>词表</em>文件创建一个分词器：",it,cs,ot,fs,Kt="请务必记住，自定义分词器生成的词表与预训练模型分词器生成的词表是不同的。如果使用预训练模型，则需要使用预训练模型的词表，否则输入将没有意义。 使用 <code>DistilBertTokenizer</code> 类创建具有预训练模型词表的分词器：",mt,us,ct,ds,Ot="使用 <code>DistilBertTokenizerFast</code> 类创建快速分词器：",ft,$s,ut,E,dt,gs,$t,hs,se='图像处理器用于处理视觉输入。它继承自 <a href="/docs/transformers/pr_31098/zh/internal/image_processing_utils#transformers.ImageProcessingMixin">ImageProcessingMixin</a> 基类。',gt,ys,te='要使用它，需要创建一个与你使用的模型关联的图像处理器。例如，如果你使用 <a href="model_doc/vit">ViT</a> 进行图像分类，可以创建一个默认的 <code>ViTImageProcessor</code>：',ht,bs,yt,Y,bt,js,ee="修改任何 <code>ViTImageProcessor</code> 参数以创建自定义图像处理器：",jt,_s,_t,Ms,Mt,Ts,le='特征提取器用于处理音频输入。它继承自 <a href="/docs/transformers/pr_31098/zh/main_classes/feature_extractor#transformers.FeatureExtractionMixin">FeatureExtractionMixin</a> 基类，亦可继承 <a href="/docs/transformers/pr_31098/zh/main_classes/feature_extractor#transformers.SequenceFeatureExtractor">SequenceFeatureExtractor</a> 类来处理音频输入。',Tt,vs,ne='要使用它，创建一个与你使用的模型关联的特征提取器。例如，如果你使用 <a href="model_doc/wav2vec2">Wav2Vec2</a> 进行音频分类，可以创建一个默认的 <code>Wav2Vec2FeatureExtractor</code>：',vt,Zs,Zt,L,wt,ws,ae="修改任何 <code>Wav2Vec2FeatureExtractor</code> 参数以创建自定义特征提取器：",qt,qs,Jt,Js,kt,ks,re="对于支持多模式任务的模型，🤗 Transformers 提供了一个处理器类，可以方便地将特征提取器和分词器等处理类包装到单个对象中。例如，让我们使用 <code>Wav2Vec2Processor</code> 来执行自动语音识别任务 (ASR)。 ASR 将音频转录为文本，因此您将需要一个特征提取器和一个分词器。",Rt,Rs,pe="创建一个特征提取器来处理音频输入：",Ct,Cs,Wt,Ws,ie="创建一个分词器来处理文本输入：",Ut,Us,Vt,Vs,oe="将特征提取器和分词器合并到 <code>Wav2Vec2Processor</code> 中：",zt,zs,Gt,Gs,me="通过两个基类 - 配置类和模型类 - 以及一个附加的预处理类（分词器、图像处理器、特征提取器或处理器），你可以创建 🤗 Transformers 支持的任何模型。 每个基类都是可配置的，允许你使用所需的特定属性。 你可以轻松设置模型进行训练或修改现有的预训练模型进行微调。",xt,xs,Ht,Hs,Ft;return _=new Q({props:{title:"创建自定义架构",local:"创建自定义架构",headingTag:"h1"}}),U=new Q({props:{title:"配置",local:"配置",headingTag:"h2"}}),P=new q({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 q({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 q({props:{code:"bXlfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydENvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwYWN0aXZhdGlvbiUzRCUyMnJlbHUlMjIlMkMlMjBhdHRlbnRpb25fZHJvcG91dCUzRDAuNCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = DistilBertConfig.from_pretrained(<span class="hljs-string">&quot;distilbert/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 q({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 q({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}}),H=new Fs({props:{$$slots:{default:[Je]},$$scope:{ctx:w}}}),es=new Q({props:{title:"模型",local:"模型",headingTag:"h2"}}),F=new je({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[We],pytorch:[Re]},$$scope:{ctx:w}}}),ns=new Q({props:{title:"模型头（Model heads）",local:"模型头model-heads",headingTag:"h3"}}),X=new je({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ge],pytorch:[Ve]},$$scope:{ctx:w}}}),rs=new Q({props:{title:"分词器",local:"分词器",headingTag:"h2"}}),B=new Fs({props:{warning:!0,$$slots:{default:[xe]},$$scope:{ctx:w}}}),cs=new q({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}}),us=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRUb2tlbml6ZXIlMEElMEFzbG93X3Rva2VuaXplciUyMCUzRCUyMERpc3RpbEJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),$s=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpc3RpbEJlcnRUb2tlbml6ZXJGYXN0JTBBJTBBZmFzdF90b2tlbml6ZXIlMjAlM0QlMjBEaXN0aWxCZXJ0VG9rZW5pemVyRmFzdC5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),E=new Fs({props:{$$slots:{default:[He]},$$scope:{ctx:w}}}),gs=new Q({props:{title:"图像处理器",local:"图像处理器",headingTag:"h2"}}),bs=new q({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:[Fe]},$$scope:{ctx:w}}}),_s=new q({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"}}),Zs=new q({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:[Xe]},$$scope:{ctx:w}}}),qs=new q({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"}}),Cs=new q({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}}),Us=new q({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}}),zs=new q({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}}),xs=new qe({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/create_a_model.md"}}),{c(){n=f("meta"),c=p(),a=f("p"),o=p(),d(_.$$.fragment),M=p(),W=f("p"),W.innerHTML=k,T=p(),J=f("ul"),J.innerHTML=m,v=p(),d(U.$$.fragment),R=p(),z=f("p"),z.innerHTML=G,C=p(),V=f("p"),V.innerHTML=r,Z=p(),d(P.$$.fragment),Xs=p(),N=f("p"),N.innerHTML=Bt,Bs=p(),I=f("ul"),I.innerHTML=Et,Es=p(),d(D.$$.fragment),Ys=p(),S=f("p"),S.innerHTML=Yt,Ls=p(),d(A.$$.fragment),Qs=p(),K=f("p"),K.innerHTML=Lt,Ps=p(),d(O.$$.fragment),Ns=p(),ss=f("p"),ss.innerHTML=Qt,Is=p(),d(ts.$$.fragment),Ds=p(),d(H.$$.fragment),Ss=p(),d(es.$$.fragment),As=p(),ls=f("p"),ls.innerHTML=Pt,Ks=p(),d(F.$$.fragment),Os=p(),d(ns.$$.fragment),st=p(),as=f("p"),as.innerHTML=Nt,tt=p(),d(X.$$.fragment),et=p(),d(rs.$$.fragment),lt=p(),ps=f("p"),ps.innerHTML=It,nt=p(),is=f("ul"),is.innerHTML=Dt,at=p(),os=f("p"),os.textContent=St,rt=p(),d(B.$$.fragment),pt=p(),ms=f("p"),ms.innerHTML=At,it=p(),d(cs.$$.fragment),ot=p(),fs=f("p"),fs.innerHTML=Kt,mt=p(),d(us.$$.fragment),ct=p(),ds=f("p"),ds.innerHTML=Ot,ft=p(),d($s.$$.fragment),ut=p(),d(E.$$.fragment),dt=p(),d(gs.$$.fragment),$t=p(),hs=f("p"),hs.innerHTML=se,gt=p(),ys=f("p"),ys.innerHTML=te,ht=p(),d(bs.$$.fragment),yt=p(),d(Y.$$.fragment),bt=p(),js=f("p"),js.innerHTML=ee,jt=p(),d(_s.$$.fragment),_t=p(),d(Ms.$$.fragment),Mt=p(),Ts=f("p"),Ts.innerHTML=le,Tt=p(),vs=f("p"),vs.innerHTML=ne,vt=p(),d(Zs.$$.fragment),Zt=p(),d(L.$$.fragment),wt=p(),ws=f("p"),ws.innerHTML=ae,qt=p(),d(qs.$$.fragment),Jt=p(),d(Js.$$.fragment),kt=p(),ks=f("p"),ks.innerHTML=re,Rt=p(),Rs=f("p"),Rs.textContent=pe,Ct=p(),d(Cs.$$.fragment),Wt=p(),Ws=f("p"),Ws.textContent=ie,Ut=p(),d(Us.$$.fragment),Vt=p(),Vs=f("p"),Vs.innerHTML=oe,zt=p(),d(zs.$$.fragment),Gt=p(),Gs=f("p"),Gs.textContent=me,xt=p(),d(xs.$$.fragment),Ht=p(),Hs=f("p"),this.h()},l(s){const t=Ze("svelte-u9bgzb",document.head);n=u(t,"META",{name:!0,content:!0}),t.forEach(e),c=i(s),a=u(s,"P",{}),ye(a).forEach(e),o=i(s),$(_.$$.fragment,s),M=i(s),W=u(s,"P",{"data-svelte-h":!0}),j(W)!=="svelte-163eq9z"&&(W.innerHTML=k),T=i(s),J=u(s,"UL",{"data-svelte-h":!0}),j(J)!=="svelte-1asek4b"&&(J.innerHTML=m),v=i(s),$(U.$$.fragment,s),R=i(s),z=u(s,"P",{"data-svelte-h":!0}),j(z)!=="svelte-1nly6ic"&&(z.innerHTML=G),C=i(s),V=u(s,"P",{"data-svelte-h":!0}),j(V)!=="svelte-1akqh2h"&&(V.innerHTML=r),Z=i(s),$(P.$$.fragment,s),Xs=i(s),N=u(s,"P",{"data-svelte-h":!0}),j(N)!=="svelte-14v2kvo"&&(N.innerHTML=Bt),Bs=i(s),I=u(s,"UL",{"data-svelte-h":!0}),j(I)!=="svelte-13r6eur"&&(I.innerHTML=Et),Es=i(s),$(D.$$.fragment,s),Ys=i(s),S=u(s,"P",{"data-svelte-h":!0}),j(S)!=="svelte-y9wsln"&&(S.innerHTML=Yt),Ls=i(s),$(A.$$.fragment,s),Qs=i(s),K=u(s,"P",{"data-svelte-h":!0}),j(K)!=="svelte-1kmeiym"&&(K.innerHTML=Lt),Ps=i(s),$(O.$$.fragment,s),Ns=i(s),ss=u(s,"P",{"data-svelte-h":!0}),j(ss)!=="svelte-1x95j2q"&&(ss.innerHTML=Qt),Is=i(s),$(ts.$$.fragment,s),Ds=i(s),$(H.$$.fragment,s),Ss=i(s),$(es.$$.fragment,s),As=i(s),ls=u(s,"P",{"data-svelte-h":!0}),j(ls)!=="svelte-7s1eex"&&(ls.innerHTML=Pt),Ks=i(s),$(F.$$.fragment,s),Os=i(s),$(ns.$$.fragment,s),st=i(s),as=u(s,"P",{"data-svelte-h":!0}),j(as)!=="svelte-qcf0a1"&&(as.innerHTML=Nt),tt=i(s),$(X.$$.fragment,s),et=i(s),$(rs.$$.fragment,s),lt=i(s),ps=u(s,"P",{"data-svelte-h":!0}),j(ps)!=="svelte-espr00"&&(ps.innerHTML=It),nt=i(s),is=u(s,"UL",{"data-svelte-h":!0}),j(is)!=="svelte-1ewiab6"&&(is.innerHTML=Dt),at=i(s),os=u(s,"P",{"data-svelte-h":!0}),j(os)!=="svelte-51pwdw"&&(os.textContent=St),rt=i(s),$(B.$$.fragment,s),pt=i(s),ms=u(s,"P",{"data-svelte-h":!0}),j(ms)!=="svelte-1f3jbei"&&(ms.innerHTML=At),it=i(s),$(cs.$$.fragment,s),ot=i(s),fs=u(s,"P",{"data-svelte-h":!0}),j(fs)!=="svelte-15lam1s"&&(fs.innerHTML=Kt),mt=i(s),$(us.$$.fragment,s),ct=i(s),ds=u(s,"P",{"data-svelte-h":!0}),j(ds)!=="svelte-bg238o"&&(ds.innerHTML=Ot),ft=i(s),$($s.$$.fragment,s),ut=i(s),$(E.$$.fragment,s),dt=i(s),$(gs.$$.fragment,s),$t=i(s),hs=u(s,"P",{"data-svelte-h":!0}),j(hs)!=="svelte-1y1x0e7"&&(hs.innerHTML=se),gt=i(s),ys=u(s,"P",{"data-svelte-h":!0}),j(ys)!=="svelte-1evm4el"&&(ys.innerHTML=te),ht=i(s),$(bs.$$.fragment,s),yt=i(s),$(Y.$$.fragment,s),bt=i(s),js=u(s,"P",{"data-svelte-h":!0}),j(js)!=="svelte-y6n2fo"&&(js.innerHTML=ee),jt=i(s),$(_s.$$.fragment,s),_t=i(s),$(Ms.$$.fragment,s),Mt=i(s),Ts=u(s,"P",{"data-svelte-h":!0}),j(Ts)!=="svelte-1k3rzy5"&&(Ts.innerHTML=le),Tt=i(s),vs=u(s,"P",{"data-svelte-h":!0}),j(vs)!=="svelte-o65i7e"&&(vs.innerHTML=ne),vt=i(s),$(Zs.$$.fragment,s),Zt=i(s),$(L.$$.fragment,s),wt=i(s),ws=u(s,"P",{"data-svelte-h":!0}),j(ws)!=="svelte-wsqmub"&&(ws.innerHTML=ae),qt=i(s),$(qs.$$.fragment,s),Jt=i(s),$(Js.$$.fragment,s),kt=i(s),ks=u(s,"P",{"data-svelte-h":!0}),j(ks)!=="svelte-gboqg0"&&(ks.innerHTML=re),Rt=i(s),Rs=u(s,"P",{"data-svelte-h":!0}),j(Rs)!=="svelte-liph8s"&&(Rs.textContent=pe),Ct=i(s),$(Cs.$$.fragment,s),Wt=i(s),Ws=u(s,"P",{"data-svelte-h":!0}),j(Ws)!=="svelte-v0jq8i"&&(Ws.textContent=ie),Ut=i(s),$(Us.$$.fragment,s),Vt=i(s),Vs=u(s,"P",{"data-svelte-h":!0}),j(Vs)!=="svelte-1pme727"&&(Vs.innerHTML=oe),zt=i(s),$(zs.$$.fragment,s),Gt=i(s),Gs=u(s,"P",{"data-svelte-h":!0}),j(Gs)!=="svelte-11qtpiq"&&(Gs.textContent=me),xt=i(s),$(xs.$$.fragment,s),Ht=i(s),Hs=u(s,"P",{}),ye(Hs).forEach(e),this.h()},h(){be(n,"name","hf:doc:metadata"),be(n,"content",Ee)},m(s,t){we(document.head,n),l(s,c,t),l(s,a,t),l(s,o,t),g(_,s,t),l(s,M,t),l(s,W,t),l(s,T,t),l(s,J,t),l(s,v,t),g(U,s,t),l(s,R,t),l(s,z,t),l(s,C,t),l(s,V,t),l(s,Z,t),g(P,s,t),l(s,Xs,t),l(s,N,t),l(s,Bs,t),l(s,I,t),l(s,Es,t),g(D,s,t),l(s,Ys,t),l(s,S,t),l(s,Ls,t),g(A,s,t),l(s,Qs,t),l(s,K,t),l(s,Ps,t),g(O,s,t),l(s,Ns,t),l(s,ss,t),l(s,Is,t),g(ts,s,t),l(s,Ds,t),g(H,s,t),l(s,Ss,t),g(es,s,t),l(s,As,t),l(s,ls,t),l(s,Ks,t),g(F,s,t),l(s,Os,t),g(ns,s,t),l(s,st,t),l(s,as,t),l(s,tt,t),g(X,s,t),l(s,et,t),g(rs,s,t),l(s,lt,t),l(s,ps,t),l(s,nt,t),l(s,is,t),l(s,at,t),l(s,os,t),l(s,rt,t),g(B,s,t),l(s,pt,t),l(s,ms,t),l(s,it,t),g(cs,s,t),l(s,ot,t),l(s,fs,t),l(s,mt,t),g(us,s,t),l(s,ct,t),l(s,ds,t),l(s,ft,t),g($s,s,t),l(s,ut,t),g(E,s,t),l(s,dt,t),g(gs,s,t),l(s,$t,t),l(s,hs,t),l(s,gt,t),l(s,ys,t),l(s,ht,t),g(bs,s,t),l(s,yt,t),g(Y,s,t),l(s,bt,t),l(s,js,t),l(s,jt,t),g(_s,s,t),l(s,_t,t),g(Ms,s,t),l(s,Mt,t),l(s,Ts,t),l(s,Tt,t),l(s,vs,t),l(s,vt,t),g(Zs,s,t),l(s,Zt,t),g(L,s,t),l(s,wt,t),l(s,ws,t),l(s,qt,t),g(qs,s,t),l(s,Jt,t),g(Js,s,t),l(s,kt,t),l(s,ks,t),l(s,Rt,t),l(s,Rs,t),l(s,Ct,t),g(Cs,s,t),l(s,Wt,t),l(s,Ws,t),l(s,Ut,t),g(Us,s,t),l(s,Vt,t),l(s,Vs,t),l(s,zt,t),g(zs,s,t),l(s,Gt,t),l(s,Gs,t),l(s,xt,t),g(xs,s,t),l(s,Ht,t),l(s,Hs,t),Ft=!0},p(s,[t]){const ce={};t&2&&(ce.$$scope={dirty:t,ctx:s}),H.$set(ce);const fe={};t&2&&(fe.$$scope={dirty:t,ctx:s}),F.$set(fe);const ue={};t&2&&(ue.$$scope={dirty:t,ctx:s}),X.$set(ue);const de={};t&2&&(de.$$scope={dirty:t,ctx:s}),B.$set(de);const $e={};t&2&&($e.$$scope={dirty:t,ctx:s}),E.$set($e);const ge={};t&2&&(ge.$$scope={dirty:t,ctx:s}),Y.$set(ge);const he={};t&2&&(he.$$scope={dirty:t,ctx:s}),L.$set(he)},i(s){Ft||(h(_.$$.fragment,s),h(U.$$.fragment,s),h(P.$$.fragment,s),h(D.$$.fragment,s),h(A.$$.fragment,s),h(O.$$.fragment,s),h(ts.$$.fragment,s),h(H.$$.fragment,s),h(es.$$.fragment,s),h(F.$$.fragment,s),h(ns.$$.fragment,s),h(X.$$.fragment,s),h(rs.$$.fragment,s),h(B.$$.fragment,s),h(cs.$$.fragment,s),h(us.$$.fragment,s),h($s.$$.fragment,s),h(E.$$.fragment,s),h(gs.$$.fragment,s),h(bs.$$.fragment,s),h(Y.$$.fragment,s),h(_s.$$.fragment,s),h(Ms.$$.fragment,s),h(Zs.$$.fragment,s),h(L.$$.fragment,s),h(qs.$$.fragment,s),h(Js.$$.fragment,s),h(Cs.$$.fragment,s),h(Us.$$.fragment,s),h(zs.$$.fragment,s),h(xs.$$.fragment,s),Ft=!0)},o(s){y(_.$$.fragment,s),y(U.$$.fragment,s),y(P.$$.fragment,s),y(D.$$.fragment,s),y(A.$$.fragment,s),y(O.$$.fragment,s),y(ts.$$.fragment,s),y(H.$$.fragment,s),y(es.$$.fragment,s),y(F.$$.fragment,s),y(ns.$$.fragment,s),y(X.$$.fragment,s),y(rs.$$.fragment,s),y(B.$$.fragment,s),y(cs.$$.fragment,s),y(us.$$.fragment,s),y($s.$$.fragment,s),y(E.$$.fragment,s),y(gs.$$.fragment,s),y(bs.$$.fragment,s),y(Y.$$.fragment,s),y(_s.$$.fragment,s),y(Ms.$$.fragment,s),y(Zs.$$.fragment,s),y(L.$$.fragment,s),y(qs.$$.fragment,s),y(Js.$$.fragment,s),y(Cs.$$.fragment,s),y(Us.$$.fragment,s),y(zs.$$.fragment,s),y(xs.$$.fragment,s),Ft=!1},d(s){s&&(e(c),e(a),e(o),e(M),e(W),e(T),e(J),e(v),e(R),e(z),e(C),e(V),e(Z),e(Xs),e(N),e(Bs),e(I),e(Es),e(Ys),e(S),e(Ls),e(Qs),e(K),e(Ps),e(Ns),e(ss),e(Is),e(Ds),e(Ss),e(As),e(ls),e(Ks),e(Os),e(st),e(as),e(tt),e(et),e(lt),e(ps),e(nt),e(is),e(at),e(os),e(rt),e(pt),e(ms),e(it),e(ot),e(fs),e(mt),e(ct),e(ds),e(ft),e(ut),e(dt),e($t),e(hs),e(gt),e(ys),e(ht),e(yt),e(bt),e(js),e(jt),e(_t),e(Mt),e(Ts),e(Tt),e(vs),e(vt),e(Zt),e(wt),e(ws),e(qt),e(Jt),e(kt),e(ks),e(Rt),e(Rs),e(Ct),e(Wt),e(Ws),e(Ut),e(Vt),e(Vs),e(zt),e(Gt),e(Gs),e(xt),e(Ht),e(Hs)),e(n),b(_,s),b(U,s),b(P,s),b(D,s),b(A,s),b(O,s),b(ts,s),b(H,s),b(es,s),b(F,s),b(ns,s),b(X,s),b(rs,s),b(B,s),b(cs,s),b(us,s),b($s,s),b(E,s),b(gs,s),b(bs,s),b(Y,s),b(_s,s),b(Ms,s),b(Zs,s),b(L,s),b(qs,s),b(Js,s),b(Cs,s),b(Us,s),b(zs,s),b(xs,s)}}}const Ee='{"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 Ye(w){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Se extends Te{constructor(n){super(),ve(this,n,Ye,Be,_e,{})}}export{Se as component};
