import{s as ta,o as sa}from"../chunks/scheduler.cd324960.js";import{S as na,i as aa,e as p,s as n,c as U,h as pa,a as M,d as t,b as a,f as Ln,g as T,j as i,k as Pn,l as Ma,m as s,n as y,t as c,o as r,p as m,q as la,r as ea}from"../chunks/index.d5c3adcc.js";import{T as Kn}from"../chunks/Tip.889bec11.js";import{C as ia,H as u,E as Ua}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.87c38818.js";import{C as o}from"../chunks/CodeBlock.2ff0aef1.js";function Ta(Qe){let J;return{c(){J=la('您可以将语言标识符从 `"dv"` 更改为您选择的语言标识符。要查看 Common Voice 13 中所有可选的语言，\n    请查看 Hugging Face Hub 上的数据集卡片：https://huggingface.co/datasets/mozilla-foundation/common_voice_13_0')},l(j){J=ea(j,'您可以将语言标识符从 `"dv"` 更改为您选择的语言标识符。要查看 Common Voice 13 中所有可选的语言，\n    请查看 Hugging Face Hub 上的数据集卡片：https://huggingface.co/datasets/mozilla-foundation/common_voice_13_0')},m(j,C){s(j,J,C)},d(j){j&&t(J)}}}function ya(Qe){let J;return{c(){J=la("如果您不想将模型检查点上传到 Hub，请设置 `push_to_hub=False`。")},l(j){J=ea(j,"如果您不想将模型检查点上传到 Hub，请设置 `push_to_hub=False`。")},m(j,C){s(j,J,C)},d(j){j&&t(J)}}}function ca(Qe){let J,j,C,ge,h,Ve,f,Ie,b,Ws=`在本节中，我们将手把手指导如何在 Common Voice 13 数据集上微调 Whisper 以进行语音识别。
我们将使用模型的“small”版本和一个相对轻量级的数据集，使您能够在任何 16GB 以上的 GPU 上用少量磁盘空间相对快速地微调，
例如 Google Colab 免费提供的 16GB T4 GPU。`,_e,Q,Es=`如果您的 GPU 太小，或在训练过程中遇到内存问题，可以遵循我们之后提供的建议来减少内存使用量。
相反，如果您可以访问更大的 GPU，您可以修改训练参数以最大化您的吞吐量。因此，无论您的 GPU 规格如何，都可以参考本指南！`,$e,R,Fs=`同样，本指南简要介绍了如何针对迪维希语微调 Whisper 模型。然而，这里介绍的步骤可以推广到 Common Voice 数据集中的任何语言，
更一般地，可以推广到 Hugging Face Hub 上的任何 ASR 数据集。您可以更改代码以快速切换到您选择的语言，并在您的母语上微调 Whisper 模型 🌍`,Ne,g,vs="好了，废话少说，让我们开始我们的微调流程吧！",ke,V,We,I,Bs='我们强烈建议您在训练时直接将模型检查点上传至 <a href="https://huggingface.co/" rel="nofollow">Hugging Face Hub</a>。Hub 提供：',Ee,_,As="<li>集成的版本控制：您可以确保训练过程中不会丢失任何模型检查点。</li> <li>Tensorboard 日志：跟踪训练过程中的重要指标。</li> <li>模型卡片：记录模型的功能及其预期用例。</li> <li>社区：与社区共享和协作的简便方式！🤗</li>",Fe,$,xs='将 notebook 链接到 Hub 非常简单——只需要输入您的 Hub 认证令牌。在 <a href="https://huggingface.co/settings/tokens" rel="nofollow">这里</a> 找到您的 Hub 认证令牌并根据提示输入它：',ve,N,Be,k,Zs="<strong>输出：</strong>",Ae,W,xe,E,Ze,F,Gs=`<a href="https://huggingface.co/datasets/mozilla-foundation/common_voice_13_0" rel="nofollow">Common Voice 13</a> 包含大约十小时的标注过的迪维希语数据，
这对于微调来说是极少量的数据，因此我们将依赖在预训练期间 Whisper 获得的广泛的多语言 ASR 知识来弥补迪维希语的低资源量。`,Ge,v,Ss=`使用 🤗 Datasets 下载和准备数据非常简单。我们可以用一行代码下载并准备好 Common Voice 13 的数据。由于迪维希语资源非常少，
我们将结合 <code>train</code> 和 <code>validation</code> 子集，提供大约七小时的训练数据，并使用三小时的 <code>test</code> 数据作为我们保留的测试集：`,Se,B,Ye,A,Ys="<strong>输出：</strong>",Xe,x,He,d,Oe,Z,Xs=`大多数 ASR 数据集只提供输入音频样本（<code>audio</code>）和相应的转写文本（<code>sentence</code>）。Common Voice 包含额外的元数据，如 <code>accent</code> 和 <code>locale</code>，
我们做 ASR 时可以忽略这些信息。为了让代码尽可能通用，我们只用输入音频和转写文本来进行微调，丢弃额外的元数据信息：`,ze,G,qe,S,De,Y,Hs="ASR 流程可以分解为三个阶段：",Le,X,Os="<li>特征提取器将原始音频输入预处理为 log-mel 频谱图</li> <li>模型执行序列到序列的映射</li> <li>分词器将预测的词元后处理为文本</li>",Pe,H,zs=`在 🤗 Transformers 中，Whisper 模型有一个关联的特征提取器和分词器，分别称为 <a href="https://huggingface.co/docs/transformers/main/model_doc/whisper#transformers.WhisperFeatureExtractor" rel="nofollow">WhisperFeatureExtractor</a> 和 <a href="https://huggingface.co/docs/transformers/main/model_doc/whisper#transformers.WhisperTokenizer" rel="nofollow">WhisperTokenizer</a>。
为了简化我们的工作，这两个类的对象又可以被封装在一个类中，称为 <a href="https://huggingface.co/docs/transformers/model_doc/whisper#transformers.WhisperProcessor" rel="nofollow">WhisperProcessor</a>。
我们可以调用 WhisperProcessor 来执行音频预处理和文本词元后处理。这样我们在训练期间只需要跟踪两个对象：处理器和模型。`,Ke,O,qs=`当执行多语言微调时，我们需要在实例化处理器时设置 <code>&quot;language&quot;</code> 和 <code>&quot;task&quot;</code>。<code>&quot;language&quot;</code> 应设置为源音频语言，
任务设置为 <code>&quot;transcribe&quot;</code> 以进行语音识别或 <code>&quot;translate&quot;</code> 以进行语音翻译。这些参数会影响分词器的行为，应正确设置以确保目标标签被正确编码。`,lt,z,Ds="我们可以通过导入语言列表来查看 Whisper 支持的所有可能语言：",et,q,tt,D,Ls=`如果您浏览此列表，您会注意到许多语言都存在，但迪维希语是少数不存在的之一！这意味着 Whisper 没有在迪维希语上进行预训练。
然而，这并不意味着我们不能在其上微调 Whisper。这样做，我们将教会 Whisper 一种新的语言，一种预训练检查点不支持的语言。这很酷，对吧！`,st,L,Ps=`当您在一种新语言上微调时，Whisper 可以利用它在其他 96 种语言上的预训练知识。总的来说，所有现代语言在语言学上至少与 Whisper 已经
知道的 96 种语言中的一种类似，所以我们可以利用起这种跨语言的知识。`,nt,P,Ks=`我们需要做的是找到 Whisper 在预训练期间学习过<strong>最相似</strong>的语言。维基百科的迪维希语词条指出，迪维希语与斯里兰卡的僧伽罗语密切相关。
如果我们再次检查语言代码，我们可以看到僧伽罗语存在于 Whisper 语言集中，因此我们可以安全地将我们的语言参数设置为 <code>&quot;sinhalese&quot;</code>。`,at,K,ln="好！我们将从预训练检查点加载我们的处理器，将语言设置为 <code>&quot;sinhalese&quot;</code>，任务设置为 <code>&quot;transcribe&quot;</code>，如上所述：",pt,ll,Mt,el,en=`值得重申的是，在大多数情况下，您会发现您想要微调的语言在预训练语言集中，这种情况下，您可以直接将语言设置为您的源音频语言！
请注意，对于仅英语的微调，这两个参数应省略，这种情况下语言（<code>&quot;English&quot;</code>）和任务（<code>&quot;transcribe&quot;</code>）都是唯一默认的选项。`,it,tl,Ut,sl,tn="让我们看看数据集特征。特别注意 <code>&quot;audio&quot;</code> 列——这详细说明了我们输入音频的采样率：",Tt,nl,yt,al,sn="<strong>输出：</strong>",ct,pl,rt,Ml,nn="由于我们的输入音频采样率为 48kHz，我们需要在将其传递给 Whisper 特征提取器之前将其 <em>下采样</em> 到 16kHz，16kHz 是 Whisper 模型期望的采样率。",mt,il,an=`我们将使用数据集的 <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.cast_column" rel="nofollow"><code>cast_column</code></a> 方法
将音频输入设置为正确的采样率。此操作不会就地更改音频，而是指示数据集在加载音频样本时即时地重采样：`,ot,Ul,Jt,Tl,pn="现在我们可以编写一个函数来准备我们的数据以供模型使用：",jt,yl,Mn="<li>调用 <code>sample[&quot;audio&quot;]</code> 在逐个样本上加载和重采样音频数据。如上所述，🤗 Datasets 在加载时即时执行任何必要的重采样操作。</li> <li>用特征提取器从我们的一维音频数组计算 log-mel 频谱图输入特征。</li> <li>用分词器将转写文本编码为标签 id。</li>",ut,cl,Ct,rl,Un=`我们可以使用 🤗 Datasets 的 <code>.map</code> 方法将数据预处理函数应用于我们所有的训练样本。
我们将从原始训练数据中移除原有的列（音频和文本），只留下 <code>prepare_dataset</code> 函数返回的列：`,dt,ml,wt,ol,Tn=`最后，我们定义一个函数来过滤掉音频样本长度超过 30s 的训练数据。这些样本否则会被 Whisper 特征提取器截断，这可能影响训练的稳定性。
我们定义一个函数，对于小于 30s 的样本返回 <code>True</code>，对于更长的样本返回 <code>False</code>：`,ht,Jl,ft,jl,yn="我们通过 🤗 Datasets 的 <code>.filter</code> 方法将我们的过滤函数应用于我们的训练数据集的所有样本：",bt,ul,Qt,Cl,cn="让我们检查一下通过这个过滤步骤我们移除了多少训练数据：",Rt,dl,gt,wl,rn="<strong>输出：</strong>",Vt,hl,It,fl,mn=`好的！在过滤前后我们有相同数量的样本，所以原数据集中没有超过 30s 的样本。如果您切换语言，情况可能不同，因此为了稳健性最好保留这个过滤步骤。
有了这些，我们的数据已经完全准备好进行训练了！让我们继续看看如何使用这些数据来微调 Whisper。`,_t,bl,$t,Ql,on=`现在我们已经准备好了我们的数据，我们准备好深入训练流程了。
<a href="https://huggingface.co/transformers/master/main_classes/trainer.html?highlight=trainer" rel="nofollow">🤗 Trainer</a> 将为我们完成大部分繁重的工作。我们所要做的就是：`,Nt,Rl,Jn="<li>定义一个数据整理器：数据整理器接受我们预处理的数据并准备好 PyTorch 张量以供模型使用。</li> <li>评估指标：我们希望使用词错误率（WER）指标来评估模型，需要定义一个处理这种计算的 <code>compute_metrics</code> 函数。</li> <li>加载预训练检查点：我们需要加载一个预训练检查点并为训练正确配置它。</li> <li>定义训练参数：这将被 🤗 Trainer 用来构建训练计划。</li>",kt,gl,jn="一旦我们完成了模型的微调，我们将在测试数据上评估它，以验证我们是否正确地训练了它转写迪维希语语音。",Wt,Vl,Et,Il,un="序列到序列语音模型的数据整理器很独特，它能独立地处理 <code>input_features</code> 和 <code>labels</code>：<code>input_features</code> 必须由特征提取器处理，而 <code>labels</code> 由分词器处理。",Ft,_l,Cn=`<code>input_features</code> 已经填充到 30s 并转换为固定维度的 log-Mel 频谱图，所以我们所要做的就是使用特征提取器的 <code>.pad</code> 方法，
并设置参数 <code>return_tensors=pt</code>，将它们转换为批量的 PyTorch 张量。请注意，这里没有应用额外的填充，因为输入是固定维度的，
<code>input_features</code> 仅被转换为 PyTorch 张量。`,vt,$l,dn=`另一方面，<code>labels</code> 是未填充的。我们首先使用分词器的 <code>.pad</code> 方法将序列填充到批次中的最大长度。然后用 <code>-100</code> 替换填充词元，
以便在计算损失函数时<strong>不</strong>考虑这些词元。我们还要去掉标签序列开头的转写起始（start of transcript）词元，因为我们稍后在训练期间会添加它。`,Bt,Nl,wn="我们可以利用我们之前定义的 <code>WhisperProcessor</code> 来执行特征提取器和分词器操作：",At,kl,xt,Wl,hn="我们现在可以初始化我们刚刚定义的数据整理器：",Zt,El,Gt,Fl,fn="继续！",St,vl,Yt,Bl,bn='接下来，我们定义我们在测试集上将使用的评估指标。我们将使用 <a href="evaluation">评价指标</a> 章节中介绍的词错误率（WER）指标，这是评估 ASR 系统的“事实上”的指标。',Xt,Al,Qn="我们从 🤗 Evaluate 加载 WER 指标：",Ht,xl,Ot,Zl,Rn=`然后我们只需定义一个函数，它接受我们模型的预测并返回 WER 指标。这个函数称为 <code>compute_metrics</code>，首先用 <code>pad_token_id</code> 替换 <code>label_ids</code> 中的 <code>-100</code>
（撤销我们在数据整理器中为了在损失函数中正确忽略填充词元做的步骤）。然后，它将预测的标签 id 解码为字符串。最后，它计算预测结果和参考标签之间的 WER。
在这里，我们可以选择评估“标准化”的转录和预测，这些转录和预测都移除了标点和大小写。我们建议您遵循这个步骤，通过标准化转录改进 WER。`,zt,Gl,qt,Sl,Dt,Yl,gn="现在让我们加载预训练的 Whisper small 检查点。用 🤗 Transformers 这是小菜一碟！",Lt,Xl,Pt,Hl,Vn=`我们将 <code>use_cache</code> 设置为 <code>False</code> 以进行训练，因为我们正在使用 <a href="https://huggingface.co/docs/transformers/v4.18.0/en/performance#gradient-checkpointing" rel="nofollow">梯度检查点</a>，
两者不兼容。我们还将覆盖两个生成参数以控制模型在推理期间的行为：我们将通过设置 <code>language</code> 和 <code>task</code> 参数在生成期间强制规定语言和任务标签，
并重新启用缓存以加速推理：`,Kt,Ol,ls,zl,es,ql,In=`在最后一步，我们定义了所有与训练相关的参数。在这里，我们将训练步骤数设置为 500。这足以看到与预训练 Whisper 模型相比 WER 大幅提升，
同时确保微调可以在大约 45 分钟内在 Google Colab 免费版上运行完。有关训练参数的更多详情，请参阅 Seq2SeqTrainingArguments <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.Seq2SeqTrainingArguments" rel="nofollow">文档</a>。`,ts,Dl,ss,w,ns,Ll,_n="我们可以将训练参数传递给 🤗 Trainer，连同我们的模型、数据集、数据整理器和 <code>compute_metrics</code> 函数一起：",as,Pl,ps,Kl,$n="有了这个，我们就准备好开始训练了！",Ms,le,is,ee,Nn="要启动训练，只需执行：",Us,te,Ts,se,kn=`训练大约需要 45 分钟，取决于您的 GPU 或 Google Colab 给分配的 GPU 。由于 GPU 不同，当您开始训练时，可能会遇到 CUDA <code>&quot;out-of-memory&quot;</code> 错误。
在这种情况下，您可以两倍两倍地逐渐减少 <code>per_device_train_batch_size</code> 并使用 <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.Seq2SeqTrainingArguments.gradient_accumulation_steps" rel="nofollow"><code>gradient_accumulation_steps</code></a> 来补偿。`,ys,ne,Wn="<strong>输出：</strong>",cs,ae,En='<thead><tr><th align="center">Training Loss</th> <th align="center">Epoch</th> <th align="center">Step</th> <th align="center">Validation Loss</th> <th align="center">Wer Ortho</th> <th align="center">Wer</th></tr></thead> <tbody><tr><td align="center">0.136</td> <td align="center">1.63</td> <td align="center">500</td> <td align="center">0.1727</td> <td align="center">63.8972</td> <td align="center">14.0661</td></tr></tbody>',rs,pe,Fn=`我们最终的 WER 是 14.1%——对于七小时的训练数据和仅 500 训练步骤来说不错，这相当于与预训练模型相比提高了 112%！
这意味着我们已经将一个之前不了解迪维希语的模型微调为在不到一小时内以足够的准确性识别迪维希语语音 🤯`,ms,Me,vn=`最重要的是，这与其他 ASR 系统相比如何。为此，我们可以查看 autoevaluate <a href="https://huggingface.co/spaces/autoevaluate/leaderboards?dataset=mozilla-foundation%2Fcommon_voice_13_0&amp;only_verified=0&amp;task=automatic-speech-recognition&amp;config=dv&amp;split=test&amp;metric=wer" rel="nofollow">排行榜</a>，
一个根据语言和数据集分类模型并根据它们的 WER 排名的排行榜。`,os,ie,Bn='查看排行榜，我们看到我们训练了 500 步的模型令人信服地击败了我们在前一节评估的预训练 <a href="https://huggingface.co/openai/whisper-small" rel="nofollow">Whisper Small</a> 检查点。干得好 👏',Js,Ue,An=`我们看到有一些检查点比我们训练的表现更好。Hugging Face Hub 的美妙之处在于它是一个<em>协作</em>平台——如果我们没有时间或资源自己进行更长时间的训练运行，
我们可以加载社区中其他人已经训练并慷慨分享的检查点（记得对他们心怀感谢！）。您将能够以与预训练检查点相同的方式使用 <code>pipeline</code> 类加载这些检查点，
正如我们之前所做的！所以没有什么能阻止您挑选排行榜上最佳模型来用于您的任务！`,js,Te,xn="我们可以在将训练结果推送到 Hub 时自动将我们的检查点提交到排行榜——我们只需设置适当的关键字参数 (kwargs)。您可以根据您的数据集、语言和模型名称相应地更改这些值：",us,ye,Cs,ce,Zn="现在可以将训练结果上传到 Hub，请执行 <code>push_to_hub</code> 命令：",ds,re,ws,me,Gn="这将在 <code>&quot;您的用户名/您给模型起的名字&quot;</code> 下保存训练日志和模型权重。作为示例，请查看 <code>sanchit-gandhi/whisper-small-dv</code> 上的上传文件。",hs,oe,Sn="虽然在 Common Voice 13 迪维希语测试数据上微调的模型提供了令人满意的结果，但这绝非最佳。本指南的目的是演示如何使用 🤗 Trainer 微调 ASR 模型以进行多语言语音识别。",fs,Je,Yn=`如果您有自己的 GPU 或订阅了 Google Colab 付费计划，您可以将 <code>max_steps</code> 增加到 4000 步，通过更多步骤的训练进一步降低大约 3% 的 WER。
如果您决定进行 4000 步的训练，我们还建议将学习率调度器更改为<em>线性</em>计划（设置 <code>lr_scheduler_type=&quot;linear&quot;</code>），因为这将在长时间的训练中提升更多性能。`,bs,je,Xn="通过优化训练超参数，如 <em>学习率</em> 和 <em>dropout</em>，并使用更大的预训练检查点（<code>medium</code> 或 <code>large</code>），可能进一步改善结果。我们将这留作读者的练习。",Qs,ue,Rs,Ce,Hn=`您现在可以使用 Hub 上的链接与任何人共享此模型。大家可以直接将标识符 <code>&quot;您的用户名/您给模型起的名字&quot;</code> 加载到 <code>pipeline()</code> 对象中。
例如，要加载微调的检查点 <a href="https://huggingface.co/sanchit-gandhi/whisper-small-dv" rel="nofollow">“sanchit-gandhi/whisper-small-dv”</a>：`,gs,de,Vs,we,Is,he,On=`在本节中，我们逐步介绍了如何使用 🤗 Datasets、Transformers 和 Hugging Face Hub 微调 Whisper 模型以进行语音识别。
我们首先加载了 Common Voice 13 数据集的迪维希语子集，并通过计算 log-mel 频谱图和分词文本对其进行了预处理。然后我们定义了数据整理器、评估指标和训练参数，
使用 🤗 Trainer 来训练和评估我们的模型。我们将微调的模型上传到 Hugging Face Hub，并展示了如何使用 <code>pipeline()</code> 类共享和使用它。`,_s,fe,zn=`如果您一直学到了这里，您现在应该有了一个用于语音识别的微调检查点，干得好！🥳 更重要的是，您现在掌握了所有必要的工具，可以在任何语音识别数据集或领域上微调 Whisper 模型。
那么，您还在等什么呢！从 <a href="choosing_dataset">选择数据集</a> 章节中介绍的数据集里挑一个，或选择您自己的数据集，看看您是否可以获得 SOTA！排行榜在等着您……`,$s,be,Ns,Re,ks;return h=new ia({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new u({props:{title:"微调语音识别模型",local:"微调语音识别模型",headingTag:"h1"}}),V=new u({props:{title:"配置环境",local:"配置环境",headingTag:"h2"}}),N=new o({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`,wrap:!1}}),W=new o({props:{code:"TG9naW4lMjBzdWNjZXNzZnVsJTBBWW91ciUyMHRva2VuJTIwaGFzJTIwYmVlbiUyMHNhdmVkJTIwdG8lMjAlMkZyb290JTJGLmh1Z2dpbmdmYWNlJTJGdG9rZW4=",highlighted:`Login successful
Your token has been saved to /root/.huggingface/token`,wrap:!1}}),E=new u({props:{title:"加载数据集",local:"加载数据集",headingTag:"h2"}}),B=new o({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwRGF0YXNldERpY3QlMEElMEFjb21tb25fdm9pY2UlMjAlM0QlMjBEYXRhc2V0RGljdCgpJTBBJTBBY29tbW9uX3ZvaWNlJTVCJTIydHJhaW4lMjIlNUQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJkdiUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMkJ2YWxpZGF0aW9uJTIyJTBBKSUwQWNvbW1vbl92b2ljZSU1QiUyMnRlc3QlMjIlNUQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJkdiUyMiUyQyUyMHNwbGl0JTNEJTIydGVzdCUyMiUwQSklMEElMEFwcmludChjb21tb25fdm9pY2Up",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, DatasetDict

common_voice = DatasetDict()

common_voice[<span class="hljs-string">&quot;train&quot;</span>] = load_dataset(
    <span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;dv&quot;</span>, split=<span class="hljs-string">&quot;train+validation&quot;</span>
)
common_voice[<span class="hljs-string">&quot;test&quot;</span>] = load_dataset(
    <span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;dv&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>
)

<span class="hljs-built_in">print</span>(common_voice)`,wrap:!1}}),x=new o({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2NsaWVudF9pZCclMkMlMjAncGF0aCclMkMlMjAnYXVkaW8nJTJDJTIwJ3NlbnRlbmNlJyUyQyUyMCd1cF92b3RlcyclMkMlMjAnZG93bl92b3RlcyclMkMlMjAnYWdlJyUyQyUyMCdnZW5kZXInJTJDJTIwJ2FjY2VudCclMkMlMjAnbG9jYWxlJyUyQyUyMCdzZWdtZW50JyUyQyUyMCd2YXJpYW50JyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNDkwNCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB0ZXN0JTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidjbGllbnRfaWQnJTJDJTIwJ3BhdGgnJTJDJTIwJ2F1ZGlvJyUyQyUyMCdzZW50ZW5jZSclMkMlMjAndXBfdm90ZXMnJTJDJTIwJ2Rvd25fdm90ZXMnJTJDJTIwJ2FnZSclMkMlMjAnZ2VuZGVyJyUyQyUyMCdhY2NlbnQnJTJDJTIwJ2xvY2FsZSclMkMlMjAnc2VnbWVudCclMkMlMjAndmFyaWFudCclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDIyMTIlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTdEKQ==",highlighted:`DatasetDict({
    train: <span class="hljs-built_in">Dataset</span>({
        features: [<span class="hljs-string">&#x27;client_id&#x27;</span>, <span class="hljs-string">&#x27;path&#x27;</span>, <span class="hljs-string">&#x27;audio&#x27;</span>, <span class="hljs-string">&#x27;sentence&#x27;</span>, <span class="hljs-string">&#x27;up_votes&#x27;</span>, <span class="hljs-string">&#x27;down_votes&#x27;</span>, <span class="hljs-string">&#x27;age&#x27;</span>, <span class="hljs-string">&#x27;gender&#x27;</span>, <span class="hljs-string">&#x27;accent&#x27;</span>, <span class="hljs-string">&#x27;locale&#x27;</span>, <span class="hljs-string">&#x27;segment&#x27;</span>, <span class="hljs-string">&#x27;variant&#x27;</span>],
        num_rows: <span class="hljs-number">4904</span>
    })
    test: <span class="hljs-built_in">Dataset</span>({
        features: [<span class="hljs-string">&#x27;client_id&#x27;</span>, <span class="hljs-string">&#x27;path&#x27;</span>, <span class="hljs-string">&#x27;audio&#x27;</span>, <span class="hljs-string">&#x27;sentence&#x27;</span>, <span class="hljs-string">&#x27;up_votes&#x27;</span>, <span class="hljs-string">&#x27;down_votes&#x27;</span>, <span class="hljs-string">&#x27;age&#x27;</span>, <span class="hljs-string">&#x27;gender&#x27;</span>, <span class="hljs-string">&#x27;accent&#x27;</span>, <span class="hljs-string">&#x27;locale&#x27;</span>, <span class="hljs-string">&#x27;segment&#x27;</span>, <span class="hljs-string">&#x27;variant&#x27;</span>],
        num_rows: <span class="hljs-number">2212</span>
    })
})`,wrap:!1}}),d=new Kn({props:{$$slots:{default:[Ta]},$$scope:{ctx:Qe}}}),G=new o({props:{code:"Y29tbW9uX3ZvaWNlJTIwJTNEJTIwY29tbW9uX3ZvaWNlLnNlbGVjdF9jb2x1bW5zKCU1QiUyMmF1ZGlvJTIyJTJDJTIwJTIyc2VudGVuY2UlMjIlNUQp",highlighted:'common_voice = common_voice.select_columns([<span class="hljs-string">&quot;audio&quot;</span>, <span class="hljs-string">&quot;sentence&quot;</span>])',wrap:!1}}),S=new u({props:{title:"特征提取器、分词器和处理器",local:"特征提取器分词器和处理器",headingTag:"h2"}}),q=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbHMud2hpc3Blci50b2tlbml6YXRpb25fd2hpc3BlciUyMGltcG9ydCUyMFRPX0xBTkdVQUdFX0NPREUlMEElMEFUT19MQU5HVUFHRV9DT0RF",highlighted:`<span class="hljs-keyword">from</span> transformers.models.whisper.tokenization_whisper <span class="hljs-keyword">import</span> TO_LANGUAGE_CODE

TO_LANGUAGE_CODE`,wrap:!1}}),ll=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdoaXNwZXJQcm9jZXNzb3IlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBXaGlzcGVyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJvcGVuYWklMkZ3aGlzcGVyLXNtYWxsJTIyJTJDJTIwbGFuZ3VhZ2UlM0QlMjJzaW5oYWxlc2UlMjIlMkMlMjB0YXNrJTNEJTIydHJhbnNjcmliZSUyMiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> WhisperProcessor

processor = WhisperProcessor.from_pretrained(
    <span class="hljs-string">&quot;openai/whisper-small&quot;</span>, language=<span class="hljs-string">&quot;sinhalese&quot;</span>, task=<span class="hljs-string">&quot;transcribe&quot;</span>
)`,wrap:!1}}),tl=new u({props:{title:"预处理数据",local:"预处理数据",headingTag:"h2"}}),nl=new o({props:{code:"Y29tbW9uX3ZvaWNlJTVCJTIydHJhaW4lMjIlNUQuZmVhdHVyZXM=",highlighted:'common_voice[<span class="hljs-string">&quot;train&quot;</span>].features',wrap:!1}}),pl=new o({props:{code:"JTdCJ2F1ZGlvJyUzQSUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0Q0ODAwMCUyQyUyMG1vbm8lM0RUcnVlJTJDJTIwZGVjb2RlJTNEVHJ1ZSUyQyUyMGlkJTNETm9uZSklMkMlMEElMjAnc2VudGVuY2UnJTNBJTIwVmFsdWUoZHR5cGUlM0Qnc3RyaW5nJyUyQyUyMGlkJTNETm9uZSklN0Q=",highlighted:`{<span class="hljs-string">&#x27;audio&#x27;</span>: Audio(<span class="hljs-attribute">sampling_rate</span>=48000, <span class="hljs-attribute">mono</span>=<span class="hljs-literal">True</span>, <span class="hljs-attribute">decode</span>=<span class="hljs-literal">True</span>, <span class="hljs-attribute">id</span>=None),
 <span class="hljs-string">&#x27;sentence&#x27;</span>: Value(<span class="hljs-attribute">dtype</span>=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-attribute">id</span>=None)}`,wrap:!1}}),Ul=new o({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwQXVkaW8lMEElMEFzYW1wbGluZ19yYXRlJTIwJTNEJTIwcHJvY2Vzc29yLmZlYXR1cmVfZXh0cmFjdG9yLnNhbXBsaW5nX3JhdGUlMEFjb21tb25fdm9pY2UlMjAlM0QlMjBjb21tb25fdm9pY2UuY2FzdF9jb2x1bW4oJTIyYXVkaW8lMjIlMkMlMjBBdWRpbyhzYW1wbGluZ19yYXRlJTNEc2FtcGxpbmdfcmF0ZSkp",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Audio

sampling_rate = processor.feature_extractor.sampling_rate
common_voice = common_voice.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=sampling_rate))`,wrap:!1}}),cl=new o({props:{code:"ZGVmJTIwcHJlcGFyZV9kYXRhc2V0KGV4YW1wbGUpJTNBJTBBJTIwJTIwJTIwJTIwYXVkaW8lMjAlM0QlMjBleGFtcGxlJTVCJTIyYXVkaW8lMjIlNUQlMEElMEElMjAlMjAlMjAlMjBleGFtcGxlJTIwJTNEJTIwcHJvY2Vzc29yKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGF1ZGlvJTNEYXVkaW8lNUIlMjJhcnJheSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNhbXBsaW5nX3JhdGUlM0RhdWRpbyU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0ZXh0JTNEZXhhbXBsZSU1QiUyMnNlbnRlbmNlJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMCVFOCVBRSVBMSVFNyVBRSU5NyVFOCVCRSU5MyVFNSU4NSVBNSVFOSU5RiVCMyVFOSVBMiU5MSVFNiVBMCVCNyVFNiU5QyVBQyVFNyU5QSU4NCVFOSU5NSVCRiVFNSVCQSVBNiVFRiVCQyU4QyVFNCVCQiVBNSVFNyVBNyU5MiVFOCVBRSVBMSUwQSUyMCUyMCUyMCUyMGV4YW1wbGUlNUIlMjJpbnB1dF9sZW5ndGglMjIlNUQlMjAlM0QlMjBsZW4oYXVkaW8lNUIlMjJhcnJheSUyMiU1RCklMjAlMkYlMjBhdWRpbyU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBleGFtcGxl",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">prepare_dataset</span>(<span class="hljs-params">example</span>):
    audio = example[<span class="hljs-string">&quot;audio&quot;</span>]

    example = processor(
        audio=audio[<span class="hljs-string">&quot;array&quot;</span>],
        sampling_rate=audio[<span class="hljs-string">&quot;sampling_rate&quot;</span>],
        text=example[<span class="hljs-string">&quot;sentence&quot;</span>],
    )

    <span class="hljs-comment"># 计算输入音频样本的长度，以秒计</span>
    example[<span class="hljs-string">&quot;input_length&quot;</span>] = <span class="hljs-built_in">len</span>(audio[<span class="hljs-string">&quot;array&quot;</span>]) / audio[<span class="hljs-string">&quot;sampling_rate&quot;</span>]

    <span class="hljs-keyword">return</span> example`,wrap:!1}}),ml=new o({props:{code:"Y29tbW9uX3ZvaWNlJTIwJTNEJTIwY29tbW9uX3ZvaWNlLm1hcCglMEElMjAlMjAlMjAlMjBwcmVwYXJlX2RhdGFzZXQlMkMlMjByZW1vdmVfY29sdW1ucyUzRGNvbW1vbl92b2ljZS5jb2x1bW5fbmFtZXMlNUIlMjJ0cmFpbiUyMiU1RCUyQyUyMG51bV9wcm9jJTNEMSUwQSk=",highlighted:`common_voice = common_voice.<span class="hljs-built_in">map</span>(
    prepare_dataset, remove_columns=common_voice.column_names[<span class="hljs-string">&quot;train&quot;</span>], num_proc=<span class="hljs-number">1</span>
)`,wrap:!1}}),Jl=new o({props:{code:"bWF4X2lucHV0X2xlbmd0aCUyMCUzRCUyMDMwLjAlMEElMEElMEFkZWYlMjBpc19hdWRpb19pbl9sZW5ndGhfcmFuZ2UobGVuZ3RoKSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGxlbmd0aCUyMCUzQyUyMG1heF9pbnB1dF9sZW5ndGg=",highlighted:`max_input_length = <span class="hljs-number">30.0</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">is_audio_in_length_range</span>(<span class="hljs-params">length</span>):
    <span class="hljs-keyword">return</span> length &lt; max_input_length`,wrap:!1}}),ul=new o({props:{code:"Y29tbW9uX3ZvaWNlJTVCJTIydHJhaW4lMjIlNUQlMjAlM0QlMjBjb21tb25fdm9pY2UlNUIlMjJ0cmFpbiUyMiU1RC5maWx0ZXIoJTBBJTIwJTIwJTIwJTIwaXNfYXVkaW9faW5fbGVuZ3RoX3JhbmdlJTJDJTBBJTIwJTIwJTIwJTIwaW5wdXRfY29sdW1ucyUzRCU1QiUyMmlucHV0X2xlbmd0aCUyMiU1RCUyQyUwQSk=",highlighted:`common_voice[<span class="hljs-string">&quot;train&quot;</span>] = common_voice[<span class="hljs-string">&quot;train&quot;</span>].<span class="hljs-built_in">filter</span>(
    is_audio_in_length_range,
    input_columns=[<span class="hljs-string">&quot;input_length&quot;</span>],
)`,wrap:!1}}),dl=new o({props:{code:"Y29tbW9uX3ZvaWNlJTVCJTIydHJhaW4lMjIlNUQ=",highlighted:'common_voice[<span class="hljs-string">&quot;train&quot;</span>]',wrap:!1}}),hl=new o({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidpbnB1dF9mZWF0dXJlcyclMkMlMjAnbGFiZWxzJyUyQyUyMCdpbnB1dF9sZW5ndGgnJTVEJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjA0OTA0JTBBJTdEKQ==",highlighted:`<span class="hljs-title function_ invoke__">Dataset</span>({
    <span class="hljs-attr">features</span>: [<span class="hljs-string">&#x27;input_features&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;input_length&#x27;</span>],
    <span class="hljs-attr">num_rows</span>: <span class="hljs-number">4904</span>
})`,wrap:!1}}),bl=new u({props:{title:"训练和评估",local:"训练和评估",headingTag:"h2"}}),Vl=new u({props:{title:"定义数据整理器",local:"定义数据整理器",headingTag:"h3"}}),kl=new o({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGF0YWNsYXNzZXMlMjBpbXBvcnQlMjBkYXRhY2xhc3MlMEFmcm9tJTIwdHlwaW5nJTIwaW1wb3J0JTIwQW55JTJDJTIwRGljdCUyQyUyMExpc3QlMkMlMjBVbmlvbiUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yU3BlZWNoU2VxMlNlcVdpdGhQYWRkaW5nJTNBJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc29yJTNBJTIwQW55JTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19jYWxsX18oJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZiUyQyUyMGZlYXR1cmVzJTNBJTIwTGlzdCU1QkRpY3QlNUJzdHIlMkMlMjBVbmlvbiU1Qkxpc3QlNUJpbnQlNUQlMkMlMjB0b3JjaC5UZW5zb3IlNUQlNUQlNUQlMEElMjAlMjAlMj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g=",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Any</span>, <span class="hljs-type">Dict</span>, <span class="hljs-type">List</span>, <span class="hljs-type">Union</span>


<span class="hljs-meta">@dataclass</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorSpeechSeq2SeqWithPadding</span>:
    processor: <span class="hljs-type">Any</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">
        self, features: <span class="hljs-type">List</span>[<span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, <span class="hljs-type">Union</span>[<span class="hljs-type">List</span>[<span class="hljs-built_in">int</span>], torch.Tensor]]]
    </span>) -&gt; <span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, torch.Tensor]:
        <span class="hljs-comment"># 分离输入特征和标签，它们长度不同，填充方式也不同</span>
        <span class="hljs-comment"># 首先以 PyTorch 张量格式返回音频</span>
        input_features = [
            {<span class="hljs-string">&quot;input_features&quot;</span>: feature[<span class="hljs-string">&quot;input_features&quot;</span>][<span class="hljs-number">0</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features
        ]
        batch = self.processor.feature_extractor.pad(input_features, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

        <span class="hljs-comment"># 获取分词后得到的标签序列</span>
        label_features = [{<span class="hljs-string">&quot;input_ids&quot;</span>: feature[<span class="hljs-string">&quot;labels&quot;</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
        <span class="hljs-comment"># 把标签序列填充到最大长度</span>
        labels_batch = self.processor.tokenizer.pad(label_features, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

        <span class="hljs-comment"># 用 -100 来代替填充进的标签，从而不影响损失函数的计算</span>
        labels = labels_batch[<span class="hljs-string">&quot;input_ids&quot;</span>].masked_fill(
            labels_batch.attention_mask.ne(<span class="hljs-number">1</span>), -<span class="hljs-number">100</span>
        )

        <span class="hljs-comment"># 如果在之前分词时添加了 bos 词元，那就剪切掉，因为之后还会加上的</span>
        <span class="hljs-keyword">if</span> (labels[:, <span class="hljs-number">0</span>] == self.processor.tokenizer.bos_token_id).<span class="hljs-built_in">all</span>().cpu().item():
            labels = labels[:, <span class="hljs-number">1</span>:]

        batch[<span class="hljs-string">&quot;labels&quot;</span>] = labels

        <span class="hljs-keyword">return</span> batch`,wrap:!1}}),El=new o({props:{code:"ZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvclNwZWVjaFNlcTJTZXFXaXRoUGFkZGluZyhwcm9jZXNzb3IlM0Rwcm9jZXNzb3Ip",highlighted:"data_collator = DataCollatorSpeechSeq2SeqWithPadding(processor=processor)",wrap:!1}}),vl=new u({props:{title:"评估指标",local:"评估指标",headingTag:"h3"}}),xl=new o({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMndlciUyMik=",highlighted:`<span class="hljs-keyword">import</span> evaluate

metric = evaluate.load(<span class="hljs-string">&quot;wer&quot;</span>)`,wrap:!1}}),Gl=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbHMud2hpc3Blci5lbmdsaXNoX25vcm1hbGl6ZXIlMjBpbXBvcnQlMjBCYXNpY1RleHROb3JtYWxpemVyJTBBJTBBbm9ybWFsaXplciUyMCUzRCUyMEJhc2ljVGV4dE5vcm1hbGl6ZXIoKSUwQSUwQSUwQWRlZiUyMGNvbXB1dGVfbWV0cmljcyhwcmVkKSUzQSUwQSUyMCUyMCUyMCUyMHByZWRfaWRzJTIwJTNEJTIwcHJlZC5wcmVkaWN0aW9ucyUwQSUyMCUyMCUyMCUyMGxhYmVsX2lkcyUyMCUzRCUyMHByZWQubGFiZWxfaWRzJTBBJTBBJTIwJTIwJTIwJ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U1QmklNUQpJTIwJTNFJTIwMCUwQSUyMCUyMCUyMCUyMCU1RCUwQSUwQSUyMCUyMCUyMCUyMHdlciUyMCUzRCUyMDEwMCUyMColMjBtZXRyaWMuY29tcHV0ZShwcmVkaWN0aW9ucyUzRHByZWRfc3RyX25vcm0lMkMlMjByZWZlcmVuY2VzJTNEbGFiZWxfc3RyX25vcm0pJTBBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTdCJTIyd2VyX29ydGhvJTIyJTNBJTIwd2VyX29ydGhvJTJDJTIwJTIyd2VyJTIyJTNBJTIwd2VyJTdE",highlighted:`<span class="hljs-keyword">from</span> transformers.models.whisper.english_normalizer <span class="hljs-keyword">import</span> BasicTextNormalizer

normalizer = BasicTextNormalizer()


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">pred</span>):
    pred_ids = pred.predictions
    label_ids = pred.label_ids

    <span class="hljs-comment"># 用 pad_token_id 替换 -100</span>
    label_ids[label_ids == -<span class="hljs-number">100</span>] = processor.tokenizer.pad_token_id

    <span class="hljs-comment"># 我们希望在计算指标时不要组合起词元</span>
    pred_str = processor.batch_decode(pred_ids, skip_special_tokens=<span class="hljs-literal">True</span>)
    label_str = processor.batch_decode(label_ids, skip_special_tokens=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># 计算普通的 WER</span>
    wer_ortho = <span class="hljs-number">100</span> * metric.compute(predictions=pred_str, references=label_str)

    <span class="hljs-comment"># 计算标准化的 WER</span>
    pred_str_norm = [normalizer(pred) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> pred_str]
    label_str_norm = [normalizer(label) <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> label_str]
    <span class="hljs-comment"># 过滤，从而在评估时只计算 reference 非空的样本</span>
    pred_str_norm = [
        pred_str_norm[i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(pred_str_norm)) <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(label_str_norm[i]) &gt; <span class="hljs-number">0</span>
    ]
    label_str_norm = [
        label_str_norm[i]
        <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(label_str_norm))
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(label_str_norm[i]) &gt; <span class="hljs-number">0</span>
    ]

    wer = <span class="hljs-number">100</span> * metric.compute(predictions=pred_str_norm, references=label_str_norm)

    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;wer_ortho&quot;</span>: wer_ortho, <span class="hljs-string">&quot;wer&quot;</span>: wer}`,wrap:!1}}),Sl=new u({props:{title:"加载预训练检查点",local:"加载预训练检查点",headingTag:"h3"}}),Xl=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdoaXNwZXJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMFdoaXNwZXJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haSUyRndoaXNwZXItc21hbGwlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> WhisperForConditionalGeneration

model = WhisperForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;openai/whisper-small&quot;</span>)`,wrap:!1}}),Ol=new o({props:{code:"ZnJvbSUyMGZ1bmN0b29scyUyMGltcG9ydCUyMHBhcnRpYWwlMEElMEElMjMlMjAlRTUlOUMlQTglRTglQUUlQUQlRTclQkIlODMlRTYlOUMlOUYlRTklOTclQjQlRTQlQjglOEQlRTQlQkQlQkYlRTclOTQlQTglRTclQkMlOTMlRTUlQUQlOTglRUYlQkMlOEMlRTUlOUIlQTAlRTQlQjglQkElRTUlQUUlODMlRTUlOTIlOEMlRTYlQTIlQUYlRTUlQkElQTYlRTYlQTMlODAlRTYlOUYlQTUlRTclODIlQjklRTQlQjglOEQlRTUlODUlQkMlRTUlQUUlQjklMEFtb2RlbC5jb25maWcudXNlX2NhY2hlJTIwJTNEJTIwRmFsc2UlMEElMEElMjMlMjAlRTQlQjglQkElRTclOTQlOUYlRTYlODglOTAlRTglQUUlQkUlRTclQkQlQUUlRTglQUYlQUQlRTglQTglODAlRTUlOTIlOEMlRTQlQkIlQkIlRTUlOEElQTElRUYlQkMlOEMlRTUlQjklQjYlRTklODclOEQlRTYlOTYlQjAlRTUlOTAlQUYlRTclOTQlQTglRTclQkMlOTMlRTUlQUQlOTglMEFtb2RlbC5nZW5lcmF0ZSUyMCUzRCUyMHBhcnRpYWwoJTBBJTIwJTIwJTIwJTIwbW9kZWwuZ2VuZXJhdGUlMkMlMjBsYW5ndWFnZSUzRCUyMnNpbmhhbGVzZSUyMiUyQyUyMHRhc2slM0QlMjJ0cmFuc2NyaWJlJTIyJTJDJTIwdXNlX2NhY2hlJTNEVHJ1ZSUwQSk=",highlighted:`<span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> partial

<span class="hljs-comment"># 在训练期间不使用缓存，因为它和梯度检查点不兼容</span>
model.config.use_cache = <span class="hljs-literal">False</span>

<span class="hljs-comment"># 为生成设置语言和任务，并重新启用缓存</span>
model.generate = partial(
    model.generate, language=<span class="hljs-string">&quot;sinhalese&quot;</span>, task=<span class="hljs-string">&quot;transcribe&quot;</span>, use_cache=<span class="hljs-literal">True</span>
)`,wrap:!1}}),zl=new u({props:{title:"定义训练配置",local:"定义训练配置",headingTag:"h2"}}),Dl=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBTZXEyU2VxVHJhaW5pbmdBcmd1bWVudHMoJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMi4lMkZ3aGlzcGVyLXNtYW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pbnRpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZnAxNiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2X2Z1bGxfZXZhbCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyc3RlcHMlMjIlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwcHJlZGljdF93aXRoX2dlbmVyYXRlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRpb25fbWF4X2xlbmd0aCUzRDIyNSUyQyUwQSUyMCUyMCUyMCUyMHNhdmVfc3RlcHMlM0Q1MDAlMkMlMEElMjAlMjAlMjAlMjBldmFsX3N0ZXBzJTNENTAwJTJDJTBBJTIwJTIwJTIwJTIwbG9nZ2luZ19zdGVwcyUzRDI1JTJDJTBBJTIwJTIwJTIwJTIwcmVwb3J0X3RvJTNEJTVCJTIydGVuc29yYm9hcmQlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBsb2FkX2Jlc3RfbW9kZWxfYXRfZW5kJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG1ldHJpY19mb3JfYmVzdF9tb2RlbCUzRCUyMndlciUyMiUyQyUwQSUyMCUyMCUyMCUyMGdyZWF0ZXJfaXNfYmV0dGVyJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainingArguments

