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