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