training_args = Seq2SeqTrainingArguments(
    output_dir=<span class="hljs-string">&quot;./whisper-small-dv&quot;</span>,  <span class="hljs-comment"># 在 HF Hub 上的输出目录的名字</span>
    per_device_train_batch_size=<span class="hljs-number">16</span>,
    gradient_accumulation_steps=<span class="hljs-number">1</span>,  <span class="hljs-comment"># 每次 batch size 下调到一半就把这个参数上调到两倍</span>
    learning_rate=<span class="hljs-number">1e-5</span>,
    lr_scheduler_type=<span class="hljs-string">&quot;constant_with_warmup&quot;</span>,
    warmup_steps=<span class="hljs-number">50</span>,
    max_steps=<span class="hljs-number">500</span>,  <span class="hljs-comment"># 如果您有自己的 GPU 或者 Colab 付费计划，上调到 4000</span>
    gradient_checkpointing=<span class="hljs-literal">True</span>,
    fp16=<span class="hljs-literal">True</span>,
    fp16_full_eval=<span class="hljs-literal">True</span>,
    evaluation_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
    per_device_eval_batch_size=<span class="hljs-number">16</span>,
    predict_with_generate=<span class="hljs-literal">True</span>,
    generation_max_length=<span class="hljs-number">225</span>,
    save_steps=<span class="hljs-number">500</span>,
    eval_steps=<span class="hljs-number">500</span>,
    logging_steps=<span class="hljs-number">25</span>,
    report_to=[<span class="hljs-string">&quot;tensorboard&quot;</span>],
    load_best_model_at_end=<span class="hljs-literal">True</span>,
    metric_for_best_model=<span class="hljs-string">&quot;wer&quot;</span>,
    greater_is_better=<span class="hljs-literal">False</span>,
    push_to_hub=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),w=new Kn({props:{$$slots:{default:[ya]},$$scope:{ctx:Qe}}}),Pl=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0Rjb21tb25fdm9pY2UlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRGNvbW1vbl92b2ljZSU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMGNvbXB1dGVfbWV0cmljcyUzRGNvbXB1dGVfbWV0cmljcyUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHByb2Nlc3NvciUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainer

