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