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