import{s as pt,o as it,n as nt}from"../chunks/scheduler.9991993c.js";import{S as rt,i as ct,g as p,s as a,r as c,A as mt,h as i,f as l,c as n,j as at,u as m,x as r,k as ol,y as ht,a as t,v as h,d as o,t as M,w as u,m as ot,n as Mt}from"../chunks/index.7fc9a5e7.js";import{T as Ml}from"../chunks/Tip.9de92fc6.js";import{C as J}from"../chunks/CodeBlock.e11cba92.js";import{H as g,E as ut}from"../chunks/EditOnGithub.84ab7f0e.js";function ft($){let f,y='请查看<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>文档以获取已支持的任务和可用参数的完整列表。';return{c(){f=p("p"),f.innerHTML=y},l(T){f=i(T,"P",{"data-svelte-h":!0}),r(f)!=="svelte-pd00vj"&&(f.innerHTML=y)},m(T,d){t(T,f,d)},p:nt,d(T){T&&l(f)}}}function jt($){let f;return{c(){f=ot("创建推理引擎是一个复杂的主题，值得有自己的页面。")},l(y){f=Mt(y,"创建推理引擎是一个复杂的主题，值得有自己的页面。")},m(y,T){t(y,f,T)},d(y){y&&l(f)}}}function Jt($){let f,y='要运行上面的示例，除了🤗 Transformers之外，您需要安装<a href="https://pypi.org/project/pytesseract/" rel="nofollow"><code>pytesseract</code></a>。',T,d,w;return d=new J({props:{code:"c3VkbyUyMGFwdCUyMGluc3RhbGwlMjAteSUyMHRlc3NlcmFjdC1vY3IlMEFwaXAlMjBpbnN0YWxsJTIwcHl0ZXNzZXJhY3Q=",highlighted:`sudo apt install -y tesseract-ocr
pip install pytesseract`,wrap:!1}}),{c(){f=p("p"),f.innerHTML=y,T=a(),c(d.$$.fragment)},l(j){f=i(j,"P",{"data-svelte-h":!0}),r(f)!=="svelte-9d8qcy"&&(f.innerHTML=y),T=n(j),m(d.$$.fragment,j)},m(j,b){t(j,f,b),t(j,T,b),h(d,j,b),w=!0},p:nt,i(j){w||(o(d.$$.fragment,j),w=!0)},o(j){M(d.$$.fragment,j),w=!1},d(j){j&&(l(f),l(T)),u(d,j)}}}function Tt($){let f,y,T,d,w,j,b,ul='<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 让使用<a href="https://huggingface.co/models" rel="nofollow">Hub</a>上的任何模型进行任何语言、计算机视觉、语音以及多模态任务的推理变得非常简单。即使您对特定的模态没有经验，或者不熟悉模型的源码，您仍然可以使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>进行推理！本教程将教您：',Ss,G,fl='<li>如何使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 进行推理。</li> <li>如何使用特定的<code>tokenizer</code>(分词器)或模型。</li> <li>如何使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 进行音频、视觉和多模态任务的推理。</li>',Fs,U,Qs,B,Es,x,jl='虽然每个任务都有一个关联的<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>，但使用通用的抽象的<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>更加简单，其中包含所有特定任务的<code>pipelines</code>。<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>会自动加载一个默认模型和一个能够进行任务推理的预处理类。让我们以使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>进行自动语音识别（ASR）或语音转文本为例。',Ps,k,Jl='<li>首先，创建一个<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>并指定推理任务：</li>',As,W,Ds,Z,Tl='<li>将您的输入传递给<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a>。对于语音识别，这通常是一个音频输入文件：</li>',Ks,_,Os,X,yl=`您没有得到您期望的结果？可以在Hub上查看一些<a href="https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&amp;sort=trending" rel="nofollow">最受欢迎的自动语音识别模型</a>
，看看是否可以获得更好的转录。`,se,H,dl=`让我们尝试来自 OpenAI 的<a href="https://huggingface.co/openai/whisper-large" rel="nofollow">Whisper large-v2</a> 模型。Whisperb比Wav2Vec2晚2年发布，使用接近10倍的数据进行了训练。因此，它在大多数下游基准测试上击败了Wav2Vec2。
它还具有预测标点和大小写的附加优势，而Wav2Vec2则无法实现这些功能。`,ee,C,wl="让我们在这里尝试一下，看看它的表现如何：",le,R,te,V,gl=`现在这个结果看起来更准确了！要进行深入的Wav2Vec2与Whisper比较，请参阅<a href="https://huggingface.co/learn/audio-course/chapter5/asr_models" rel="nofollow">音频变换器课程</a>。
我们鼓励您在 Hub 上查看不同语言的模型，以及专业领域的模型等。您可以在Hub上直接查看并比较模型的结果，以确定是否适合或处理边缘情况是否比其他模型更好。如果您没有找到适用于您的用例的模型，您始终可以<a href="training">训练</a>自己的模型！`,ae,Y,bl="如果您有多个输入，您可以将输入作为列表传递：",ne,N,pe,z,$l="<code>Pipelines</code>非常适合用于测试，因为从一个模型切换到另一个模型非常琐碎；但是，还有一些方法可以将它们优化后用于大型工作负载而不仅仅是测试。请查看以下指南，深入探讨如何迭代整个数据集或在Web服务器中使用<code>Pipelines</code>：",ie,q,Ul='<li><a href="#using-pipelines-on-a-dataset">在数据集上使用流水线</a></li> <li><a href="./pipeline_webserver">在Web服务器中使用流水线</a></li>',re,L,ce,S,Zl='<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 支持许多参数；有些是适用于特定任务的，而有些适用于所有<code>pipeline</code>。通常情况下，您可以在任何地方指定对应参数：',me,F,he,Q,Il="让我们查看其中的三个重要参数：",oe,E,Me,P,vl="如果您使用 <code>device=n</code>，<code>pipeline</code>会自动将模型放在指定的设备上。无论您使用PyTorch还是Tensorflow，这都可以工作。",ue,A,fe,D,Gl='如果模型对于单个GPU来说过于庞大，并且您正在使用PyTorch，您可以设置 <code>device_map=&quot;auto&quot;</code> 以自动确定如何加载和存储模型权重。使用 <code>device_map</code> 参数需要安装🤗 <a href="https://huggingface.co/docs/accelerate" rel="nofollow">Accelerate</a> 软件包：',je,K,Je,O,Bl="以下代码会自动在各个设备上加载和存储模型权重：",Te,ss,ye,es,xl="请注意，如果传递了 <code>device_map=&quot;auto&quot;</code>，在实例化您的 <code>pipeline</code> 时不需要添加 <code>device=device</code> 参数，否则可能会遇到一些意外的状况！",de,ls,we,ts,kl='默认情况下，<code>pipelines</code>不会进行批量推理，原因在<a href="https://huggingface.co/docs/transformers/main_classes/pipelines#pipeline-batching" rel="nofollow">这里</a>详细解释。因为批处理不一定更快，实际上在某些情况下可能会更慢。',ge,as,Wl="但如果在您的用例中起作用，您可以使用：",be,ns,$e,ps,_l="以上代码会在提供的4个音频文件上运行<code>pipeline</code>，它会将它们以2个一组的批次传递给模型（模型在GPU上，此时批处理更有可能有所帮助），而您无需编写额外的代码。输出应始终与没有批处理时收到的结果相一致。它只是一种帮助您更快地使用<code>pipeline</code>的方式。",Ue,is,Xl='<code>pipeline</code>也可以减轻一些批处理的复杂性，因为对于某些<code>pipeline</code>，需要将单个项目（如长音频文件）分成多个部分以供模型处理。<code>pipeline</code>为您执行这种<a href="./main_classes/pipelines#pipeline-chunk-batching"><em>chunk batching</em></a>。',Ze,rs,Ie,cs,Hl=`所有任务都提供了特定于任务的参数，这些参数提供额外的灵活性和选择，以帮助您完成工作。
例如，<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline.__call__">transformers.AutomaticSpeechRecognitionPipeline.<strong>call</strong>()</a> 方法具有一个 <code>return_timestamps</code> 参数，对于字幕视频似乎很有帮助：`,ve,ms,Ge,hs,Cl="正如您所看到的，模型推断出了文本，还输出了各个句子发音的<strong>时间</strong>。",Be,os,Rl='每个任务都有许多可用的参数，因此请查看每个任务的API参考，以了解您可以进行哪些调整！例如，<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline">AutomaticSpeechRecognitionPipeline</a> 具有 <code>chunk_length_s</code> 参数，对于处理非常长的音频文件（例如，为整部电影或长达一小时的视频配字幕）非常有帮助，这通常是模型无法单独处理的：',xe,Ms,ke,us,Vl='如果您找不到一个真正有帮助的参数，欢迎<a href="https://github.com/huggingface/transformers/issues/new?assignees=&amp;labels=feature&amp;template=feature-request.yml" rel="nofollow">提出请求</a>！',We,fs,_e,js,Yl="<code>pipelines</code>也可以对大型数据集进行推理。我们建议使用迭代器来完成这一任务，这是最简单的方法：",Xe,Js,He,Ts,Nl='迭代器 <code>data()</code> 会产生每个结果，<code>pipelines</code>会自动识别输入为可迭代对象，并在GPU上处理数据的同时开始获取数据（在底层使用<a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader" rel="nofollow">DataLoader</a>）。这一点非常重要，因为您不必为整个数据集分配内存，可以尽可能快地将数据传送到GPU。',Ce,ys,zl="由于批处理可以加速处理，因此在这里尝试调整 <code>batch_size</code> 参数可能会很有用。",Re,ds,ql='迭代数据集的最简单方法就是从🤗 <a href="https://github.com/huggingface/datasets/" rel="nofollow">Datasets</a> 中加载数据集：',Ve,ws,Ye,gs,Ne,I,ze,bs,Ll='<a href="./pipeline_webserver">链接</a>',qe,$s,Le,Us,Sl='对于视觉任务，使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 几乎是相同的。',Se,Zs,Fl="指定您的任务并将图像传递给分类器。图像可以是链接、本地路径或base64编码的图像。例如，下面显示的是哪种品种的猫？",Fe,Is,Ql='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg" alt="pipeline-cat-chonk"/>',Qe,vs,Ee,Gs,Pe,Bs,El='对于NLP任务，使用<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 几乎是相同的。',Ae,xs,De,ks,Ke,Ws,Pl='<a href="/docs/transformers/pr_30621/zh/main_classes/pipelines#transformers.pipeline">pipeline()</a> 支持多个模态。例如，视觉问题回答（VQA）任务结合了文本和图像。请随意使用您喜欢的任何图像链接和您想要问关于该图像的问题。图像可以是URL或图像的本地路径。',Oe,_s,Al='例如，如果您使用这个<a href="https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png" rel="nofollow">invoice image</a>：',sl,Xs,el,v,ll,Hs,tl,Cs,Dl="您可以轻松地使用🤗 <code>accelerate</code>在大模型上运行 <code>pipeline</code>！首先确保您已经使用 <code>pip install accelerate</code> 安装了 <code>accelerate</code>。",al,Rs,Kl="首先使用 <code>device_map=&quot;auto&quot;</code> 加载您的模型！我们将在示例中使用 <code>facebook/opt-1.3b</code>。",nl,Vs,pl,Ys,Ol="如果安装 <code>bitsandbytes</code> 并添加参数 <code>load_in_8bit=True</code>，您还可以传递8位加载的模型。",il,Ns,rl,zs,st="请注意，您可以将<code>checkpoint </code>替换为任何支持大模型加载的Hugging Face模型，比如BLOOM！",cl,qs,ml,Ls,hl;return w=new g({props:{title:"推理pipeline",local:"推理pipeline",headingTag:"h1"}}),U=new Ml({props:{$$slots:{default:[ft]},$$scope:{ctx:$}}}),B=new g({props:{title:"Pipeline使用",local:"pipeline使用",headingTag:"h2"}}),W=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIyYXV0b21hdGljLXNwZWVjaC1yZWNvZ25pdGlvbiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber = pipeline(task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>)`,wrap:!1}}),_=new J({props:{code:"dHJhbnNjcmliZXIoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGTmFyc2lsJTJGYXNyX2R1bW15JTJGcmVzb2x2ZSUyRm1haW4lMkZtbGsuZmxhYyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;I HAVE A DREAM BUT ONE DAY THIS NATION WILL RISE UP LIVE UP THE TRUE MEANING OF ITS TREES&#x27;</span>}`,wrap:!1}}),R=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIpJTBBdHJhbnNjcmliZXIoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGTmFyc2lsJTJGYXNyX2R1bW15JTJGcmVzb2x2ZSUyRm1haW4lMkZtbGsuZmxhYyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; I have a dream that one day this nation will rise up and live out the true meaning of its creed.&#x27;</span>}`,wrap:!1}}),N=new J({props:{code:"dHJhbnNjcmliZXIoJTBBJTIwJTIwJTIwJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGTmFyc2lsJTJGYXNyX2R1bW15JTJGcmVzb2x2ZSUyRm1haW4lMkZtbGsuZmxhYyUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRk5hcnNpbCUyRmFzcl9kdW1teSUyRnJlc29sdmUlMkZtYWluJTJGMS5mbGFjJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKQ==",highlighted:`transcriber(
    [
        <span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>,
        <span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac&quot;</span>,
    ]
)`,wrap:!1}}),L=new g({props:{title:"参数",local:"参数",headingTag:"h2"}}),F=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjBteV9wYXJhbWV0ZXIlM0QxKSUwQSUwQW91dCUyMCUzRCUyMHRyYW5zY3JpYmVyKC4uLiklMjAlMjAlMjMlMjBUaGlzJTIwd2lsbCUyMHVzZSUyMCU2MG15X3BhcmFtZXRlciUzRDElNjAuJTBBb3V0JTIwJTNEJTIwdHJhbnNjcmliZXIoLi4uJTJDJTIwbXlfcGFyYW1ldGVyJTNEMiklMjAlMjAlMjMlMjBUaGlzJTIwd2lsbCUyMG92ZXJyaWRlJTIwYW5kJTIwdXNlJTIwJTYwbXlfcGFyYW1ldGVyJTNEMiU2MC4lMEFvdXQlMjAlM0QlMjB0cmFuc2NyaWJlciguLi4pJTIwJTIwJTIzJTIwVGhpcyUyMHdpbGwlMjBnbyUyMGJhY2slMjB0byUyMHVzaW5nJTIwJTYwbXlfcGFyYW1ldGVyJTNEMSU2MC4=",highlighted:'transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, my_parameter=<span class="hljs-number">1</span>)\n\nout = transcriber(...)  <span class="hljs-comment"># This will use `my_parameter=1`.</span>\nout = transcriber(..., my_parameter=<span class="hljs-number">2</span>)  <span class="hljs-comment"># This will override and use `my_parameter=2`.</span>\nout = transcriber(...)  <span class="hljs-comment"># This will go back to using `my_parameter=1`.</span>',wrap:!1}}),E=new g({props:{title:"设备",local:"设备",headingTag:"h3"}}),A=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjBkZXZpY2UlM0QwKQ==",highlighted:'transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, device=<span class="hljs-number">0</span>)',wrap:!1}}),K=new J({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMGFjY2VsZXJhdGU=",highlighted:"pip install --upgrade accelerate",wrap:!1}}),ss=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMik=",highlighted:'transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)',wrap:!1}}),ls=new g({props:{title:"批量大小",local:"批量大小",headingTag:"h3"}}),ns=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjBkZXZpY2UlM0QwJTJDJTIwYmF0Y2hfc2l6ZSUzRDIpJTBBYXVkaW9fZmlsZW5hbWVzJTIwJTNEJTIwJTVCZiUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRk5hcnNpbCUyRmFzcl9kdW1teSUyRnJlc29sdmUlMkZtYWluJTJGJTdCaSU3RC5mbGFjJTIyJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMSUyQyUyMDUpJTVEJTBBdGV4dHMlMjAlM0QlMjB0cmFuc2NyaWJlcihhdWRpb19maWxlbmFtZXMp",highlighted:`transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, device=<span class="hljs-number">0</span>, batch_size=<span class="hljs-number">2</span>)
audio_filenames = [<span class="hljs-string">f&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/<span class="hljs-subst">{i}</span>.flac&quot;</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1</span>, <span class="hljs-number">5</span>)]
texts = transcriber(audio_filenames)`,wrap:!1}}),rs=new g({props:{title:"任务特定参数",local:"任务特定参数",headingTag:"h3"}}),ms=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjByZXR1cm5fdGltZXN0YW1wcyUzRFRydWUpJTBBdHJhbnNjcmliZXIoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGTmFyc2lsJTJGYXNyX2R1bW15JTJGcmVzb2x2ZSUyRm1haW4lMkZtbGsuZmxhYyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, return_timestamps=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; I have a dream that one day this nation will rise up and live out the true meaning of its creed.&#x27;</span>, <span class="hljs-string">&#x27;chunks&#x27;</span>: [{<span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">0.0</span>, <span class="hljs-number">11.88</span>), <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; I have a dream that one day this nation will rise up and live out the true meaning of its&#x27;</span>}, {<span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.88</span>, <span class="hljs-number">12.38</span>), <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; creed.&#x27;</span>}]}`,wrap:!1}}),Ms=new J({props:{code:"dHJhbnNjcmliZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haSUyRndoaXNwZXItbGFyZ2UtdjIlMjIlMkMlMjBjaHVua19sZW5ndGhfcyUzRDMwJTJDJTIwcmV0dXJuX3RpbWVzdGFtcHMlM0RUcnVlKSUwQXRyYW5zY3JpYmVyKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRnNhbmNoaXQtZ2FuZGhpJTJGbGlicmlzcGVlY2hfbG9uZyUyRnJlc29sdmUlMkZtYWluJTJGYXVkaW8ud2F2JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large-v2&quot;</span>, chunk_length_s=<span class="hljs-number">30</span>, return_timestamps=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(<span class="hljs-string">&quot;https://huggingface.co/datasets/sanchit-gandhi/librispeech_long/resolve/main/audio.wav&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&quot; Chapter 16. I might have told you of the beginning of this liaison in a few lines, but I wanted you to see every step by which we came.  I, too, agree to whatever Marguerite wished, Marguerite to be unable to live apart from me. It was the day after the evening...</span>`,wrap:!1}}),fs=new g({props:{title:"在数据集上使用pipelines",local:"在数据集上使用pipelines",headingTag:"h2"}}),Js=new J({props:{code:"ZGVmJTIwZGF0YSgpJTNBJTBBJTIwJTIwJTIwJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMTAwMCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB5aWVsZCUyMGYlMjJNeSUyMGV4YW1wbGUlMjAlN0JpJTdEJTIyJTBBJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKG1vZGVsJTNEJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIlMkMlMjBkZXZpY2UlM0QwKSUwQWdlbmVyYXRlZF9jaGFyYWN0ZXJzJTIwJTNEJTIwMCUwQWZvciUyMG91dCUyMGluJTIwcGlwZShkYXRhKCkpJTNBJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdGVkX2NoYXJhY3RlcnMlMjAlMkIlM0QlMjBsZW4ob3V0JTVCMCU1RCU1QiUyMmdlbmVyYXRlZF90ZXh0JTIyJTVEKQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">data</span>():
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>):
        <span class="hljs-keyword">yield</span> <span class="hljs-string">f&quot;My example <span class="hljs-subst">{i}</span>&quot;</span>


pipe = pipeline(model=<span class="hljs-string">&quot;openai-community/gpt2&quot;</span>, device=<span class="hljs-number">0</span>)
generated_characters = <span class="hljs-number">0</span>
<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipe(data()):
    generated_characters += <span class="hljs-built_in">len</span>(out[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;generated_text&quot;</span>])`,wrap:!1}}),ws=new J({props:{code:"JTIzJTIwS2V5RGF0YXNldCUyMGlzJTIwYSUyMHV0aWwlMjB0aGF0JTIwd2lsbCUyMGp1c3QlMjBvdXRwdXQlMjB0aGUlMjBpdGVtJTIwd2UncmUlMjBpbnRlcmVzdGVkJTIwaW4uJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5waXBlbGluZXMucHRfdXRpbHMlMjBpbXBvcnQlMjBLZXlEYXRhc2V0JTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKG1vZGVsJTNEJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRnRpbnktcmFuZG9tLXdhdjJ2ZWMyJTIyJTJDJTIwZGV2aWNlJTNEMCklMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmhmLWludGVybmFsLXRlc3RpbmclMkZsaWJyaXNwZWVjaF9hc3JfZHVtbXklMjIlMkMlMjAlMjJjbGVhbiUyMiUyQyUyMHNwbGl0JTNEJTIydmFsaWRhdGlvbiU1QiUzQTEwJTVEJTIyKSUwQSUwQWZvciUyMG91dCUyMGluJTIwcGlwZShLZXlEYXRhc2V0KGRhdGFzZXQlMkMlMjAlMjJhdWRpbyUyMikpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQob3V0KQ==",highlighted:`<span class="hljs-comment"># KeyDataset is a util that will just output the item we&#x27;re interested in.</span>
<span class="hljs-keyword">from</span> transformers.pipelines.pt_utils <span class="hljs-keyword">import</span> KeyDataset
<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

pipe = pipeline(model=<span class="hljs-string">&quot;hf-internal-testing/tiny-random-wav2vec2&quot;</span>, device=<span class="hljs-number">0</span>)
dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/librispeech_asr_dummy&quot;</span>, <span class="hljs-string">&quot;clean&quot;</span>, split=<span class="hljs-string">&quot;validation[:10]&quot;</span>)

<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipe(KeyDataset(dataset, <span class="hljs-string">&quot;audio&quot;</span>)):
    <span class="hljs-built_in">print</span>(out)`,wrap:!1}}),gs=new g({props:{title:"在Web服务器上使用pipelines",local:"在web服务器上使用pipelines",headingTag:"h2"}}),I=new Ml({props:{$$slots:{default:[jt]},$$scope:{ctx:$}}}),$s=new g({props:{title:"视觉流水线",local:"视觉流水线",headingTag:"h2"}}),vs=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdmlzaW9uX2NsYXNzaWZpZXIlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0JTIyKSUwQXByZWRzJTIwJTNEJTIwdmlzaW9uX2NsYXNzaWZpZXIoJTBBJTIwJTIwJTIwJTIwaW1hZ2VzJTNEJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGcGlwZWxpbmUtY2F0LWNob25rLmpwZWclMjIlMEEpJTBBcHJlZHMlMjAlM0QlMjAlNUIlN0IlMjJzY29yZSUyMiUzQSUyMHJvdW5kKHByZWQlNUIlMjJzY29yZSUyMiU1RCUyQyUyMDQpJTJDJTIwJTIybGFiZWwlMjIlM0ElMjBwcmVkJTVCJTIybGFiZWwlMjIlNUQlN0QlMjBmb3IlMjBwcmVkJTIwaW4lMjBwcmVkcyU1RCUwQXByZWRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>vision_classifier = pipeline(model=<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = vision_classifier(
<span class="hljs-meta">... </span>    images=<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = [{<span class="hljs-string">&quot;score&quot;</span>: <span class="hljs-built_in">round</span>(pred[<span class="hljs-string">&quot;score&quot;</span>], <span class="hljs-number">4</span>), <span class="hljs-string">&quot;label&quot;</span>: pred[<span class="hljs-string">&quot;label&quot;</span>]} <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
<span class="hljs-meta">&gt;&gt;&gt; </span>preds
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.4335</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;lynx, catamount&#x27;</span>}, {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0348</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cougar, puma, catamount, mountain lion, painter, panther, Felis concolor&#x27;</span>}, {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0324</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;snow leopard, ounce, Panthera uncia&#x27;</span>}, {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0239</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;Egyptian cat&#x27;</span>}, {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0229</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;tiger cat&#x27;</span>}]`,wrap:!1}}),Gs=new g({props:{title:"文本流水线",local:"文本流水线",headingTag:"h2"}}),xs=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTIzJTIwVGhpcyUyMG1vZGVsJTIwaXMlMjBhJTIwJTYwemVyby1zaG90LWNsYXNzaWZpY2F0aW9uJTYwJTIwbW9kZWwuJTBBJTIzJTIwSXQlMjB3aWxsJTIwY2xhc3NpZnklMjB0ZXh0JTJDJTIwZXhjZXB0JTIweW91JTIwYXJlJTIwZnJlZSUyMHRvJTIwY2hvb3NlJTIwYW55JTIwbGFiZWwlMjB5b3UlMjBtaWdodCUyMGltYWdpbmUlMEFjbGFzc2lmaWVyJTIwJTNEJTIwcGlwZWxpbmUobW9kZWwlM0QlMjJmYWNlYm9vayUyRmJhcnQtbGFyZ2UtbW5saSUyMiklMEFjbGFzc2lmaWVyKCUwQSUyMCUyMCUyMCUyMCUyMkklMjBoYXZlJTIwYSUyMHByb2JsZW0lMjB3aXRoJTIwbXklMjBpcGhvbmUlMjB0aGF0JTIwbmVlZHMlMjB0byUyMGJlJTIwcmVzb2x2ZWQlMjBhc2FwISElMjIlMkMlMEElMjAlMjAlMjAlMjBjYW5kaWRhdGVfbGFiZWxzJTNEJTVCJTIydXJnZW50JTIyJTJDJTIwJTIybm90JTIwdXJnZW50JTIyJTJDJTIwJTIycGhvbmUlMjIlMkMlMjAlMjJ0YWJsZXQlMjIlMkMlMjAlMjJjb21wdXRlciUyMiU1RCUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># This model is a \`zero-shot-classification\` model.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># It will classify text, except you are free to choose any label you might imagine</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(model=<span class="hljs-string">&quot;facebook/bart-large-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I have a problem with my iphone that needs to be resolved asap!!&quot;</span>,
<span class="hljs-meta">... </span>    candidate_labels=[<span class="hljs-string">&quot;urgent&quot;</span>, <span class="hljs-string">&quot;not urgent&quot;</span>, <span class="hljs-string">&quot;phone&quot;</span>, <span class="hljs-string">&quot;tablet&quot;</span>, <span class="hljs-string">&quot;computer&quot;</span>],
<span class="hljs-meta">... </span>)
{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;I have a problem with my iphone that needs to be resolved asap!!&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>: [<span class="hljs-string">&#x27;urgent&#x27;</span>, <span class="hljs-string">&#x27;phone&#x27;</span>, <span class="hljs-string">&#x27;computer&#x27;</span>, <span class="hljs-string">&#x27;not urgent&#x27;</span>, <span class="hljs-string">&#x27;tablet&#x27;</span>], <span class="hljs-string">&#x27;scores&#x27;</span>: [<span class="hljs-number">0.504</span>, <span class="hljs-number">0.479</span>, <span class="hljs-number">0.013</span>, <span class="hljs-number">0.003</span>, <span class="hljs-number">0.002</span>]}`,wrap:!1}}),ks=new g({props:{title:"多模态流水线",local:"多模态流水线",headingTag:"h2"}}),Xs=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdnFhJTIwJTNEJTIwcGlwZWxpbmUobW9kZWwlM0QlMjJpbXBpcmElMkZsYXlvdXRsbS1kb2N1bWVudC1xYSUyMiklMEFvdXRwdXQlMjAlM0QlMjB2cWEoJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0QlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGc3BhY2VzJTJGaW1waXJhJTJGZG9jcXVlcnklMkZyZXNvbHZlJTJGMjM1OTIyM2MxODM3YTc1ODc0MDJiZGEwZjI2NDMzODJhNmVlZmVhYiUyRmludm9pY2UucG5nJTIyJTJDJTBBJTIwJTIwJTIwJTIwcXVlc3Rpb24lM0QlMjJXaGF0JTIwaXMlMjB0aGUlMjBpbnZvaWNlJTIwbnVtYmVyJTNGJTIyJTJDJTBBKSUwQW91dHB1dCU1QjAlNUQlNUIlMjJzY29yZSUyMiU1RCUyMCUzRCUyMHJvdW5kKG91dHB1dCU1QjAlNUQlNUIlMjJzY29yZSUyMiU1RCUyQyUyMDMpJTBBb3V0cHV0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>vqa = pipeline(model=<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>output = vqa(
<span class="hljs-meta">... </span>    image=<span class="hljs-string">&quot;https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png&quot;</span>,
<span class="hljs-meta">... </span>    question=<span class="hljs-string">&quot;What is the invoice number?&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>output[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;score&quot;</span>] = <span class="hljs-built_in">round</span>(output[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;score&quot;</span>], <span class="hljs-number">3</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>output
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.425</span>, <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;us-001&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">16</span>}]`,wrap:!1}}),v=new Ml({props:{$$slots:{default:[Jt]},$$scope:{ctx:$}}}),Hs=new g({props:{title:"在大模型上使用🤗 accelerate 和 pipeline ：",local:"在大模型上使用-accelerate-和-pipeline-",headingTag:"h2"}}),Vs=new J({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMGFjY2VsZXJhdGUlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBwaXBlbGluZSUwQSUwQXBpcGUlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMmZhY2Vib29rJTJGb3B0LTEuM2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBb3V0cHV0JTIwJTNEJTIwcGlwZSglMjJUaGlzJTIwaXMlMjBhJTIwY29vbCUyMGV4YW1wbGUhJTIyJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRvcF9wJTNEMC45NSk=",highlighted:`<span class="hljs-comment"># pip install accelerate</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(model=<span class="hljs-string">&quot;facebook/opt-1.3b&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
output = pipe(<span class="hljs-string">&quot;This is a cool example!&quot;</span>, do_sample=<span class="hljs-literal">True</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),Ns=new J({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMGFjY2VsZXJhdGUlMjBiaXRzYW5kYnl0ZXMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBwaXBlbGluZSUwQSUwQXBpcGUlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMmZhY2Vib29rJTJGb3B0LTEuM2IlMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiUyQyUyMG1vZGVsX2t3YXJncyUzRCU3QiUyMmxvYWRfaW5fOGJpdCUyMiUzQSUyMFRydWUlN0QpJTBBb3V0cHV0JTIwJTNEJTIwcGlwZSglMjJUaGlzJTIwaXMlMjBhJTIwY29vbCUyMGV4YW1wbGUhJTIyJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRvcF9wJTNEMC45NSk=",highlighted:`<span class="hljs-comment"># pip install accelerate bitsandbytes</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(model=<span class="hljs-string">&quot;facebook/opt-1.3b&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, model_kwargs={<span class="hljs-string">&quot;load_in_8bit&quot;</span>: <span class="hljs-literal">True</span>})
output = pipe(<span class="hljs-string">&quot;This is a cool example!&quot;</span>, do_sample=<span class="hljs-literal">True</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),qs=new ut({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/pipeline_tutorial.md"}}),{c(){f=p("meta"),y=a(),T=p("p"),d=a(),c(w.$$.fragment),j=a(),b=p("p"),b.innerHTML=ul,Ss=a(),G=p("ul"),G.innerHTML=fl,Fs=a(),c(U.$$.fragment),Qs=a(),c(B.$$.fragment),Es=a(),x=p("p"),x.innerHTML=jl,Ps=a(),k=p("ol"),k.innerHTML=Jl,As=a(),c(W.$$.fragment),Ds=a(),Z=p("ol"),Z.innerHTML=Tl,Ks=a(),c(_.$$.fragment),Os=a(),X=p("p"),X.innerHTML=yl,se=a(),H=p("p"),H.innerHTML=dl,ee=a(),C=p("p"),C.textContent=wl,le=a(),c(R.$$.fragment),te=a(),V=p("p"),V.innerHTML=gl,ae=a(),Y=p("p"),Y.textContent=bl,ne=a(),c(N.$$.fragment),pe=a(),z=p("p"),z.innerHTML=$l,ie=a(),q=p("ul"),q.innerHTML=Ul,re=a(),c(L.$$.fragment),ce=a(),S=p("p"),S.innerHTML=Zl,me=a(),c(F.$$.fragment),he=a(),Q=p("p"),Q.textContent=Il,oe=a(),c(E.$$.fragment),Me=a(),P=p("p"),P.innerHTML=vl,ue=a(),c(A.$$.fragment),fe=a(),D=p("p"),D.innerHTML=Gl,je=a(),c(K.$$.fragment),Je=a(),O=p("p"),O.textContent=Bl,Te=a(),c(ss.$$.fragment),ye=a(),es=p("p"),es.innerHTML=xl,de=a(),c(ls.$$.fragment),we=a(),ts=p("p"),ts.innerHTML=kl,ge=a(),as=p("p"),as.textContent=Wl,be=a(),c(ns.$$.fragment),$e=a(),ps=p("p"),ps.innerHTML=_l,Ue=a(),is=p("p"),is.innerHTML=Xl,Ze=a(),c(rs.$$.fragment),Ie=a(),cs=p("p"),cs.innerHTML=Hl,ve=a(),c(ms.$$.fragment),Ge=a(),hs=p("p"),hs.innerHTML=Cl,Be=a(),os=p("p"),os.innerHTML=Rl,xe=a(),c(Ms.$$.fragment),ke=a(),us=p("p"),us.innerHTML=Vl,We=a(),c(fs.$$.fragment),_e=a(),js=p("p"),js.innerHTML=Yl,Xe=a(),c(Js.$$.fragment),He=a(),Ts=p("p"),Ts.innerHTML=Nl,Ce=a(),ys=p("p"),ys.innerHTML=zl,Re=a(),ds=p("p"),ds.innerHTML=ql,Ve=a(),c(ws.$$.fragment),Ye=a(),c(gs.$$.fragment),Ne=a(),c(I.$$.fragment),ze=a(),bs=p("p"),bs.innerHTML=Ll,qe=a(),c($s.$$.fragment),Le=a(),Us=p("p"),Us.innerHTML=Sl,Se=a(),Zs=p("p"),Zs.textContent=Fl,Fe=a(),Is=p("p"),Is.innerHTML=Ql,Qe=a(),c(vs.$$.fragment),Ee=a(),c(Gs.$$.fragment),Pe=a(),Bs=p("p"),Bs.innerHTML=El,Ae=a(),c(xs.$$.fragment),De=a(),c(ks.$$.fragment),Ke=a(),Ws=p("p"),Ws.innerHTML=Pl,Oe=a(),_s=p("p"),_s.innerHTML=Al,sl=a(),c(Xs.$$.fragment),el=a(),c(v.$$.fragment),ll=a(),c(Hs.$$.fragment),tl=a(),Cs=p("p"),Cs.innerHTML=Dl,al=a(),Rs=p("p"),Rs.innerHTML=Kl,nl=a(),c(Vs.$$.fragment),pl=a(),Ys=p("p"),Ys.innerHTML=Ol,il=a(),c(Ns.$$.fragment),rl=a(),zs=p("p"),zs.innerHTML=st,cl=a(),c(qs.$$.fragment),ml=a(),Ls=p("p"),this.h()},l(s){const e=mt("svelte-u9bgzb",document.head);f=i(e,"META",{name:!0,content:!0}),e.forEach(l),y=n(s),T=i(s,"P",{}),at(T).forEach(l),d=n(s),m(w.$$.fragment,s),j=n(s),b=i(s,"P",{"data-svelte-h":!0}),r(b)!=="svelte-e9v82j"&&(b.innerHTML=ul),Ss=n(s),G=i(s,"UL",{"data-svelte-h":!0}),r(G)!=="svelte-1xskegw"&&(G.innerHTML=fl),Fs=n(s),m(U.$$.fragment,s),Qs=n(s),m(B.$$.fragment,s),Es=n(s),x=i(s,"P",{"data-svelte-h":!0}),r(x)!=="svelte-hvx3pu"&&(x.innerHTML=jl),Ps=n(s),k=i(s,"OL",{"data-svelte-h":!0}),r(k)!=="svelte-1x1vmgb"&&(k.innerHTML=Jl),As=n(s),m(W.$$.fragment,s),Ds=n(s),Z=i(s,"OL",{start:!0,"data-svelte-h":!0}),r(Z)!=="svelte-1mpj6i8"&&(Z.innerHTML=Tl),Ks=n(s),m(_.$$.fragment,s),Os=n(s),X=i(s,"P",{"data-svelte-h":!0}),r(X)!=="svelte-wuyqla"&&(X.innerHTML=yl),se=n(s),H=i(s,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1og2a64"&&(H.innerHTML=dl),ee=n(s),C=i(s,"P",{"data-svelte-h":!0}),r(C)!=="svelte-y6rqea"&&(C.textContent=wl),le=n(s),m(R.$$.fragment,s),te=n(s),V=i(s,"P",{"data-svelte-h":!0}),r(V)!=="svelte-7v8a2b"&&(V.innerHTML=gl),ae=n(s),Y=i(s,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1hufjes"&&(Y.textContent=bl),ne=n(s),m(N.$$.fragment,s),pe=n(s),z=i(s,"P",{"data-svelte-h":!0}),r(z)!=="svelte-cjxg4p"&&(z.innerHTML=$l),ie=n(s),q=i(s,"UL",{"data-svelte-h":!0}),r(q)!=="svelte-r6yb7c"&&(q.innerHTML=Ul),re=n(s),m(L.$$.fragment,s),ce=n(s),S=i(s,"P",{"data-svelte-h":!0}),r(S)!=="svelte-k00dkn"&&(S.innerHTML=Zl),me=n(s),m(F.$$.fragment,s),he=n(s),Q=i(s,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-u8ryko"&&(Q.textContent=Il),oe=n(s),m(E.$$.fragment,s),Me=n(s),P=i(s,"P",{"data-svelte-h":!0}),r(P)!=="svelte-idsrr1"&&(P.innerHTML=vl),ue=n(s),m(A.$$.fragment,s),fe=n(s),D=i(s,"P",{"data-svelte-h":!0}),r(D)!=="svelte-1658hsh"&&(D.innerHTML=Gl),je=n(s),m(K.$$.fragment,s),Je=n(s),O=i(s,"P",{"data-svelte-h":!0}),r(O)!=="svelte-ftwjlg"&&(O.textContent=Bl),Te=n(s),m(ss.$$.fragment,s),ye=n(s),es=i(s,"P",{"data-svelte-h":!0}),r(es)!=="svelte-15xcnf9"&&(es.innerHTML=xl),de=n(s),m(ls.$$.fragment,s),we=n(s),ts=i(s,"P",{"data-svelte-h":!0}),r(ts)!=="svelte-lwvdk2"&&(ts.innerHTML=kl),ge=n(s),as=i(s,"P",{"data-svelte-h":!0}),r(as)!=="svelte-1ht982g"&&(as.textContent=Wl),be=n(s),m(ns.$$.fragment,s),$e=n(s),ps=i(s,"P",{"data-svelte-h":!0}),r(ps)!=="svelte-occjw6"&&(ps.innerHTML=_l),Ue=n(s),is=i(s,"P",{"data-svelte-h":!0}),r(is)!=="svelte-1aawhlf"&&(is.innerHTML=Xl),Ze=n(s),m(rs.$$.fragment,s),Ie=n(s),cs=i(s,"P",{"data-svelte-h":!0}),r(cs)!=="svelte-1klq38f"&&(cs.innerHTML=Hl),ve=n(s),m(ms.$$.fragment,s),Ge=n(s),hs=i(s,"P",{"data-svelte-h":!0}),r(hs)!=="svelte-118drgt"&&(hs.innerHTML=Cl),Be=n(s),os=i(s,"P",{"data-svelte-h":!0}),r(os)!=="svelte-1svwulj"&&(os.innerHTML=Rl),xe=n(s),m(Ms.$$.fragment,s),ke=n(s),us=i(s,"P",{"data-svelte-h":!0}),r(us)!=="svelte-o57d00"&&(us.innerHTML=Vl),We=n(s),m(fs.$$.fragment,s),_e=n(s),js=i(s,"P",{"data-svelte-h":!0}),r(js)!=="svelte-3vy3oi"&&(js.innerHTML=Yl),Xe=n(s),m(Js.$$.fragment,s),He=n(s),Ts=i(s,"P",{"data-svelte-h":!0}),r(Ts)!=="svelte-ug61kl"&&(Ts.innerHTML=Nl),Ce=n(s),ys=i(s,"P",{"data-svelte-h":!0}),r(ys)!=="svelte-ty0yyf"&&(ys.innerHTML=zl),Re=n(s),ds=i(s,"P",{"data-svelte-h":!0}),r(ds)!=="svelte-1hgrt8v"&&(ds.innerHTML=ql),Ve=n(s),m(ws.$$.fragment,s),Ye=n(s),m(gs.$$.fragment,s),Ne=n(s),m(I.$$.fragment,s),ze=n(s),bs=i(s,"P",{"data-svelte-h":!0}),r(bs)!=="svelte-1lz0h23"&&(bs.innerHTML=Ll),qe=n(s),m($s.$$.fragment,s),Le=n(s),Us=i(s,"P",{"data-svelte-h":!0}),r(Us)!=="svelte-weev4k"&&(Us.innerHTML=Sl),Se=n(s),Zs=i(s,"P",{"data-svelte-h":!0}),r(Zs)!=="svelte-h0nzrm"&&(Zs.textContent=Fl),Fe=n(s),Is=i(s,"P",{"data-svelte-h":!0}),r(Is)!=="svelte-1bks2jw"&&(Is.innerHTML=Ql),Qe=n(s),m(vs.$$.fragment,s),Ee=n(s),m(Gs.$$.fragment,s),Pe=n(s),Bs=i(s,"P",{"data-svelte-h":!0}),r(Bs)!=="svelte-129isu1"&&(Bs.innerHTML=El),Ae=n(s),m(xs.$$.fragment,s),De=n(s),m(ks.$$.fragment,s),Ke=n(s),Ws=i(s,"P",{"data-svelte-h":!0}),r(Ws)!=="svelte-ohn46o"&&(Ws.innerHTML=Pl),Oe=n(s),_s=i(s,"P",{"data-svelte-h":!0}),r(_s)!=="svelte-13a1pna"&&(_s.innerHTML=Al),sl=n(s),m(Xs.$$.fragment,s),el=n(s),m(v.$$.fragment,s),ll=n(s),m(Hs.$$.fragment,s),tl=n(s),Cs=i(s,"P",{"data-svelte-h":!0}),r(Cs)!=="svelte-2liy51"&&(Cs.innerHTML=Dl),al=n(s),Rs=i(s,"P",{"data-svelte-h":!0}),r(Rs)!=="svelte-15lp4hn"&&(Rs.innerHTML=Kl),nl=n(s),m(Vs.$$.fragment,s),pl=n(s),Ys=i(s,"P",{"data-svelte-h":!0}),r(Ys)!=="svelte-5lgja0"&&(Ys.innerHTML=Ol),il=n(s),m(Ns.$$.fragment,s),rl=n(s),zs=i(s,"P",{"data-svelte-h":!0}),r(zs)!=="svelte-y7nde"&&(zs.innerHTML=st),cl=n(s),m(qs.$$.fragment,s),ml=n(s),Ls=i(s,"P",{}),at(Ls).forEach(l),this.h()},h(){ol(f,"name","hf:doc:metadata"),ol(f,"content",yt),ol(Z,"start","2")},m(s,e){ht(document.head,f),t(s,y,e),t(s,T,e),t(s,d,e),h(w,s,e),t(s,j,e),t(s,b,e),t(s,Ss,e),t(s,G,e),t(s,Fs,e),h(U,s,e),t(s,Qs,e),h(B,s,e),t(s,Es,e),t(s,x,e),t(s,Ps,e),t(s,k,e),t(s,As,e),h(W,s,e),t(s,Ds,e),t(s,Z,e),t(s,Ks,e),h(_,s,e),t(s,Os,e),t(s,X,e),t(s,se,e),t(s,H,e),t(s,ee,e),t(s,C,e),t(s,le,e),h(R,s,e),t(s,te,e),t(s,V,e),t(s,ae,e),t(s,Y,e),t(s,ne,e),h(N,s,e),t(s,pe,e),t(s,z,e),t(s,ie,e),t(s,q,e),t(s,re,e),h(L,s,e),t(s,ce,e),t(s,S,e),t(s,me,e),h(F,s,e),t(s,he,e),t(s,Q,e),t(s,oe,e),h(E,s,e),t(s,Me,e),t(s,P,e),t(s,ue,e),h(A,s,e),t(s,fe,e),t(s,D,e),t(s,je,e),h(K,s,e),t(s,Je,e),t(s,O,e),t(s,Te,e),h(ss,s,e),t(s,ye,e),t(s,es,e),t(s,de,e),h(ls,s,e),t(s,we,e),t(s,ts,e),t(s,ge,e),t(s,as,e),t(s,be,e),h(ns,s,e),t(s,$e,e),t(s,ps,e),t(s,Ue,e),t(s,is,e),t(s,Ze,e),h(rs,s,e),t(s,Ie,e),t(s,cs,e),t(s,ve,e),h(ms,s,e),t(s,Ge,e),t(s,hs,e),t(s,Be,e),t(s,os,e),t(s,xe,e),h(Ms,s,e),t(s,ke,e),t(s,us,e),t(s,We,e),h(fs,s,e),t(s,_e,e),t(s,js,e),t(s,Xe,e),h(Js,s,e),t(s,He,e),t(s,Ts,e),t(s,Ce,e),t(s,ys,e),t(s,Re,e),t(s,ds,e),t(s,Ve,e),h(ws,s,e),t(s,Ye,e),h(gs,s,e),t(s,Ne,e),h(I,s,e),t(s,ze,e),t(s,bs,e),t(s,qe,e),h($s,s,e),t(s,Le,e),t(s,Us,e),t(s,Se,e),t(s,Zs,e),t(s,Fe,e),t(s,Is,e),t(s,Qe,e),h(vs,s,e),t(s,Ee,e),h(Gs,s,e),t(s,Pe,e),t(s,Bs,e),t(s,Ae,e),h(xs,s,e),t(s,De,e),h(ks,s,e),t(s,Ke,e),t(s,Ws,e),t(s,Oe,e),t(s,_s,e),t(s,sl,e),h(Xs,s,e),t(s,el,e),h(v,s,e),t(s,ll,e),h(Hs,s,e),t(s,tl,e),t(s,Cs,e),t(s,al,e),t(s,Rs,e),t(s,nl,e),h(Vs,s,e),t(s,pl,e),t(s,Ys,e),t(s,il,e),h(Ns,s,e),t(s,rl,e),t(s,zs,e),t(s,cl,e),h(qs,s,e),t(s,ml,e),t(s,Ls,e),hl=!0},p(s,[e]){const et={};e&2&&(et.$$scope={dirty:e,ctx:s}),U.$set(et);const lt={};e&2&&(lt.$$scope={dirty:e,ctx:s}),I.$set(lt);const tt={};e&2&&(tt.$$scope={dirty:e,ctx:s}),v.$set(tt)},i(s){hl||(o(w.$$.fragment,s),o(U.$$.fragment,s),o(B.$$.fragment,s),o(W.$$.fragment,s),o(_.$$.fragment,s),o(R.$$.fragment,s),o(N.$$.fragment,s),o(L.$$.fragment,s),o(F.$$.fragment,s),o(E.$$.fragment,s),o(A.$$.fragment,s),o(K.$$.fragment,s),o(ss.$$.fragment,s),o(ls.$$.fragment,s),o(ns.$$.fragment,s),o(rs.$$.fragment,s),o(ms.$$.fragment,s),o(Ms.$$.fragment,s),o(fs.$$.fragment,s),o(Js.$$.fragment,s),o(ws.$$.fragment,s),o(gs.$$.fragment,s),o(I.$$.fragment,s),o($s.$$.fragment,s),o(vs.$$.fragment,s),o(Gs.$$.fragment,s),o(xs.$$.fragment,s),o(ks.$$.fragment,s),o(Xs.$$.fragment,s),o(v.$$.fragment,s),o(Hs.$$.fragment,s),o(Vs.$$.fragment,s),o(Ns.$$.fragment,s),o(qs.$$.fragment,s),hl=!0)},o(s){M(w.$$.fragment,s),M(U.$$.fragment,s),M(B.$$.fragment,s),M(W.$$.fragment,s),M(_.$$.fragment,s),M(R.$$.fragment,s),M(N.$$.fragment,s),M(L.$$.fragment,s),M(F.$$.fragment,s),M(E.$$.fragment,s),M(A.$$.fragment,s),M(K.$$.fragment,s),M(ss.$$.fragment,s),M(ls.$$.fragment,s),M(ns.$$.fragment,s),M(rs.$$.fragment,s),M(ms.$$.fragment,s),M(Ms.$$.fragment,s),M(fs.$$.fragment,s),M(Js.$$.fragment,s),M(ws.$$.fragment,s),M(gs.$$.fragment,s),M(I.$$.fragment,s),M($s.$$.fragment,s),M(vs.$$.fragment,s),M(Gs.$$.fragment,s),M(xs.$$.fragment,s),M(ks.$$.fragment,s),M(Xs.$$.fragment,s),M(v.$$.fragment,s),M(Hs.$$.fragment,s),M(Vs.$$.fragment,s),M(Ns.$$.fragment,s),M(qs.$$.fragment,s),hl=!1},d(s){s&&(l(y),l(T),l(d),l(j),l(b),l(Ss),l(G),l(Fs),l(Qs),l(Es),l(x),l(Ps),l(k),l(As),l(Ds),l(Z),l(Ks),l(Os),l(X),l(se),l(H),l(ee),l(C),l(le),l(te),l(V),l(ae),l(Y),l(ne),l(pe),l(z),l(ie),l(q),l(re),l(ce),l(S),l(me),l(he),l(Q),l(oe),l(Me),l(P),l(ue),l(fe),l(D),l(je),l(Je),l(O),l(Te),l(ye),l(es),l(de),l(we),l(ts),l(ge),l(as),l(be),l($e),l(ps),l(Ue),l(is),l(Ze),l(Ie),l(cs),l(ve),l(Ge),l(hs),l(Be),l(os),l(xe),l(ke),l(us),l(We),l(_e),l(js),l(Xe),l(He),l(Ts),l(Ce),l(ys),l(Re),l(ds),l(Ve),l(Ye),l(Ne),l(ze),l(bs),l(qe),l(Le),l(Us),l(Se),l(Zs),l(Fe),l(Is),l(Qe),l(Ee),l(Pe),l(Bs),l(Ae),l(De),l(Ke),l(Ws),l(Oe),l(_s),l(sl),l(el),l(ll),l(tl),l(Cs),l(al),l(Rs),l(nl),l(pl),l(Ys),l(il),l(rl),l(zs),l(cl),l(ml),l(Ls)),l(f),u(w,s),u(U,s),u(B,s),u(W,s),u(_,s),u(R,s),u(N,s),u(L,s),u(F,s),u(E,s),u(A,s),u(K,s),u(ss,s),u(ls,s),u(ns,s),u(rs,s),u(ms,s),u(Ms,s),u(fs,s),u(Js,s),u(ws,s),u(gs,s),u(I,s),u($s,s),u(vs,s),u(Gs,s),u(xs,s),u(ks,s),u(Xs,s),u(v,s),u(Hs,s),u(Vs,s),u(Ns,s),u(qs,s)}}}const yt='{"title":"推理pipeline","local":"推理pipeline","sections":[{"title":"Pipeline使用","local":"pipeline使用","sections":[],"depth":2},{"title":"参数","local":"参数","sections":[{"title":"设备","local":"设备","sections":[],"depth":3},{"title":"批量大小","local":"批量大小","sections":[],"depth":3},{"title":"任务特定参数","local":"任务特定参数","sections":[],"depth":3}],"depth":2},{"title":"在数据集上使用pipelines","local":"在数据集上使用pipelines","sections":[],"depth":2},{"title":"在Web服务器上使用pipelines","local":"在web服务器上使用pipelines","sections":[],"depth":2},{"title":"视觉流水线","local":"视觉流水线","sections":[],"depth":2},{"title":"文本流水线","local":"文本流水线","sections":[],"depth":2},{"title":"多模态流水线","local":"多模态流水线","sections":[],"depth":2},{"title":"在大模型上使用🤗 accelerate 和 pipeline ：","local":"在大模型上使用-accelerate-和-pipeline-","sections":[],"depth":2}],"depth":1}';function dt($){return it(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zt extends rt{constructor(f){super(),ct(this,f,dt,Tt,pt,{})}}export{Zt as component};
