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