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