trainer = Seq2SeqTrainer(
    args=training_args,
    model=model,
    train_dataset=common_voice[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=common_voice[<span class="hljs-string">&quot;test&quot;</span>],
    data_collator=data_collator,
    compute_metrics=compute_metrics,
    tokenizer=processor,
)`,wrap:!1}}),le=new u({props:{title:"训练",local:"训练",headingTag:"h3"}}),te=new o({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:"trainer.train()",wrap:!1}}),ye=new o({props:{code:"a3dhcmdzJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIyZGF0YXNldF90YWdzJTIyJTNBJTIwJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJkYXRhc2V0JTIyJTNBJTIwJTIyQ29tbW9uJTIwVm9pY2UlMjAxMyUyMiUyQyUyMCUyMCUyMyUyMCVFOCVBRSVBRCVFNyVCQiU4MyVFNiU5NSVCMCVFNiU4RCVBRSVFOSU5QiU4NiUwQSUyMCUyMCUyMCUyMCUyMmxhbmd1YWdlJTIyJTNBJTIwJTIyZHYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJtb2RlbF9uYW1lJTIyJTNBJTIwJTIyV2hpc3BlciUyMFNtYWxsJTIwRHYlMjAtJTIwU2FuY2hpdCUyMEdhbmRoaSUyMiUyQyUyMCUyMCUyMyUyMCVFNyVCQiU5OSVFNiVBOCVBMSVFNSU5RSU4QiVFOCVCNSVCNyVFNCVCOCVBQSVFMiU4MCU5QyVFNiVCQyU4MiVFNCVCQSVBRSVFMiU4MCU5RCVFNyU5QSU4NCVFNSU5MCU4RCVFNSVBRCU5NyUwQSUyMCUyMCUyMCUyMCUyMmZpbmV0dW5lZF9mcm9tJTIyJTNBJTIwJTIyb3BlbmFpJTJGd2hpc3Blci1zbWFsbCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnRhc2tzJTIyJTNBJTIwJTIyYXV0b21hdGljLXNwZWVjaC1yZWNvZ25pdGlvbiUyMiUyQyUwQSU3RA==",highlighted:`kwargs = {
    <span class="hljs-string">&quot;dataset_tags&quot;</span>: <span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>,
    <span class="hljs-string">&quot;dataset&quot;</span>: <span class="hljs-string">&quot;Common Voice 13&quot;</span>,  <span class="hljs-comment"># 训练数据集</span>
    <span class="hljs-string">&quot;language&quot;</span>: <span class="hljs-string">&quot;dv&quot;</span>,
    <span class="hljs-string">&quot;model_name&quot;</span>: <span class="hljs-string">&quot;Whisper Small Dv - Sanchit Gandhi&quot;</span>,  <span class="hljs-comment"># 给模型起个“漂亮”的名字</span>
    <span class="hljs-string">&quot;finetuned_from&quot;</span>: <span class="hljs-string">&quot;openai/whisper-small&quot;</span>,
    <span class="hljs-string">&quot;tasks&quot;</span>: <span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>,
}`,wrap:!1}}),re=new o({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1YigqKmt3YXJncyk=",highlighted:"trainer.push_to_hub(**kwargs)",wrap:!1}}),ue=new u({props:{title:"分享您的模型",local:"分享您的模型",headingTag:"h2"}}),de=new o({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKCUyMmF1dG9tYXRpYy1zcGVlY2gtcmVjb2duaXRpb24lMjIlMkMlMjBtb2RlbCUzRCUyMnNhbmNoaXQtZ2FuZGhpJTJGd2hpc3Blci1zbWFsbC1kdiUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;sanchit-gandhi/whisper-small-dv&quot;</span>)`,wrap:!1}}),we=new u({props:{title:"结论",local:"结论",headingTag:"h2"}}),be=new Ua({props:{source:"https://github.com/huggingface/audio-transformers-course/blob/main/chapters/zh-CN/chapter5/fine-tuning.mdx"}}),{c(){J=p("meta"),j=n(),C=p("p"),ge=n(),U(h.$$.fragment),Ve=n(),U(f.$$.fragment),Ie=n(),b=p("p"),b.textContent=Ws,_e=n(),Q=p("p"),Q.textContent=Es,$e=n(),R=p("p"),R.textContent=Fs,Ne=n(),g=p("p"),g.textContent=vs,ke=n(),U(V.$$.fragment),We=n(),I=p("p"),I.innerHTML=Bs,Ee=n(),_=p("ul"),_.innerHTML=As,Fe=n(),$=p("p"),$.innerHTML=xs,ve=n(),U(N.$$.fragment),Be=n(),k=p("p"),k.innerHTML=Zs,Ae=n(),U(W.$$.fragment),xe=n(),U(E.$$.fragment),Ze=n(),F=p("p"),F.innerHTML=Gs,Ge=n(),v=p("p"),v.innerHTML=Ss,Se=n(),U(B.$$.fragment),Ye=n(),A=p("p"),A.innerHTML=Ys,Xe=n(),U(x.$$.fragment),He=n(),U(d.$$.fragment),Oe=n(),Z=p("p"),Z.innerHTML=Xs,ze=n(),U(G.$$.fragment),qe=n(),U(S.$$.fragment),De=n(),Y=p("p"),Y.textContent=Hs,Le=n(),X=p("ol"),X.innerHTML=Os,Pe=n(),H=p("p"),H.innerHTML=zs,Ke=n(),O=p("p"),O.innerHTML=qs,lt=n(),z=p("p"),z.textContent=Ds,et=n(),U(q.$$.fragment),tt=n(),D=p("p"),D.textContent=Ls,st=n(),L=p("p"),L.textContent=Ps,nt=n(),P=p("p"),P.innerHTML=Ks,at=n(),K=p("p"),K.innerHTML=ln,pt=n(),U(ll.$$.fragment),Mt=n(),el=p("p"),el.innerHTML=en,it=n(),U(tl.$$.fragment),Ut=n(),sl=p("p"),sl.innerHTML=tn,Tt=n(),U(nl.$$.fragment),yt=n(),al=p("p"),al.innerHTML=sn,ct=n(),U(pl.$$.fragment),rt=n(),Ml=p("p"),Ml.innerHTML=nn,mt=n(),il=p("p"),il.innerHTML=an,ot=n(),U(Ul.$$.fragment),Jt=n(),Tl=p("p"),Tl.textContent=pn,jt=n(),yl=p("ol"),yl.innerHTML=Mn,ut=n(),U(cl.$$.fragment),Ct=n(),rl=p("p"),rl.innerHTML=Un,dt=n(),U(ml.$$.fragment),wt=n(),ol=p("p"),ol.innerHTML=Tn,ht=n(),U(Jl.$$.fragment),ft=n(),jl=p("p"),jl.innerHTML=yn,bt=n(),U(ul.$$.fragment),Qt=n(),Cl=p("p"),Cl.textContent=cn,Rt=n(),U(dl.$$.fragment),gt=n(),wl=p("p"),wl.innerHTML=rn,Vt=n(),U(hl.$$.fragment),It=n(),fl=p("p"),fl.textContent=mn,_t=n(),U(bl.$$.fragment),$t=n(),Ql=p("p"),Ql.innerHTML=on,Nt=n(),Rl=p("ul"),Rl.innerHTML=Jn,kt=n(),gl=p("p"),gl.textContent=jn,Wt=n(),U(Vl.$$.fragment),Et=n(),Il=p("p"),Il.innerHTML=un,Ft=n(),_l=p("p"),_l.innerHTML=Cn,vt=n(),$l=p("p"),$l.innerHTML=dn,Bt=n(),Nl=p("p"),Nl.innerHTML=wn,At=n(),U(kl.$$.fragment),xt=n(),Wl=p("p"),Wl.textContent=hn,Zt=n(),U(El.$$.fragment),Gt=n(),Fl=p("p"),Fl.textContent=fn,St=n(),U(vl.$$.fragment),Yt=n(),Bl=p("p"),Bl.innerHTML=bn,Xt=n(),Al=p("p"),Al.textContent=Qn,Ht=n(),U(xl.$$.fragment),Ot=n(),Zl=p("p"),Zl.innerHTML=Rn,zt=n(),U(Gl.$$.fragment),qt=n(),U(Sl.$$.fragment),Dt=n(),Yl=p("p"),Yl.textContent=gn,Lt=n(),U(Xl.$$.fragment),Pt=n(),Hl=p("p"),Hl.innerHTML=Vn,Kt=n(),U(Ol.$$.fragment),ls=n(),U(zl.$$.fragment),es=n(),ql=p("p"),ql.innerHTML=In,ts=n(),U(Dl.$$.fragment),ss=n(),U(w.$$.fragment),ns=n(),Ll=p("p"),Ll.innerHTML=_n,as=n(),U(Pl.$$.fragment),ps=n(),Kl=p("p"),Kl.textContent=$n,Ms=n(),U(le.$$.fragment),is=n(),ee=p("p"),ee.textContent=Nn,Us=n(),U(te.$$.fragment),Ts=n(),se=p("p"),se.innerHTML=kn,ys=n(),ne=p("p"),ne.innerHTML=Wn,cs=n(),ae=p("table"),ae.innerHTML=En,rs=n(),pe=p("p"),pe.textContent=Fn,ms=n(),Me=p("p"),Me.innerHTML=vn,os=n(),ie=p("p"),ie.innerHTML=Bn,Js=n(),Ue=p("p"),Ue.innerHTML=An,js=n(),Te=p("p"),Te.textContent=xn,us=n(),U(ye.$$.fragment),Cs=n(),ce=p("p"),ce.innerHTML=Zn,ds=n(),U(re.$$.fragment),ws=n(),me=p("p"),me.innerHTML=Gn,hs=n(),oe=p("p"),oe.textContent=Sn,fs=n(),Je=p("p"),Je.innerHTML=Yn,bs=n(),je=p("p"),je.innerHTML=Xn,Qs=n(),U(ue.$$.fragment),Rs=n(),Ce=p("p"),Ce.innerHTML=Hn,gs=n(),U(de.$$.fragment),Vs=n(),U(we.$$.fragment),Is=n(),he=p("p"),he.innerHTML=On,_s=n(),fe=p("p"),fe.innerHTML=zn,$s=n(),U(be.$$.fragment),Ns=n(),Re=p("p"),this.h()},l(l){const e=pa("svelte-u9bgzb",document.head);J=M(e,"META",{name:!0,content:!0}),e.forEach(t),j=a(l),C=M(l,"P",{}),Ln(C).forEach(t),ge=a(l),T(h.$$.fragment,l),Ve=a(l),T(f.$$.fragment,l),Ie=a(l),b=M(l,"P",{"data-svelte-h":!0}),i(b)!=="svelte-t5ru1m"&&(b.textContent=Ws),_e=a(l),Q=M(l,"P",{"data-svelte-h":!0}),i(Q)!=="svelte-f3da03"&&(Q.textContent=Es),$e=a(l),R=M(l,"P",{"data-svelte-h":!0}),i(R)!=="svelte-1vlcpny"&&(R.textContent=Fs),Ne=a(l),g=M(l,"P",{"data-svelte-h":!0}),i(g)!=="svelte-n705wb"&&(g.textContent=vs),ke=a(l),T(V.$$.fragment,l),We=a(l),I=M(l,"P",{"data-svelte-h":!0}),i(I)!=="svelte-lens2d"&&(I.innerHTML=Bs),Ee=a(l),_=M(l,"UL",{"data-svelte-h":!0}),i(_)!=="svelte-zy709d"&&(_.innerHTML=As),Fe=a(l),$=M(l,"P",{"data-svelte-h":!0}),i($)!=="svelte-dgyk61"&&($.innerHTML=xs),ve=a(l),T(N.$$.fragment,l),Be=a(l),k=M(l,"P",{"data-svelte-h":!0}),i(k)!=="svelte-1yevus4"&&(k.innerHTML=Zs),Ae=a(l),T(W.$$.fragment,l),xe=a(l),T(E.$$.fragment,l),Ze=a(l),F=M(l,"P",{"data-svelte-h":!0}),i(F)!=="svelte-92mc8l"&&(F.innerHTML=Gs),Ge=a(l),v=M(l,"P",{"data-svelte-h":!0}),i(v)!=="svelte-11i4l0m"&&(v.innerHTML=Ss),Se=a(l),T(B.$$.fragment,l),Ye=a(l),A=M(l,"P",{"data-svelte-h":!0}),i(A)!=="svelte-1yevus4"&&(A.innerHTML=Ys),Xe=a(l),T(x.$$.fragment,l),He=a(l),T(d.$$.fragment,l),Oe=a(l),Z=M(l,"P",{"data-svelte-h":!0}),i(Z)!=="svelte-c0b7nt"&&(Z.innerHTML=Xs),ze=a(l),T(G.$$.fragment,l),qe=a(l),T(S.$$.fragment,l),De=a(l),Y=M(l,"P",{"data-svelte-h":!0}),i(Y)!=="svelte-1uoip9t"&&(Y.textContent=Hs),Le=a(l),X=M(l,"OL",{"data-svelte-h":!0}),i(X)!=="svelte-1w9f7ck"&&(X.innerHTML=Os),Pe=a(l),H=M(l,"P",{"data-svelte-h":!0}),i(H)!=="svelte-162nugg"&&(H.innerHTML=zs),Ke=a(l),O=M(l,"P",{"data-svelte-h":!0}),i(O)!=="svelte-192gcf7"&&(O.innerHTML=qs),lt=a(l),z=M(l,"P",{"data-svelte-h":!0}),i(z)!=="svelte-1ezccys"&&(z.textContent=Ds),et=a(l),T(q.$$.fragment,l),tt=a(l),D=M(l,"P",{"data-svelte-h":!0}),i(D)!=="svelte-1p1d3gg"&&(D.textContent=Ls),st=a(l),L=M(l,"P",{"data-svelte-h":!0}),i(L)!=="svelte-ta40kf"&&(L.textContent=Ps),nt=a(l),P=M(l,"P",{"data-svelte-h":!0}),i(P)!=="svelte-1a2pu3t"&&(P.innerHTML=Ks),at=a(l),K=M(l,"P",{"data-svelte-h":!0}),i(K)!=="svelte-r8eoip"&&(K.innerHTML=ln),pt=a(l),T(ll.$$.fragment,l),Mt=a(l),el=M(l,"P",{"data-svelte-h":!0}),i(el)!=="svelte-g0mj1o"&&(el.innerHTML=en),it=a(l),T(tl.$$.fragment,l),Ut=a(l),sl=M(l,"P",{"data-svelte-h":!0}),i(sl)!=="svelte-2b5fha"&&(sl.innerHTML=tn),Tt=a(l),T(nl.$$.fragment,l),yt=a(l),al=M(l,"P",{"data-svelte-h":!0}),i(al)!=="svelte-1yevus4"&&(al.innerHTML=sn),ct=a(l),T(pl.$$.fragment,l),rt=a(l),Ml=M(l,"P",{"data-svelte-h":!0}),i(Ml)!=="svelte-1c29jgt"&&(Ml.innerHTML=nn),mt=a(l),il=M(l,"P",{"data-svelte-h":!0}),i(il)!=="svelte-1vgw7u7"&&(il.innerHTML=an),ot=a(l),T(Ul.$$.fragment,l),Jt=a(l),Tl=M(l,"P",{"data-svelte-h":!0}),i(Tl)!=="svelte-zcyi55"&&(Tl.textContent=pn),jt=a(l),yl=M(l,"OL",{"data-svelte-h":!0}),i(yl)!=="svelte-1qehlx7"&&(yl.innerHTML=Mn),ut=a(l),T(cl.$$.fragment,l),Ct=a(l),rl=M(l,"P",{"data-svelte-h":!0}),i(rl)!=="svelte-1ehdxdk"&&(rl.innerHTML=Un),dt=a(l),T(ml.$$.fragment,l),wt=a(l),ol=M(l,"P",{"data-svelte-h":!0}),i(ol)!=="svelte-60yc23"&&(ol.innerHTML=Tn),ht=a(l),T(Jl.$$.fragment,l),ft=a(l),jl=M(l,"P",{"data-svelte-h":!0}),i(jl)!=="svelte-y0zjer"&&(jl.innerHTML=yn),bt=a(l),T(ul.$$.fragment,l),Qt=a(l),Cl=M(l,"P",{"data-svelte-h":!0}),i(Cl)!=="svelte-13hgdvh"&&(Cl.textContent=cn),Rt=a(l),T(dl.$$.fragment,l),gt=a(l),wl=M(l,"P",{"data-svelte-h":!0}),i(wl)!=="svelte-1yevus4"&&(wl.innerHTML=rn),Vt=a(l),T(hl.$$.fragment,l),It=a(l),fl=M(l,"P",{"data-svelte-h":!0}),i(fl)!=="svelte-c6tevt"&&(fl.textContent=mn),_t=a(l),T(bl.$$.fragment,l),$t=a(l),Ql=M(l,"P",{"data-svelte-h":!0}),i(Ql)!=="svelte-z5nw3c"&&(Ql.innerHTML=on),Nt=a(l),Rl=M(l,"UL",{"data-svelte-h":!0}),i(Rl)!=="svelte-10eslib"&&(Rl.innerHTML=Jn),kt=a(l),gl=M(l,"P",{"data-svelte-h":!0}),i(gl)!=="svelte-obu25w"&&(gl.textContent=jn),Wt=a(l),T(Vl.$$.fragment,l),Et=a(l),Il=M(l,"P",{"data-svelte-h":!0}),i(Il)!=="svelte-1kswku9"&&(Il.innerHTML=un),Ft=a(l),_l=M(l,"P",{"data-svelte-h":!0}),i(_l)!=="svelte-xlia7b"&&(_l.innerHTML=Cn),vt=a(l),$l=M(l,"P",{"data-svelte-h":!0}),i($l)!=="svelte-1iwpolk"&&($l.innerHTML=dn),Bt=a(l),Nl=M(l,"P",{"data-svelte-h":!0}),i(Nl)!=="svelte-1s7glbn"&&(Nl.innerHTML=wn),At=a(l),T(kl.$$.fragment,l),xt=a(l),Wl=M(l,"P",{"data-svelte-h":!0}),i(Wl)!=="svelte-z7lypb"&&(Wl.textContent=hn),Zt=a(l),T(El.$$.fragment,l),Gt=a(l),Fl=M(l,"P",{"data-svelte-h":!0}),i(Fl)!=="svelte-dqtrpj"&&(Fl.textContent=fn),St=a(l),T(vl.$$.fragment,l),Yt=a(l),Bl=M(l,"P",{"data-svelte-h":!0}),i(Bl)!=="svelte-7tjb9r"&&(Bl.innerHTML=bn),Xt=a(l),Al=M(l,"P",{"data-svelte-h":!0}),i(Al)!=="svelte-1lc6r4g"&&(Al.textContent=Qn),Ht=a(l),T(xl.$$.fragment,l),Ot=a(l),Zl=M(l,"P",{"data-svelte-h":!0}),i(Zl)!=="svelte-414s5z"&&(Zl.innerHTML=Rn),zt=a(l),T(Gl.$$.fragment,l),qt=a(l),T(Sl.$$.fragment,l),Dt=a(l),Yl=M(l,"P",{"data-svelte-h":!0}),i(Yl)!=="svelte-zmr5sw"&&(Yl.textContent=gn),Lt=a(l),T(Xl.$$.fragment,l),Pt=a(l),Hl=M(l,"P",{"data-svelte-h":!0}),i(Hl)!=="svelte-1wi35xe"&&(Hl.innerHTML=Vn),Kt=a(l),T(Ol.$$.fragment,l),ls=a(l),T(zl.$$.fragment,l),es=a(l),ql=M(l,"P",{"data-svelte-h":!0}),i(ql)!=="svelte-ulkdda"&&(ql.innerHTML=In),ts=a(l),T(Dl.$$.fragment,l),ss=a(l),T(w.$$.fragment,l),ns=a(l),Ll=M(l,"P",{"data-svelte-h":!0}),i(Ll)!=="svelte-1u3ha1v"&&(Ll.innerHTML=_n),as=a(l),T(Pl.$$.fragment,l),ps=a(l),Kl=M(l,"P",{"data-svelte-h":!0}),i(Kl)!=="svelte-5wnyaq"&&(Kl.textContent=$n),Ms=a(l),T(le.$$.fragment,l),is=a(l),ee=M(l,"P",{"data-svelte-h":!0}),i(ee)!=="svelte-122cis9"&&(ee.textContent=Nn),Us=a(l),T(te.$$.fragment,l),Ts=a(l),se=M(l,"P",{"data-svelte-h":!0}),i(se)!=="svelte-1gjb4js"&&(se.innerHTML=kn),ys=a(l),ne=M(l,"P",{"data-svelte-h":!0}),i(ne)!=="svelte-1yevus4"&&(ne.innerHTML=Wn),cs=a(l),ae=M(l,"TABLE",{"data-svelte-h":!0}),i(ae)!=="svelte-10vryw9"&&(ae.innerHTML=En),rs=a(l),pe=M(l,"P",{"data-svelte-h":!0}),i(pe)!=="svelte-10aq1mn"&&(pe.textContent=Fn),ms=a(l),Me=M(l,"P",{"data-svelte-h":!0}),i(Me)!=="svelte-15gsjpw"&&(Me.innerHTML=vn),os=a(l),ie=M(l,"P",{"data-svelte-h":!0}),i(ie)!=="svelte-78xp5w"&&(ie.innerHTML=Bn),Js=a(l),Ue=M(l,"P",{"data-svelte-h":!0}),i(Ue)!=="svelte-s8vhhi"&&(Ue.innerHTML=An),js=a(l),Te=M(l,"P",{"data-svelte-h":!0}),i(Te)!=="svelte-bxx63o"&&(Te.textContent=xn),us=a(l),T(ye.$$.fragment,l),Cs=a(l),ce=M(l,"P",{"data-svelte-h":!0}),i(ce)!=="svelte-cgp6wi"&&(ce.innerHTML=Zn),ds=a(l),T(re.$$.fragment,l),ws=a(l),me=M(l,"P",{"data-svelte-h":!0}),i(me)!=="svelte-6yy0r3"&&(me.innerHTML=Gn),hs=a(l),oe=M(l,"P",{"data-svelte-h":!0}),i(oe)!=="svelte-16p8gmz"&&(oe.textContent=Sn),fs=a(l),Je=M(l,"P",{"data-svelte-h":!0}),i(Je)!=="svelte-8g6ivh"&&(Je.innerHTML=Yn),bs=a(l),je=M(l,"P",{"data-svelte-h":!0}),i(je)!=="svelte-78x16n"&&(je.innerHTML=Xn),Qs=a(l),T(ue.$$.fragment,l),Rs=a(l),Ce=M(l,"P",{"data-svelte-h":!0}),i(Ce)!=="svelte-aopruc"&&(Ce.innerHTML=Hn),gs=a(l),T(de.$$.fragment,l),Vs=a(l),T(we.$$.fragment,l),Is=a(l),he=M(l,"P",{"data-svelte-h":!0}),i(he)!=="svelte-6i264g"&&(he.innerHTML=On),_s=a(l),fe=M(l,"P",{"data-svelte-h":!0}),i(fe)!=="svelte-6xy6ht"&&(fe.innerHTML=zn),$s=a(l),T(be.$$.fragment,l),Ns=a(l),Re=M(l,"P",{}),Ln(Re).forEach(t),this.h()},h(){Pn(J,"name","hf:doc:metadata"),Pn(J,"content",ra)},m(l,e){Ma(document.head,J),s(l,j,e),s(l,C,e),s(l,ge,e),y(h,l,e),s(l,Ve,e),y(f,l,e),s(l,Ie,e),s(l,b,e),s(l,_e,e),s(l,Q,e),s(l,$e,e),s(l,R,e),s(l,Ne,e),s(l,g,e),s(l,ke,e),y(V,l,e),s(l,We,e),s(l,I,e),s(l,Ee,e),s(l,_,e),s(l,Fe,e),s(l,$,e),s(l,ve,e),y(N,l,e),s(l,Be,e),s(l,k,e),s(l,Ae,e),y(W,l,e),s(l,xe,e),y(E,l,e),s(l,Ze,e),s(l,F,e),s(l,Ge,e),s(l,v,e),s(l,Se,e),y(B,l,e),s(l,Ye,e),s(l,A,e),s(l,Xe,e),y(x,l,e),s(l,He,e),y(d,l,e),s(l,Oe,e),s(l,Z,e),s(l,ze,e),y(G,l,e),s(l,qe,e),y(S,l,e),s(l,De,e),s(l,Y,e),s(l,Le,e),s(l,X,e),s(l,Pe,e),s(l,H,e),s(l,Ke,e),s(l,O,e),s(l,lt,e),s(l,z,e),s(l,et,e),y(q,l,e),s(l,tt,e),s(l,D,e),s(l,st,e),s(l,L,e),s(l,nt,e),s(l,P,e),s(l,at,e),s(l,K,e),s(l,pt,e),y(ll,l,e),s(l,Mt,e),s(l,el,e),s(l,it,e),y(tl,l,e),s(l,Ut,e),s(l,sl,e),s(l,Tt,e),y(nl,l,e),s(l,yt,e),s(l,al,e),s(l,ct,e),y(pl,l,e),s(l,rt,e),s(l,Ml,e),s(l,mt,e),s(l,il,e),s(l,ot,e),y(Ul,l,e),s(l,Jt,e),s(l,Tl,e),s(l,jt,e),s(l,yl,e),s(l,ut,e),y(cl,l,e),s(l,Ct,e),s(l,rl,e),s(l,dt,e),y(ml,l,e),s(l,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oe,e),s(l,fs,e),s(l,Je,e),s(l,bs,e),s(l,je,e),s(l,Qs,e),y(ue,l,e),s(l,Rs,e),s(l,Ce,e),s(l,gs,e),y(de,l,e),s(l,Vs,e),y(we,l,e),s(l,Is,e),s(l,he,e),s(l,_s,e),s(l,fe,e),s(l,$s,e),y(be,l,e),s(l,Ns,e),s(l,Re,e),ks=!0},p(l,[e]){const qn={};e&2&&(qn.$$scope={dirty:e,ctx:l}),d.$set(qn);const Dn={};e&2&&(Dn.$$scope={dirty:e,ctx:l}),w.$set(Dn)},i(l){ks||(c(h.$$.fragment,l),c(f.$$.fragment,l),c(V.$$.fragment,l),c(N.$$.fragment,l),c(W.$$.fragment,l),c(E.$$.fragment,l),c(B.$$.fragment,l),c(x.$$.fragment,l),c(d.$$.fragment,l),c(G.$$.fragment,l),c(S.$$.fragment,l),c(q.$$.fragment,l),c(ll.$$.fragment,l),c(tl.$$.fragment,l),c(nl.$$.fragment,l),c(pl.$$.fragment,l),c(Ul.$$.fragment,l),c(cl.$$.fragment,l),c(ml.$$.fragment,l),c(Jl.$$.fragment,l),c(ul.$$.fragment,l),c(dl.$$.fragment,l),c(hl.$$.fragment,l),c(bl.$$.fragment,l),c(Vl.$$.fragment,l),c(kl.$$.fragment,l),c(El.$$.fragment,l),c(vl.$$.fragment,l),c(xl.$$.fragment,l),c(Gl.$$.fragment,l),c(Sl.$$.fragment,l),c(Xl.$$.fragment,l),c(Ol.$$.fragment,l),c(zl.$$.fragment,l),c(Dl.$$.fragment,l),c(w.$$.fragment,l),c(Pl.$$.fragment,l),c(le.$$.fragment,l),c(te.$$.fragment,l),c(ye.$$.fragment,l),c(re.$$.fragment,l),c(ue.$$.fragment,l),c(de.$$.fragment,l),c(we.$$.fragment,l),c(be.$$.fragment,l),ks=!0)},o(l){r(h.$$.fragment,l),r(f.$$.fragment,l),r(V.$$.fragment,l),r(N.$$.fragment,l),r(W.$$.fragment,l),r(E.$$.fragment,l),r(B.$$.fragment,l),r(x.$$.fragment,l),r(d.$$.fragment,l),r(G.$$.fragment,l),r(S.$$.fragment,l),r(q.$$.fragment,l),r(ll.$$.fragment,l),r(tl.$$.fragment,l),r(nl.$$.fragment,l),r(pl.$$.fragment,l),r(Ul.$$.fragment,l),r(cl.$$.fragment,l),r(ml.$$.fragment,l),r(Jl.$$.fragment,l),r(ul.$$.fragment,l),r(dl.$$.fragment,l),r(hl.$$.fragment,l),r(bl.$$.fragment,l),r(Vl.$$.fragment,l),r(kl.$$.fragment,l),r(El.$$.fragment,l),r(vl.$$.fragment,l),r(xl.$$.fragment,l),r(Gl.$$.fragment,l),r(Sl.$$.fragment,l),r(Xl.$$.fragment,l),r(Ol.$$.fragment,l),r(zl.$$.fragment,l),r(Dl.$$.fragment,l),r(w.$$.fragment,l),r(Pl.$$.fragment,l),r(le.$$.fragment,l),r(te.$$.fragment,l),r(ye.$$.fragment,l),r(re.$$.fragment,l),r(ue.$$.fragment,l),r(de.$$.fragment,l),r(we.$$.fragment,l),r(be.$$.fragment,l),ks=!1},d(l){l&&(t(j),t(C),t(ge),t(Ve),t(Ie),t(b),t(_e),t(Q),t($e),t(R),t(Ne),t(g),t(ke),t(We),t(I),t(Ee),t(_),t(Fe),t($),t(ve),t(Be),t(k),t(Ae),t(xe),t(Ze),t(F),t(Ge),t(v),t(Se),t(Ye),t(A),t(Xe),t(He),t(Oe),t(Z),t(ze),t(qe),t(De),t(Y),t(Le),t(X),t(Pe),t(H),t(Ke),t(O),t(lt),t(z),t(et),t(tt),t(D),t(st),t(L),t(nt),t(P),t(at),t(K),t(pt),t(Mt),t(el),t(it),t(Ut),t(sl),t(Tt),t(yt),t(al),t(ct),t(rt),t(Ml),t(mt),t(il),t(ot),t(Jt),t(Tl),t(jt),t(yl),t(ut),t(Ct),t(rl),t(dt),t(wt),t(ol),t(ht),t(ft),t(jl),t(bt),t(Qt),t(Cl),t(Rt),t(gt),t(wl),t(Vt),t(It),t(fl),t(_t),t($t),t(Ql),t(Nt),t(Rl),t(kt),t(gl),t(Wt),t(Et),t(Il),t(Ft),t(_l),t(vt),t($l),t(Bt),t(Nl),t(At),t(xt),t(Wl),t(Zt),t(Gt),t(Fl),t(St),t(Yt),t(Bl),t(Xt),t(Al),t(Ht),t(Ot),t(Zl),t(zt),t(qt),t(Dt),t(Yl),t(Lt),t(Pt),t(Hl),t(Kt),t(ls),t(es),t(ql),t(ts),t(ss),t(ns),t(Ll),t(as),t(ps),t(Kl),t(Ms),t(is),t(ee),t(Us),t(Ts),t(se),t(ys),t(ne),t(cs),t(ae),t(rs),t(pe),t(ms),t(Me),t(os),t(ie),t(Js),t(Ue),t(js),t(Te),t(us),t(Cs),t(ce),t(ds),t(ws),t(me),t(hs),t(oe),t(fs),t(Je),t(bs),t(je),t(Qs),t(Rs),t(Ce),t(gs),t(Vs),t(Is),t(he),t(_s),t(fe),t($s),t(Ns),t(Re)),t(J),m(h,l),m(f,l),m(V,l),m(N,l),m(W,l),m(E,l),m(B,l),m(x,l),m(d,l),m(G,l),m(S,l),m(q,l),m(ll,l),m(tl,l),m(nl,l),m(pl,l),m(Ul,l),m(cl,l),m(ml,l),m(Jl,l),m(ul,l),m(dl,l),m(hl,l),m(bl,l),m(Vl,l),m(kl,l),m(El,l),m(vl,l),m(xl,l),m(Gl,l),m(Sl,l),m(Xl,l),m(Ol,l),m(zl,l),m(Dl,l),m(w,l),m(Pl,l),m(le,l),m(te,l),m(ye,l),m(re,l),m(ue,l),m(de,l),m(we,l),m(be,l)}}}const ra='{"title":"微调语音识别模型","local":"微调语音识别模型","sections":[{"title":"配置环境","local":"配置环境","sections":[],"depth":2},{"title":"加载数据集","local":"加载数据集","sections":[],"depth":2},{"title":"特征提取器、分词器和处理器","local":"特征提取器分词器和处理器","sections":[],"depth":2},{"title":"预处理数据","local":"预处理数据","sections":[],"depth":2},{"title":"训练和评估","local":"训练和评估","sections":[{"title":"定义数据整理器","local":"定义数据整理器","sections":[],"depth":3},{"title":"评估指标","local":"评估指标","sections":[],"depth":3},{"title":"加载预训练检查点","local":"加载预训练检查点","sections":[],"depth":3}],"depth":2},{"title":"定义训练配置","local":"定义训练配置","sections":[{"title":"训练","local":"训练","sections":[],"depth":3}],"depth":2},{"title":"分享您的模型","local":"分享您的模型","sections":[],"depth":2},{"title":"结论","local":"结论","sections":[],"depth":2}],"depth":1}';function ma(Qe){return sa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class da extends na{constructor(J){super(),aa(this,J,ma,ca,ta,{})}}export{da as component};
