import{s as pl,o as rl,n as C}from"../chunks/scheduler.01eeda35.js";import{S as ol,i as cl,g as U,s as c,r as h,A as Ml,h as w,f as t,c as M,j as al,u as J,x as b,k as nl,y as ml,a,v as u,d as f,t as j,w as T}from"../chunks/index.6dd51b66.js";import{T as il}from"../chunks/Tip.de9bae2b.js";import{Y as yl}from"../chunks/Youtube.d6471f07.js";import{C as $}from"../chunks/CodeBlock.19ec9b8c.js";import{H as k,E as dl}from"../chunks/index.58fe8f9d.js";import{H as Zs,a as R}from"../chunks/HfOption.f7f04550.js";function hl(G){let l,m;return l=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIyc3VtbWFyaXphdGlvbiUyMiUyQyUyMG1vZGVsJTNEJTIyZ29vZ2xlJTJGcGVnYXN1cy1iaWxsc3VtJTIyKSUwQXBpcGVsaW5lKCUyMlNlY3Rpb24lMjB3YXMlMjBmb3JtZXJseSUyMHNldCUyMG91dCUyMGFzJTIwc2VjdGlvbiUyMDQ0JTIwb2YlMjB0aGlzJTIwdGl0bGUuJTIwQXMlMjBvcmlnaW5hbGx5JTIwZW5hY3RlZCUyQyUyMHRoaXMlMjBzZWN0aW9uJTIwY29udGFpbmVkJTIwdHdvJTIwZnVydGhlciUyMHByb3Zpc2lvbnMlMjB0aGF0JTIwJ25vdGhpbmclMjBpbiUyMHRoaXMlMjBhY3QlMjBzaGFsbCUyMGJlJTIwY29uc3RydWVkJTIwYXMlMjBpbiUyMGFueSUyMHdpc2UlMjBhZmZlY3RpbmclMjB0aGUlMjBncmFudCUyMG9mJTIwbGFuZHMlMjBtYWRlJTIwdG8lMjB0aGUlMjBTdGF0ZSUyMG9mJTIwQ2FsaWZvcm5pYSUyMGJ5JTIwdmlydHVlJTIwb2YlMjB0aGUlMjBhY3QlMjBlbnRpdGxlZCUyMCdBbiUyMGFjdCUyMGF1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bW1hcnlfdGV4dCclM0ElMjAnSW5zdHJ1Y3RzJTIwdGhlJTIwU2VjcmV0YXJ5JTIwb2YlMjB0aGUlMjBJbnRlcmlvciUyMHRvJTIwY29udmV5JTIwdG8lMjB0aGUlMjBTdGF0ZSUyMG9mJTIwQ2FsaWZvcm5pYSUyMGFsbCUyMHJpZ2h0JTJDJTIwdGl0bGUlMkMlMjBhbmQlMjBpbnRlcmVzdCUyMG9mJTIwdGhlJTIwVW5pdGVkJTIwU3RhdGVzJTIwaW4lMjBhbmQlMjB0byUyMHNwZWNpZmllZCUyMGxhbmRzJTIwd2hpY2glMjBhcmUlMjBsb2NhdGVkJTIwd2l0aGluJTIwdGhlJTIwWW9zZW1pdGUlMjBhbmQlMjBNYXJpcG9zYSUyME5hdGlvbmFsJTIwRm9yZXN0cyUyQyUyMENhbGlmb3JuaWEuJyU3RCU1RA==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;summarization&quot;</span>, model=<span class="hljs-string">&quot;google/pegasus-billsum&quot;</span>)
pipeline(<span class="hljs-string">&quot;Section was formerly set out as section 44 of this title. As originally enacted, this section contained two further provisions that &#x27;nothing in this act shall be construed as in any wise affecting the grant of lands made to the State of California by virtue of the act entitled &#x27;An act authorizing a grant to the State of California of the Yosemite Valley, and of the land&#x27; embracing the Mariposa Big-Tree Grove, approved June thirtieth, eighteen hundred and sixty-four; or as affecting any bona-fide entry of land made within the limits above described under any law of the United States prior to the approval of this act.&#x27; The first quoted provision was omitted from the Code because the land, granted to the state of California pursuant to the Act cite, was receded to the United States. Resolution June 11, 1906, No. 27, accepted the recession.&quot;</span>)
[{<span class="hljs-string">&#x27;summary_text&#x27;</span>: <span class="hljs-string">&#x27;Instructs the Secretary of the Interior to convey to the State of California all right, title, and interest of the United States in and to specified lands which are located within the Yosemite and Mariposa National Forests, California.&#x27;</span>}]`,wrap:!1}}),{c(){h(l.$$.fragment)},l(n){J(l.$$.fragment,n)},m(n,r){u(l,n,r),m=!0},p:C,i(n){m||(f(l.$$.fragment,n),m=!0)},o(n){j(l.$$.fragment,n),m=!1},d(n){T(l,n)}}}function Jl(G){let l,m;return l=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIyYXV0b21hdGljLXNwZWVjaC1yZWNvZ25pdGlvbiUyMiUyQyUyMG1vZGVsJTNEJTIyb3BlbmFpJTJGd2hpc3Blci1sYXJnZS12MyUyMiklMEFwaXBlbGluZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZOYXJzaWwlMkZhc3JfZHVtbXklMkZyZXNvbHZlJTJGbWFpbiUyRm1say5mbGFjJTIyKSUwQSU3Qid0ZXh0JyUzQSUyMCclMjBJJTIwaGF2ZSUyMGElMjBkcmVhbSUyMHRoYXQlMjBvbmUlMjBkYXklMjB0aGlzJTIwbmF0aW9uJTIwd2lsbCUyMHJpc2UlMjB1cCUyMGFuZCUyMGxpdmUlMjBvdXQlMjB0aGUlMjB0cnVlJTIwbWVhbmluZyUyMG9mJTIwaXRzJTIwY3JlZWQuJyU3RA==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;openai/whisper-large-v3&quot;</span>)
pipeline(<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}}),{c(){h(l.$$.fragment)},l(n){J(l.$$.fragment,n)},m(n,r){u(l,n,r),m=!0},p:C,i(n){m||(f(l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2NvcmUnJTNBJTIwMC4wMjM5NDQ3NDg1NjU1NTQ2MiU3RCUyQyUwQSUyMCU3QidsYWJlbCclM0ElMjAndGlnZXIlMjBjYXQnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMDIyODg5MTUwMzA2NTgyNDUlN0QlNUQ=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;image-classification&quot;</span>, model=<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
pipeline(images=<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</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.43350091576576233</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.034796204417943954</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.03240183740854263</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.02394474856555462</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;tiger cat&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.02288915030658245</span>}]`,wrap:!1}}),{c(){h(l.$$.fragment)},l(n){J(l.$$.fragment,n)},m(n,r){u(l,n,r),m=!0},p:C,i(n){m||(f(l.$$.fragment,n),m=!0)},o(n){j(l.$$.fragment,n),m=!1},d(n){T(l,n)}}}function fl(G){let l,m;return l=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydmlzdWFsLXF1ZXN0aW9uLWFuc3dlcmluZyUyMiUyQyUyMG1vZGVsJTNEJTIyU2FsZXNmb3JjZSUyRmJsaXAtdnFhLWJhc2UlMjIpJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0QlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZ0cmFuc2Zvcm1lcnMlMkZ0YXNrcyUyRmlkZWZpY3MtZmV3LXNob3QuanBnJTIyJTJDJTBBJTIwJTIwJTIwJTIwcXVlc3Rpb24lM0QlMjJXaGF0JTIwaXMlMjBpbiUyMHRoZSUyMGltYWdlJTNGJTIyJTJDJTBBKSUwQSU1QiU3QidhbnN3ZXInJTNBJTIwJ3N0YXR1ZSUyMG9mJTIwbGliZXJ0eSclN0QlNUQ=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;visual-question-answering&quot;</span>, model=<span class="hljs-string">&quot;Salesforce/blip-vqa-base&quot;</span>)
pipeline(
    image=<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-few-shot.jpg&quot;</span>,
    question=<span class="hljs-string">&quot;What is in the image?&quot;</span>,
)
[{<span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;statue of liberty&#x27;</span>}]`,wrap:!1}}),{c(){h(l.$$.fragment)},l(n){J(l.$$.fragment,n)},m(n,r){u(l,n,r),m=!0},p:C,i(n){m||(f(l.$$.fragment,n),m=!0)},o(n){j(l.$$.fragment,n),m=!1},d(n){T(l,n)}}}function jl(G){let l,m,n,r,p,i,y,Z;return l=new R({props:{id:"tasks",option:"summarization",$$slots:{default:[hl]},$$scope:{ctx:G}}}),n=new R({props:{id:"tasks",option:"automatic speech recognition",$$slots:{default:[Jl]},$$scope:{ctx:G}}}),p=new R({props:{id:"tasks",option:"image classification",$$slots:{default:[ul]},$$scope:{ctx:G}}}),y=new R({props:{id:"tasks",option:"visual question answering",$$slots:{default:[fl]},$$scope:{ctx:G}}}),{c(){h(l.$$.fragment),m=c(),h(n.$$.fragment),r=c(),h(p.$$.fragment),i=c(),h(y.$$.fragment)},l(o){J(l.$$.fragment,o),m=M(o),J(n.$$.fragment,o),r=M(o),J(p.$$.fragment,o),i=M(o),J(y.$$.fragment,o)},m(o,g){u(l,o,g),a(o,m,g),u(n,o,g),a(o,r,g),u(p,o,g),a(o,i,g),u(y,o,g),Z=!0},p(o,g){const x={};g&2&&(x.$$scope={dirty:g,ctx:o}),l.$set(x);const I={};g&2&&(I.$$scope={dirty:g,ctx:o}),n.$set(I);const d={};g&2&&(d.$$scope={dirty:g,ctx:o}),p.$set(d);const B={};g&2&&(B.$$scope={dirty:g,ctx:o}),y.$set(B)},i(o){Z||(f(l.$$.fragment,o),f(n.$$.fragment,o),f(p.$$.fragment,o),f(y.$$.fragment,o),Z=!0)},o(o){j(l.$$.fragment,o),j(n.$$.fragment,o),j(p.$$.fragment,o),j(y.$$.fragment,o),Z=!1},d(o){o&&(t(m),t(r),t(i)),T(l,o),T(n,o),T(p,o),T(y,o)}}}function Tl(G){let l,m='Make sure have <a href="https://hf.co/docs/accelerate/basic_tutorials/install" rel="nofollow">Accelerate</a> is installed.',n,r,p;return r=new $({props:{code:"IXBpcCUyMGluc3RhbGwlMjAtVSUyMGFjY2VsZXJhdGU=",highlighted:"!pip install -U accelerate",wrap:!1}}),{c(){l=U("p"),l.innerHTML=m,n=c(),h(r.$$.fragment)},l(i){l=w(i,"P",{"data-svelte-h":!0}),b(l)!=="svelte-xknbup"&&(l.innerHTML=m),n=M(i),J(r.$$.fragment,i)},m(i,y){a(i,l,y),a(i,n,y),u(r,i,y),p=!0},p:C,i(i){p||(f(r.$$.fragment,i),p=!0)},o(i){j(r.$$.fragment,i),p=!1},d(i){i&&(t(l),t(n)),T(r,i)}}}function Ul(G){let l,m='To run <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> on a GPU, set <code>device</code> to the associated CUDA device id. For example, <code>device=0</code> runs on the first GPU.',n,r,p,i,y='You could also let <a href="https://hf.co/docs/accelerate/index" rel="nofollow">Accelerate</a>, a library for distributed training, automatically choose how to load and store the model weights on the appropriate device. This is especially useful if you have multiple devices. Accelerate loads and stores the model weights on the fastest device first, and then moves the weights to other devices (CPU, hard drive) as needed. Set <code>device_map=&quot;auto&quot;</code> to let Accelerate choose the device.',Z,o,g,x,I;return r=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyJTJDJTIwZGV2aWNlJTNEMCklMEFwaXBlbGluZSglMjJ0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjByZWFsbHklMjBnb29kJTIwY2FrZSUyMGlzJTIwJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>, device=<span class="hljs-number">0</span>)
pipeline(<span class="hljs-string">&quot;the secret to baking a really good cake is &quot;</span>)`,wrap:!1}}),o=new il({props:{warning:!1,$$slots:{default:[Tl]},$$scope:{ctx:G}}}),x=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBcGlwZWxpbmUoJTIydGhlJTIwc2VjcmV0JTIwdG8lMjBiYWtpbmclMjBhJTIwcmVhbGx5JTIwZ29vZCUyMGNha2UlMjBpcyUyMCUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
pipeline(<span class="hljs-string">&quot;the secret to baking a really good cake is &quot;</span>)`,wrap:!1}}),{c(){l=U("p"),l.innerHTML=m,n=c(),h(r.$$.fragment),p=c(),i=U("p"),i.innerHTML=y,Z=c(),h(o.$$.fragment),g=c(),h(x.$$.fragment)},l(d){l=w(d,"P",{"data-svelte-h":!0}),b(l)!=="svelte-k22k58"&&(l.innerHTML=m),n=M(d),J(r.$$.fragment,d),p=M(d),i=w(d,"P",{"data-svelte-h":!0}),b(i)!=="svelte-1xsajsn"&&(i.innerHTML=y),Z=M(d),J(o.$$.fragment,d),g=M(d),J(x.$$.fragment,d)},m(d,B){a(d,l,B),a(d,n,B),u(r,d,B),a(d,p,B),a(d,i,B),a(d,Z,B),u(o,d,B),a(d,g,B),u(x,d,B),I=!0},p(d,B){const W={};B&2&&(W.$$scope={dirty:B,ctx:d}),o.$set(W)},i(d){I||(f(r.$$.fragment,d),f(o.$$.fragment,d),f(x.$$.fragment,d),I=!0)},o(d){j(r.$$.fragment,d),j(o.$$.fragment,d),j(x.$$.fragment,d),I=!1},d(d){d&&(t(l),t(n),t(p),t(i),t(Z),t(g)),T(r,d),T(o,d),T(x,d)}}}function wl(G){let l,m='To run <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> on Apple silicon, set <code>device=&quot;mps&quot;</code>.',n,r,p;return r=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyJTJDJTIwZGV2aWNlJTNEJTIybXBzJTIyKSUwQXBpcGVsaW5lKCUyMnRoZSUyMHNlY3JldCUyMHRvJTIwYmFraW5nJTIwYSUyMHJlYWxseSUyMGdvb2QlMjBjYWtlJTIwaXMlMjAlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>, device=<span class="hljs-string">&quot;mps&quot;</span>)
pipeline(<span class="hljs-string">&quot;the secret to baking a really good cake is &quot;</span>)`,wrap:!1}}),{c(){l=U("p"),l.innerHTML=m,n=c(),h(r.$$.fragment)},l(i){l=w(i,"P",{"data-svelte-h":!0}),b(l)!=="svelte-1r2je7y"&&(l.innerHTML=m),n=M(i),J(r.$$.fragment,i)},m(i,y){a(i,l,y),a(i,n,y),u(r,i,y),p=!0},p:C,i(i){p||(f(r.$$.fragment,i),p=!0)},o(i){j(r.$$.fragment,i),p=!1},d(i){i&&(t(l),t(n)),T(r,i)}}}function bl(G){let l,m,n,r;return l=new R({props:{id:"device",option:"GPU",$$slots:{default:[Ul]},$$scope:{ctx:G}}}),n=new R({props:{id:"device",option:"Apple silicon",$$slots:{default:[wl]},$$scope:{ctx:G}}}),{c(){h(l.$$.fragment),m=c(),h(n.$$.fragment)},l(p){J(l.$$.fragment,p),m=M(p),J(n.$$.fragment,p)},m(p,i){u(l,p,i),a(p,m,i),u(n,p,i),r=!0},p(p,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:p}),l.$set(y);const Z={};i&2&&(Z.$$scope={dirty:i,ctx:p}),n.$set(Z)},i(p){r||(f(l.$$.fragment,p),f(n.$$.fragment,p),r=!0)},o(p){j(l.$$.fragment,p),j(n.$$.fragment,p),r=!1},d(p){p&&t(m),T(l,p),T(n,p)}}}function gl(G){let l,m='Pass the <code>return_timestamps=&quot;word&quot;</code> parameter to <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> to return when each word was spoken.',n,r,p;return r=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIyYXV0b21hdGljLXNwZWVjaC1yZWNvZ25pdGlvbiUyMiUyQyUyMG1vZGVsJTNEJTIyb3BlbmFpJTJGd2hpc3Blci1sYXJnZS12MyUyMiklMEFwaXBlbGluZShhdWRpbyUzRCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRk5hcnNpbCUyRmFzcl9kdW1teSUyRnJlc29sdmUlMkZtYWluJTJGbWxrLmZsYWMlMjIlMkMlMjByZXR1cm5fdGltZXN0YW1wJTNEJTIyd29yZCUyMiklMEElN0IndGV4dCclM0ElMjAnJTIwSSUyMGhhdmUlMjBhJTIwZHJlYW0lMjB0aGF0JTIwb25lJTIwZGF5JTIwdGhpcyUyMG5hdGlvbiUyMHdpbGwlMjByaXNlJTIwdXAlMjBhbmQlMjBsaXZlJTIwb3V0JTIwdGhlJTIwdHJ1ZSUyMG1lYW5pbmclMjBvZiUyMGl0cyUyMGNyZWVkLiclMkMlMEElMjAnY2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QSUyMCclMjBjcmVlZC4nJTJDJTIwJ3RpbWVzdGFtcCclM0ElMjAoMTEuOCUyQyUyMDEyLjMpJTdEJTVEJTdE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;openai/whisper-large-v3&quot;</span>)
pipeline(audio=<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>, return_timestamp=<span class="hljs-string">&quot;word&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;text&#x27;</span>: <span class="hljs-string">&#x27; I&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">0.0</span>, <span class="hljs-number">1.1</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; have&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.1</span>, <span class="hljs-number">1.44</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; a&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.44</span>, <span class="hljs-number">1.62</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; dream&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.62</span>, <span class="hljs-number">1.92</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; that&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.92</span>, <span class="hljs-number">3.7</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; one&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">3.7</span>, <span class="hljs-number">3.88</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; day&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">3.88</span>, <span class="hljs-number">4.24</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; this&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">4.24</span>, <span class="hljs-number">5.82</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; nation&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">5.82</span>, <span class="hljs-number">6.78</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; will&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">6.78</span>, <span class="hljs-number">7.36</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; rise&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">7.36</span>, <span class="hljs-number">7.88</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; up&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">7.88</span>, <span class="hljs-number">8.46</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; and&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">8.46</span>, <span class="hljs-number">9.2</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; live&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">9.2</span>, <span class="hljs-number">10.34</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; out&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.34</span>, <span class="hljs-number">10.58</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; the&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.58</span>, <span class="hljs-number">10.8</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; true&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.8</span>, <span class="hljs-number">11.04</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; meaning&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.04</span>, <span class="hljs-number">11.4</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; of&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.4</span>, <span class="hljs-number">11.64</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; its&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.64</span>, <span class="hljs-number">11.8</span>)},
  {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; creed.&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.8</span>, <span class="hljs-number">12.3</span>)}]}`,wrap:!1}}),{c(){l=U("p"),l.innerHTML=m,n=c(),h(r.$$.fragment)},l(i){l=w(i,"P",{"data-svelte-h":!0}),b(l)!=="svelte-m6rwpl"&&(l.innerHTML=m),n=M(i),J(r.$$.fragment,i)},m(i,y){a(i,l,y),a(i,n,y),u(r,i,y),p=!0},p:C,i(i){p||(f(r.$$.fragment,i),p=!0)},o(i){j(r.$$.fragment,i),p=!1},d(i){i&&(t(l),t(n)),T(r,i)}}}function Gl(G){let l,m='Pass <code>return_full_text=False</code> to <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> to only return the generated text instead of the full text (prompt and generated text).',n,r,p='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.TextGenerationPipeline.__call__"><strong>call</strong>()</a> also supports additional keyword arguments from the <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> method. To return more than one generated sequence, set <code>num_return_sequences</code> to a value greater than 1.',i,y,Z;return y=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEFwaXBlbGluZSglMjJ0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjBnb29kJTIwY2FrZSUyMGlzJTIyJTJDJTIwbnVtX3JldHVybl9zZXF1ZW5jZXMlM0Q0JTJDJTIwcmV0dXJuX2Z1bGxfdGV4dCUzREZhbHNlKSUwQSU1QiU3QidnZW5lcmF0ZWRfdGV4dCclM0ElMjAnJTIwaG93JTIwZWFzeSUyMGl0JTIwaXMlMjBmb3IlMjBtZSUyMHRvJTIwZG8lMjBpdCUyMHdpdGglMjBteSUyMGhhbmRzLiUyMFlvdSUyMG11c3QlMjBub3QlMjBnbyUyMG51dHMlMkMlMjBvciUyMHRoZSUyMGNha2UlMjBpcyUyMGdvaW5nJTIwdG8lMjBmYWxsJTIwb3V0LiclN0QlMkMlMEElMjAlN0InZ2VuZXJhdGVkX3RleHQnJTNBJTIwJyUyMHRvJTIwcHJlcGFyZSUyMHRoZSUyMGNha2UlMjBiZWZvcmUlMjBiYWtpbmcu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ib3V0JTIwMTInJTdEJTVE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;openai-community/gpt2&quot;</span>)
pipeline(<span class="hljs-string">&quot;the secret to baking a good cake is&quot;</span>, num_return_sequences=<span class="hljs-number">4</span>, return_full_text=<span class="hljs-literal">False</span>)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27; how easy it is for me to do it with my hands. You must not go nuts, or the cake is going to fall out.&#x27;</span>},
 {<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27; to prepare the cake before baking. The key is to find the right type of icing to use and that icing makes an amazing frosting cake.\\n\\nFor a good icing cake, we give you the basics&#x27;</span>},
 {<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&quot; to remember to soak it in enough water and don&#x27;t worry about it sticking to the wall. In the meantime, you could remove the top of the cake and let it dry out with a paper towel.\\n&quot;</span>},
 {<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27; the best time to turn off the oven and let it stand 30 minutes. After 30 minutes, stir and bake a cake in a pan until fully moist.\\n\\nRemove the cake from the heat for about 12&#x27;</span>}]`,wrap:!1}}),{c(){l=U("p"),l.innerHTML=m,n=c(),r=U("p"),r.innerHTML=p,i=c(),h(y.$$.fragment)},l(o){l=w(o,"P",{"data-svelte-h":!0}),b(l)!=="svelte-16qb0c9"&&(l.innerHTML=m),n=M(o),r=w(o,"P",{"data-svelte-h":!0}),b(r)!=="svelte-1kwejfa"&&(r.innerHTML=p),i=M(o),J(y.$$.fragment,o)},m(o,g){a(o,l,g),a(o,n,g),a(o,r,g),a(o,i,g),u(y,o,g),Z=!0},p:C,i(o){Z||(f(y.$$.fragment,o),Z=!0)},o(o){j(y.$$.fragment,o),Z=!1},d(o){o&&(t(l),t(n),t(r),t(i)),T(y,o)}}}function Zl(G){let l,m,n,r;return l=new R({props:{id:"task-specific-parameters",option:"automatic speech recognition",$$slots:{default:[gl]},$$scope:{ctx:G}}}),n=new R({props:{id:"task-specific-parameters",option:"text generation",$$slots:{default:[Gl]},$$scope:{ctx:G}}}),{c(){h(l.$$.fragment),m=c(),h(n.$$.fragment)},l(p){J(l.$$.fragment,p),m=M(p),J(n.$$.fragment,p)},m(p,i){u(l,p,i),a(p,m,i),u(n,p,i),r=!0},p(p,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:p}),l.$set(y);const Z={};i&2&&(Z.$$scope={dirty:i,ctx:p}),n.$set(Z)},i(p){r||(f(l.$$.fragment,p),f(n.$$.fragment,p),r=!0)},o(p){j(l.$$.fragment,p),j(n.$$.fragment,p),r=!1},d(p){p&&t(m),T(l,p),T(n,p)}}}function Bl(G){let l,m="Inputs are internally converted to torch.float16 and it only works for models with a PyTorch backend.";return{c(){l=U("p"),l.textContent=m},l(n){l=w(n,"P",{"data-svelte-h":!0}),b(l)!=="svelte-qm0tng"&&(l.textContent=m)},m(n,r){a(n,l,r)},p:C,d(n){n&&t(l)}}}function $l(G){let l,m,n,r,p,i,y,Z='The <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> is a simple but powerful inference API that is readily available for a variety of machine learning tasks with any model from the Hugging Face <a href="https://hf.co/models" rel="nofollow">Hub</a>.',o,g,x='Tailor the <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> to your task with task specific parameters such as adding timestamps to an automatic speech recognition (ASR) pipeline for transcribing meeting notes. <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> supports GPUs, Apple Silicon, and half-precision weights to accelerate inference and save memory.',I,d,B,W,Bs='Transformers has two pipeline classes, a generic <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> and many individual task-specific pipelines like <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.TextGenerationPipeline">TextGenerationPipeline</a> or <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.VisualQuestionAnsweringPipeline">VisualQuestionAnsweringPipeline</a>. Load these individual pipelines by setting the task identifier in the <code>task</code> parameter in <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>. You can find the task identifier for each pipeline in their API documentation.',Ie,N,$s="Each task is configured to use a default pretrained model and preprocessor, but this can be overridden with the <code>model</code> parameter if you want to use a different model.",We,Y,xs='For example, to use the <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.TextGenerationPipeline">TextGenerationPipeline</a> with <a href="./model_doc/gemma2">Gemma 2</a>, set <code>task=&quot;text-generation&quot;</code> and <code>model=&quot;google/gemma-2-2b&quot;</code>.',ke,H,Ce,S,Is="When you have more than one input, pass them as a list.",ve,_,Qe,z,Ws='This guide will introduce you to the <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>, demonstrate its features, and show how to configure its various parameters.',Xe,F,Ve,q,ks='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> is compatible with many machine learning tasks across different modalities. Pass an appropriate input to the pipeline and it will handle the rest.',Re,E,Cs='Here are some examples of how to use <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> for different tasks and modalities.',Ne,v,Ye,A,He,L,vs='At a minimum, <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> only requires a task identifier, model, and the appropriate input. But there are many parameters available to configure the pipeline with, from task-specific parameters to optimizing performance.',Se,P,Qs="This section introduces you to some of the more important parameters.",_e,D,ze,K,Xs='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> is compatible with many hardware types, including GPUs, CPUs, Apple Silicon, and more. Configure the hardware type with the <code>device</code> parameter. By default, <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> runs on a CPU which is given by <code>device=-1</code>.',Fe,Q,qe,O,Ee,ee,Vs='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> can also process batches of inputs with the <code>batch_size</code> parameter. Batch inference may improve speed, especially on a GPU, but it isn’t guaranteed. Other variables such as hardware, data, and the model itself can affect whether batch inference improves speed. For this reason, batch inference is disabled by default.',Ae,se,Rs='In the example below, when there are 4 inputs and <code>batch_size</code> is set to 2, <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> passes a batch of 2 inputs to the model at a time.',Le,le,Pe,te,Ns='Another good use case for batch inference is for streaming data in <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>.',De,ae,Ke,ne,Ys="Keep the following general rules of thumb in mind for determining whether batch inference can help improve performance.",Oe,ie,Hs="<li>The only way to know for sure is to measure performance on your model, data, and hardware.</li> <li>Don’t batch inference if you’re constrained by latency (a live inference product for example).</li> <li>Don’t batch inference if you’re using a CPU.</li> <li>Don’t batch inference if you don’t know the <code>sequence_length</code> of your data. Measure performance, iteratively add to <code>sequence_length</code>, and include out-of-memory (OOM) checks to recover from failures.</li> <li>Do batch inference if your <code>sequence_length</code> is regular, and keep pushing it until you reach an OOM error. The larger the GPU, the more helpful batch inference is.</li> <li>Do make sure you can handle OOM errors if you decide to do batch inference.</li>",es,pe,ss,re,Ss='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> accepts any parameters that are supported by each individual task pipeline. Make sure to check out each individual task pipeline to see what type of parameters are available. If you can’t find a parameter that is useful for your use case, please feel free to open a GitHub <a href="https://github.com/huggingface/transformers/issues/new?assignees=&amp;labels=feature&amp;template=feature-request.yml" rel="nofollow">issue</a> to request it!',ls,oe,_s="The examples below demonstrate some of the task-specific parameters available.",ts,X,as,ce,ns,Me,zs="There are some instances where you need to process data in chunks.",is,me,Fs="<li>for some data types, a single input (for example, a really long audio file) may need to be chunked into multiple parts before it can be processed</li> <li>for some tasks, like zero-shot classification or question answering, a single input may need multiple forward passes which can cause issues with the <code>batch_size</code> parameter</li>",ps,ye,qs='The <a href="https://github.com/huggingface/transformers/blob/99e0ab6ed888136ea4877c6d8ab03690a1478363/src/transformers/pipelines/base.py#L1387" rel="nofollow">ChunkPipeline</a> class is designed to handle these use cases. Both pipeline classes are used in the same way, but since <a href="https://github.com/huggingface/transformers/blob/99e0ab6ed888136ea4877c6d8ab03690a1478363/src/transformers/pipelines/base.py#L1387" rel="nofollow">ChunkPipeline</a> can automatically handle batching, you don’t need to worry about the number of forward passes your inputs trigger. Instead, you can optimize <code>batch_size</code> independently of the inputs.',rs,de,Es='The example below shows how it differs from <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>.',os,he,cs,Je,Ms,ue,As='For inference with large datasets, you can iterate directly over the dataset itself. This avoids immediately allocating memory for the entire dataset, and you don’t need to worry about creating batches yourself. Try <a href="#batch-inference">Batch inference</a> with the <code>batch_size</code> parameter to see if it improves performance.',ms,fe,ys,je,Ls='Other ways to run inference on large datasets with <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> include using an iterator or generator.',ds,Te,hs,Ue,Js,we,Ps='<a href="https://hf.co/docs/accelerate/index" rel="nofollow">Accelerate</a> enables a couple of optimizations for running large models with <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>. Make sure Accelerate is installed first.',us,be,fs,ge,Ds="The <code>device_map=&quot;auto&quot;</code> setting is useful for automatically distributing the model across the fastest devices (GPUs) first before dispatching to other slower devices if available (CPU, hard drive).",js,Ge,Ks='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> supports half-precision weights (torch.float16), which can be significantly faster and save memory. Performance loss is negligible for most models, especially for larger ones. If your hardware supports it, you can enable torch.bfloat16 instead for more range.',Ts,V,Us,Ze,Os='Lastly, <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> also accepts quantized models to reduce memory usage even further. Make sure you have the <a href="https://hf.co/docs/bitsandbytes/installation" rel="nofollow">bitsandbytes</a> library installed first, and then add <code>load_in_8bit=True</code> to <code>model_kwargs</code> in the pipeline.',ws,Be,bs,$e,gs,xe,Gs;return p=new k({props:{title:"Pipeline",local:"pipeline",headingTag:"h1"}}),d=new yl({props:{id:"tiZFewofSLM"}}),H=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyKSUwQXBpcGVsaW5lKCUyMnRoZSUyMHNlY3JldCUyMHRvJTIwYmFraW5nJTIwYSUyMHJlYWxseSUyMGdvb2QlMjBjYWtlJTIwaXMlMjAlMjIpJTBBJTVCJTdCJ2dlbmVyYXRlZF90ZXh0JyUzQSUyMCd0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjByZWFsbHklMjBnb29kJTIwY2FrZSUyMGlzJTIwMS4lMjB0aGUlMjByaWdodCUyMGluZ3JlZGllbnRzJTIwMi4lMjB0aGUnJTdEJTVE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>)
pipeline(<span class="hljs-string">&quot;the secret to baking a really good cake is &quot;</span>)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;the secret to baking a really good cake is 1. the right ingredients 2. the&#x27;</span>}]`,wrap:!1}}),_=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyJTJDJTIwZGV2aWNlJTNEJTIyY3VkYSUyMiklMEFwaXBlbGluZSglNUIlMjJ0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjByZWFsbHklMjBnb29kJTIwY2FrZSUyMGlzJTIwJTIyJTJDJTIwJTIyYSUyMGJhZ3VldHRlJTIwaXMlMjAlMjIlNUQpJTBBJTVCJTVCJTdCJ2dlbmVyYXRlZF90ZXh0JyUzQSUyMCd0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjByZWFsbHklMjBnb29kJTIwY2FrZSUyMGlzJTIwMS4lMjB0aGUlMjByaWdodCUyMGluZ3JlZGllbnRzJTIwMi4lMjB0aGUnJTdEJTVEJTJDJTBBJTIwJTVCJTdCJ2dlbmVyYXRlZF90ZXh0JyUzQSUyMCdhJTIwYmFndWV0dGUlMjBpcyUyMDEwMCUyNSUyMGJyZWFkLiU1Q24lNUNuYSUyMGJhZ3VldHRlJTIwaXMlMjAxMDAlMjUnJTdEJTVEJTVE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline([<span class="hljs-string">&quot;the secret to baking a really good cake is &quot;</span>, <span class="hljs-string">&quot;a baguette is &quot;</span>])
[[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;the secret to baking a really good cake is 1. the right ingredients 2. the&#x27;</span>}],
 [{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;a baguette is 100% bread.\\n\\na baguette is 100%&#x27;</span>}]]`,wrap:!1}}),F=new k({props:{title:"Tasks",local:"tasks",headingTag:"h2"}}),v=new Zs({props:{id:"tasks",options:["summarization","automatic speech recognition","image classification","visual question answering"],$$slots:{default:[jl]},$$scope:{ctx:G}}}),A=new k({props:{title:"Parameters",local:"parameters",headingTag:"h2"}}),D=new k({props:{title:"Device",local:"device",headingTag:"h3"}}),Q=new Zs({props:{id:"device",options:["GPU","Apple silicon"],$$slots:{default:[bl]},$$scope:{ctx:G}}}),O=new k({props:{title:"Batch inference",local:"batch-inference",headingTag:"h3"}}),le=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJnb29nbGUlMkZnZW1tYS0yLTJiJTIyJTJDJTIwZGV2aWNlJTNEJTIyY3VkYSUyMiUyQyUyMGJhdGNoX3NpemUlM0QyKSUwQXBpcGVsaW5lKCU1QiUyMnRoZSUyMHNlY3JldCUyMHRvJTIwYmFraW5nJTIwYSUyMHJlYWxseSUyMGdvb2QlMjBjYWtlJTIwaXMlMjIlMkMlMjAlMjJhJTIwYmFndWV0dGUlMjBpcyUyMiUyQyUyMCUyMnBhcmlzJTIwaXMlMjB0aGUlMjIlMkMlMjAlMjJob3Rkb2dzJTIwYXJlJTIyJTVEKSUwQSU1QiU1QiU3QidnZW5lcmF0ZWRfdGV4dCclM0ElMjAndGhlJTIwc2VjcmV0JTIwdG8lMjBiYWtpbmclMjBhJTIwcmVhbGx5JTIwZ29vZCUyMGNha2UlMjBpcyUyMHRvJTIwdXNlJTIwYSUyMGdvb2QlMjBjYWtlJTIwbWl4LiU1Q24lNUNuaSVFMiU4MCU5OSclN0QlNUQlMkMlMEElMjAlNUIlN0InZ2VuZXJhdGVkX3RleHQnJTNBJTIwJ2ElMjBiYWd1ZXR0ZSUyMGlzJyU3RCU1RCUyQyUwQSUyMCU1QiU3QidnZW5lcmF0ZWRfdGV4dCclM0ElMjAncGFyaXMlMjBpcyUyMHRoZSUyMG1vc3QlMjBiZWF1dGlmdWwlMjBjaXR5JTIwaW4lMjB0aGUlMjB3b3JsZC4lNUNuJTVDbmklRTIlODAlOTl2ZSUyMGJlZW4lMjB0byUyMHBhcmlzJTIwMyclN0QlNUQlMkMlMEElMjAlNUIlN0InZ2VuZXJhdGVkX3RleHQnJTNBJTIwJ2hvdGRvZ3MlMjBhcmUlMjBhJTIwc3RhcGxlJTIwb2YlMjB0aGUlMjBhbWVyaWNhbiUyMGRpZXQuJTIwdGhleSUyMGFyZSUyMGElMjBncmVhdCUyMHNvdXJjZSUyMG9mJTIwcHJvdGVpbiUyMGFuZCUyMGNhbiclN0QlNUQlNUQ=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;google/gemma-2-2b&quot;</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>, batch_size=<span class="hljs-number">2</span>)
pipeline([<span class="hljs-string">&quot;the secret to baking a really good cake is&quot;</span>, <span class="hljs-string">&quot;a baguette is&quot;</span>, <span class="hljs-string">&quot;paris is the&quot;</span>, <span class="hljs-string">&quot;hotdogs are&quot;</span>])
[[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;the secret to baking a really good cake is to use a good cake mix.\\n\\ni’&#x27;</span>}],
 [{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;a baguette is&#x27;</span>}],
 [{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;paris is the most beautiful city in the world.\\n\\ni’ve been to paris 3&#x27;</span>}],
 [{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;hotdogs are a staple of the american diet. they are a great source of protein and can&#x27;</span>}]]`,wrap:!1}}),ae=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5waXBlbGluZXMucHRfdXRpbHMlMjBpbXBvcnQlMjBLZXlEYXRhc2V0JTBBaW1wb3J0JTIwZGF0YXNldHMlMEElMEElMjMlMjBLZXlEYXRhc2V0JTIwaXMlMjBhJTIwdXRpbGl0eSUyMHRoYXQlMjByZXR1cm5zJTIwdGhlJTIwaXRlbSUyMGluJTIwdGhlJTIwZGljdCUyMHJldHVybmVkJTIwYnklMjB0aGUlMjBkYXRhc2V0JTBBZGF0YXNldCUyMCUzRCUyMGRhdGFzZXRzLmxvYWRfZGF0YXNldCglMjJpbWRiJTIyJTJDJTIwbmFtZSUzRCUyMnBsYWluX3RleHQlMjIlMkMlMjBzcGxpdCUzRCUyMnVuc3VwZXJ2aXNlZCUyMiklMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lKHRhc2slM0QlMjJ0ZXh0LWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMkMlMjBkZXZpY2UlM0QlMjJjdWRhJTIyKSUwQWZvciUyMG91dCUyMGluJTIwcGlwZWxpbmUoS2V5RGF0YXNldChkYXRhc2V0JTJDJTIwJTIydGV4dCUyMiklMkMlMjBiYXRjaF9zaXplJTNEOCUyQyUyMHRydW5jYXRpb24lM0QlMjJvbmx5X2ZpcnN0JTIyKSUzQSUwQSUyMCUyMCUyMCUyMHByaW50KG91dCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline
<span class="hljs-keyword">from</span> transformers.pipelines.pt_utils <span class="hljs-keyword">import</span> KeyDataset
<span class="hljs-keyword">import</span> datasets

<span class="hljs-comment"># KeyDataset is a utility that returns the item in the dict returned by the dataset</span>
dataset = datasets.load_dataset(<span class="hljs-string">&quot;imdb&quot;</span>, name=<span class="hljs-string">&quot;plain_text&quot;</span>, split=<span class="hljs-string">&quot;unsupervised&quot;</span>)
pipeline = pipeline(task=<span class="hljs-string">&quot;text-classification&quot;</span>, model=<span class="hljs-string">&quot;distilbert/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipeline(KeyDataset(dataset, <span class="hljs-string">&quot;text&quot;</span>), batch_size=<span class="hljs-number">8</span>, truncation=<span class="hljs-string">&quot;only_first&quot;</span>):
    <span class="hljs-built_in">print</span>(out)`,wrap:!1}}),pe=new k({props:{title:"Task-specific parameters",local:"task-specific-parameters",headingTag:"h3"}}),X=new Zs({props:{id:"task-specific-parameters",options:["automatic speech recognition","text generation"],$$slots:{default:[Zl]},$$scope:{ctx:G}}}),ce=new k({props:{title:"Chunk batching",local:"chunk-batching",headingTag:"h2"}}),he=new $({props:{code:"JTIzJTIwQ2h1bmtQaXBlbGluZSUwQWFsbF9tb2RlbF9vdXRwdXRzJTIwJTNEJTIwJTVCJTVEJTBBZm9yJTIwcHJlcHJvY2Vzc2VkJTIwaW4lMjBwaXBlbGluZS5wcmVwcm9jZXNzKGlucHV0cyklM0ElMEElMjAlMjAlMjAlMjBtb2RlbF9vdXRwdXRzJTIwJTNEJTIwcGlwZWxpbmUubW9kZWxfZm9yd2FyZChwcmVwcm9jZXNzZWQpJTBBJTIwJTIwJTIwJTIwYWxsX21vZGVsX291dHB1dHMuYXBwZW5kKG1vZGVsX291dHB1dHMpJTBBb3V0cHV0cyUyMCUzRHBpcGVsaW5lLnBvc3Rwcm9jZXNzKGFsbF9tb2RlbF9vdXRwdXRzKSUwQSUwQSUyMyUyMFBpcGVsaW5lJTBBcHJlcHJvY2Vzc2VkJTIwJTNEJTIwcGlwZWxpbmUucHJlcHJvY2VzcyhpbnB1dHMpJTBBbW9kZWxfb3V0cHV0cyUyMCUzRCUyMHBpcGVsaW5lLmZvcndhcmQocHJlcHJvY2Vzc2VkKSUwQW91dHB1dHMlMjAlM0QlMjBwaXBlbGluZS5wb3N0cHJvY2Vzcyhtb2RlbF9vdXRwdXRzKQ==",highlighted:`<span class="hljs-comment"># ChunkPipeline</span>
all_model_outputs = []
<span class="hljs-keyword">for</span> preprocessed <span class="hljs-keyword">in</span> pipeline.preprocess(inputs):
    model_outputs = pipeline.model_forward(preprocessed)
    all_model_outputs.append(model_outputs)
outputs =pipeline.postprocess(all_model_outputs)

<span class="hljs-comment"># Pipeline</span>
preprocessed = pipeline.preprocess(inputs)
model_outputs = pipeline.forward(preprocessed)
outputs = pipeline.postprocess(model_outputs)`,wrap:!1}}),Je=new k({props:{title:"Large datasets",local:"large-datasets",headingTag:"h2"}}),fe=new $({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5waXBlbGluZXMucHRfdXRpbHMlMjBpbXBvcnQlMjBLZXlEYXRhc2V0JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGRhdGFzZXRzLmxvYWRfZGF0YXNldCglMjJpbWRiJTIyJTJDJTIwbmFtZSUzRCUyMnBsYWluX3RleHQlMjIlMkMlMjBzcGxpdCUzRCUyMnVuc3VwZXJ2aXNlZCUyMiklMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lKHRhc2slM0QlMjJ0ZXh0LWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMkMlMjBkZXZpY2UlM0QlMjJjdWRhJTIyKSUwQWZvciUyMG91dCUyMGluJTIwcGlwZWxpbmUoS2V5RGF0YXNldChkYXRhc2V0JTJDJTIwJTIydGV4dCUyMiklMkMlMjBiYXRjaF9zaXplJTNEOCUyQyUyMHRydW5jYXRpb24lM0QlMjJvbmx5X2ZpcnN0JTIyKSUzQSUwQSUyMCUyMCUyMCUyMHByaW50KG91dCk=",highlighted:`<span class="hljs-keyword">from</span> transformers.pipelines.pt_utils <span class="hljs-keyword">import</span> KeyDataset
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline
<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset = datasets.load_dataset(<span class="hljs-string">&quot;imdb&quot;</span>, name=<span class="hljs-string">&quot;plain_text&quot;</span>, split=<span class="hljs-string">&quot;unsupervised&quot;</span>)
pipeline = pipeline(task=<span class="hljs-string">&quot;text-classification&quot;</span>, model=<span class="hljs-string">&quot;distilbert/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipeline(KeyDataset(dataset, <span class="hljs-string">&quot;text&quot;</span>), batch_size=<span class="hljs-number">8</span>, truncation=<span class="hljs-string">&quot;only_first&quot;</span>):
    <span class="hljs-built_in">print</span>(out)`,wrap:!1}}),Te=new $({props:{code:"ZGVmJTIwZGF0YSgpJTNBJTBBJTIwJTIwJTIwJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMTAwMCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB5aWVsZCUyMGYlMjJNeSUyMGV4YW1wbGUlMjAlN0JpJTdEJTIyJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyJTJDJTIwZGV2aWNlJTNEMCklMEFnZW5lcmF0ZWRfY2hhcmFjdGVycyUyMCUzRCUyMDAlMEFmb3IlMjBvdXQlMjBpbiUyMHBpcGVsaW5lKGRhdGEoKSklM0ElMEElMjAlMjAlMjAlMjBnZW5lcmF0ZWRfY2hhcmFjdGVycyUyMCUyQiUzRCUyMGxlbihvdXQlNUIwJTVEJTVCJTIyZ2VuZXJhdGVkX3RleHQlMjIlNUQp",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>

pipeline = 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> pipeline(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}}),Ue=new k({props:{title:"Large models",local:"large-models",headingTag:"h2"}}),be=new $({props:{code:"IXBpcCUyMGluc3RhbGwlMjAtVSUyMGFjY2VsZXJhdGU=",highlighted:"!pip install -U accelerate",wrap:!1}}),V=new il({props:{warning:!1,$$slots:{default:[Bl]},$$scope:{ctx:G}}}),Be=new $({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMkMlMjBCaXRzQW5kQnl0ZXNDb25maWclMEElMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lKG1vZGVsJTNEJTIyZ29vZ2xlJTJGZ2VtbWEtN2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBtb2RlbF9rd2FyZ3MlM0QlN0IlMjJxdWFudGl6YXRpb25fY29uZmlnJTIyJTNBJTIwQml0c0FuZEJ5dGVzQ29uZmlnKGxvYWRfaW5fOGJpdCUzRFRydWUpJTdEKSUwQXBpcGVsaW5lKCUyMnRoZSUyMHNlY3JldCUyMHRvJTIwYmFraW5nJTIwYSUyMGdvb2QlMjBjYWtlJTIwaXMlMjAlMjIpJTBBJTVCJTdCJ2dlbmVyYXRlZF90ZXh0JyUzQSUyMCd0aGUlMjBzZWNyZXQlMjB0byUyMGJha2luZyUyMGElMjBnb29kJTIwY2FrZSUyMGlzJTIwMS4lMjB0aGUlMjByaWdodCUyMGluZ3JlZGllbnRzJTIwMi4lMjB0aGUlMjByaWdodCclN0QlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline, BitsAndBytesConfig

pipeline = pipeline(model=<span class="hljs-string">&quot;google/gemma-7b&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;auto&quot;</span>, model_kwargs={<span class="hljs-string">&quot;quantization_config&quot;</span>: BitsAndBytesConfig(load_in_8bit=<span class="hljs-literal">True</span>)})
pipeline(<span class="hljs-string">&quot;the secret to baking a good cake is &quot;</span>)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;the secret to baking a good cake is 1. the right ingredients 2. the right&#x27;</span>}]`,wrap:!1}}),$e=new dl({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/pipeline_tutorial.md"}}),{c(){l=U("meta"),m=c(),n=U("p"),r=c(),h(p.$$.fragment),i=c(),y=U("p"),y.innerHTML=Z,o=c(),g=U("p"),g.innerHTML=x,I=c(),h(d.$$.fragment),B=c(),W=U("p"),W.innerHTML=Bs,Ie=c(),N=U("p"),N.innerHTML=$s,We=c(),Y=U("p"),Y.innerHTML=xs,ke=c(),h(H.$$.fragment),Ce=c(),S=U("p"),S.textContent=Is,ve=c(),h(_.$$.fragment),Qe=c(),z=U("p"),z.innerHTML=Ws,Xe=c(),h(F.$$.fragment),Ve=c(),q=U("p"),q.innerHTML=ks,Re=c(),E=U("p"),E.innerHTML=Cs,Ne=c(),h(v.$$.fragment),Ye=c(),h(A.$$.fragment),He=c(),L=U("p"),L.innerHTML=vs,Se=c(),P=U("p"),P.textContent=Qs,_e=c(),h(D.$$.fragment),ze=c(),K=U("p"),K.innerHTML=Xs,Fe=c(),h(Q.$$.fragment),qe=c(),h(O.$$.fragment),Ee=c(),ee=U("p"),ee.innerHTML=Vs,Ae=c(),se=U("p"),se.innerHTML=Rs,Le=c(),h(le.$$.fragment),Pe=c(),te=U("p"),te.innerHTML=Ns,De=c(),h(ae.$$.fragment),Ke=c(),ne=U("p"),ne.textContent=Ys,Oe=c(),ie=U("ol"),ie.innerHTML=Hs,es=c(),h(pe.$$.fragment),ss=c(),re=U("p"),re.innerHTML=Ss,ls=c(),oe=U("p"),oe.textContent=_s,ts=c(),h(X.$$.fragment),as=c(),h(ce.$$.fragment),ns=c(),Me=U("p"),Me.textContent=zs,is=c(),me=U("ul"),me.innerHTML=Fs,ps=c(),ye=U("p"),ye.innerHTML=qs,rs=c(),de=U("p"),de.innerHTML=Es,os=c(),h(he.$$.fragment),cs=c(),h(Je.$$.fragment),Ms=c(),ue=U("p"),ue.innerHTML=As,ms=c(),h(fe.$$.fragment),ys=c(),je=U("p"),je.innerHTML=Ls,ds=c(),h(Te.$$.fragment),hs=c(),h(Ue.$$.fragment),Js=c(),we=U("p"),we.innerHTML=Ps,us=c(),h(be.$$.fragment),fs=c(),ge=U("p"),ge.innerHTML=Ds,js=c(),Ge=U("p"),Ge.innerHTML=Ks,Ts=c(),h(V.$$.fragment),Us=c(),Ze=U("p"),Ze.innerHTML=Os,ws=c(),h(Be.$$.fragment),bs=c(),h($e.$$.fragment),gs=c(),xe=U("p"),this.h()},l(e){const s=Ml("svelte-u9bgzb",document.head);l=w(s,"META",{name:!0,content:!0}),s.forEach(t),m=M(e),n=w(e,"P",{}),al(n).forEach(t),r=M(e),J(p.$$.fragment,e),i=M(e),y=w(e,"P",{"data-svelte-h":!0}),b(y)!=="svelte-u2ue8s"&&(y.innerHTML=Z),o=M(e),g=w(e,"P",{"data-svelte-h":!0}),b(g)!=="svelte-15ff3qz"&&(g.innerHTML=x),I=M(e),J(d.$$.fragment,e),B=M(e),W=w(e,"P",{"data-svelte-h":!0}),b(W)!=="svelte-ieinkv"&&(W.innerHTML=Bs),Ie=M(e),N=w(e,"P",{"data-svelte-h":!0}),b(N)!=="svelte-ms7obs"&&(N.innerHTML=$s),We=M(e),Y=w(e,"P",{"data-svelte-h":!0}),b(Y)!=="svelte-p6cq9"&&(Y.innerHTML=xs),ke=M(e),J(H.$$.fragment,e),Ce=M(e),S=w(e,"P",{"data-svelte-h":!0}),b(S)!=="svelte-1ty30nx"&&(S.textContent=Is),ve=M(e),J(_.$$.fragment,e),Qe=M(e),z=w(e,"P",{"data-svelte-h":!0}),b(z)!=="svelte-1ioxirz"&&(z.innerHTML=Ws),Xe=M(e),J(F.$$.fragment,e),Ve=M(e),q=w(e,"P",{"data-svelte-h":!0}),b(q)!=="svelte-1j3dc6v"&&(q.innerHTML=ks),Re=M(e),E=w(e,"P",{"data-svelte-h":!0}),b(E)!=="svelte-1itupt4"&&(E.innerHTML=Cs),Ne=M(e),J(v.$$.fragment,e),Ye=M(e),J(A.$$.fragment,e),He=M(e),L=w(e,"P",{"data-svelte-h":!0}),b(L)!=="svelte-11guezn"&&(L.innerHTML=vs),Se=M(e),P=w(e,"P",{"data-svelte-h":!0}),b(P)!=="svelte-fh3bdc"&&(P.textContent=Qs),_e=M(e),J(D.$$.fragment,e),ze=M(e),K=w(e,"P",{"data-svelte-h":!0}),b(K)!=="svelte-s3gsxb"&&(K.innerHTML=Xs),Fe=M(e),J(Q.$$.fragment,e),qe=M(e),J(O.$$.fragment,e),Ee=M(e),ee=w(e,"P",{"data-svelte-h":!0}),b(ee)!=="svelte-rwo0xl"&&(ee.innerHTML=Vs),Ae=M(e),se=w(e,"P",{"data-svelte-h":!0}),b(se)!=="svelte-1wm76el"&&(se.innerHTML=Rs),Le=M(e),J(le.$$.fragment,e),Pe=M(e),te=w(e,"P",{"data-svelte-h":!0}),b(te)!=="svelte-foh8k9"&&(te.innerHTML=Ns),De=M(e),J(ae.$$.fragment,e),Ke=M(e),ne=w(e,"P",{"data-svelte-h":!0}),b(ne)!=="svelte-c57m2q"&&(ne.textContent=Ys),Oe=M(e),ie=w(e,"OL",{"data-svelte-h":!0}),b(ie)!=="svelte-1kufr0d"&&(ie.innerHTML=Hs),es=M(e),J(pe.$$.fragment,e),ss=M(e),re=w(e,"P",{"data-svelte-h":!0}),b(re)!=="svelte-1fkyqda"&&(re.innerHTML=Ss),ls=M(e),oe=w(e,"P",{"data-svelte-h":!0}),b(oe)!=="svelte-1r45mm4"&&(oe.textContent=_s),ts=M(e),J(X.$$.fragment,e),as=M(e),J(ce.$$.fragment,e),ns=M(e),Me=w(e,"P",{"data-svelte-h":!0}),b(Me)!=="svelte-atfdfd"&&(Me.textContent=zs),is=M(e),me=w(e,"UL",{"data-svelte-h":!0}),b(me)!=="svelte-bybore"&&(me.innerHTML=Fs),ps=M(e),ye=w(e,"P",{"data-svelte-h":!0}),b(ye)!=="svelte-1fz22pv"&&(ye.innerHTML=qs),rs=M(e),de=w(e,"P",{"data-svelte-h":!0}),b(de)!=="svelte-1uskpt0"&&(de.innerHTML=Es),os=M(e),J(he.$$.fragment,e),cs=M(e),J(Je.$$.fragment,e),Ms=M(e),ue=w(e,"P",{"data-svelte-h":!0}),b(ue)!=="svelte-1qel1t2"&&(ue.innerHTML=As),ms=M(e),J(fe.$$.fragment,e),ys=M(e),je=w(e,"P",{"data-svelte-h":!0}),b(je)!=="svelte-11k64y3"&&(je.innerHTML=Ls),ds=M(e),J(Te.$$.fragment,e),hs=M(e),J(Ue.$$.fragment,e),Js=M(e),we=w(e,"P",{"data-svelte-h":!0}),b(we)!=="svelte-pf4ijx"&&(we.innerHTML=Ps),us=M(e),J(be.$$.fragment,e),fs=M(e),ge=w(e,"P",{"data-svelte-h":!0}),b(ge)!=="svelte-ldjqsx"&&(ge.innerHTML=Ds),js=M(e),Ge=w(e,"P",{"data-svelte-h":!0}),b(Ge)!=="svelte-14la8wx"&&(Ge.innerHTML=Ks),Ts=M(e),J(V.$$.fragment,e),Us=M(e),Ze=w(e,"P",{"data-svelte-h":!0}),b(Ze)!=="svelte-196xvob"&&(Ze.innerHTML=Os),ws=M(e),J(Be.$$.fragment,e),bs=M(e),J($e.$$.fragment,e),gs=M(e),xe=w(e,"P",{}),al(xe).forEach(t),this.h()},h(){nl(l,"name","hf:doc:metadata"),nl(l,"content",xl)},m(e,s){ml(document.head,l),a(e,m,s),a(e,n,s),a(e,r,s),u(p,e,s),a(e,i,s),a(e,y,s),a(e,o,s),a(e,g,s),a(e,I,s),u(d,e,s),a(e,B,s),a(e,W,s),a(e,Ie,s),a(e,N,s),a(e,We,s),a(e,Y,s),a(e,ke,s),u(H,e,s),a(e,Ce,s),a(e,S,s),a(e,ve,s),u(_,e,s),a(e,Qe,s),a(e,z,s),a(e,Xe,s),u(F,e,s),a(e,Ve,s),a(e,q,s),a(e,Re,s),a(e,E,s),a(e,Ne,s),u(v,e,s),a(e,Ye,s),u(A,e,s),a(e,He,s),a(e,L,s),a(e,Se,s),a(e,P,s),a(e,_e,s),u(D,e,s),a(e,ze,s),a(e,K,s),a(e,Fe,s),u(Q,e,s),a(e,qe,s),u(O,e,s),a(e,Ee,s),a(e,ee,s),a(e,Ae,s),a(e,se,s),a(e,Le,s),u(le,e,s),a(e,Pe,s),a(e,te,s),a(e,De,s),u(ae,e,s),a(e,Ke,s),a(e,ne,s),a(e,Oe,s),a(e,ie,s),a(e,es,s),u(pe,e,s),a(e,ss,s),a(e,re,s),a(e,ls,s),a(e,oe,s),a(e,ts,s),u(X,e,s),a(e,as,s),u(ce,e,s),a(e,ns,s),a(e,Me,s),a(e,is,s),a(e,me,s),a(e,ps,s),a(e,ye,s),a(e,rs,s),a(e,de,s),a(e,os,s),u(he,e,s),a(e,cs,s),u(Je,e,s),a(e,Ms,s),a(e,ue,s),a(e,ms,s),u(fe,e,s),a(e,ys,s),a(e,je,s),a(e,ds,s),u(Te,e,s),a(e,hs,s),u(Ue,e,s),a(e,Js,s),a(e,we,s),a(e,us,s),u(be,e,s),a(e,fs,s),a(e,ge,s),a(e,js,s),a(e,Ge,s),a(e,Ts,s),u(V,e,s),a(e,Us,s),a(e,Ze,s),a(e,ws,s),u(Be,e,s),a(e,bs,s),u($e,e,s),a(e,gs,s),a(e,xe,s),Gs=!0},p(e,[s]){const el={};s&2&&(el.$$scope={dirty:s,ctx:e}),v.$set(el);const sl={};s&2&&(sl.$$scope={dirty:s,ctx:e}),Q.$set(sl);const ll={};s&2&&(ll.$$scope={dirty:s,ctx:e}),X.$set(ll);const tl={};s&2&&(tl.$$scope={dirty:s,ctx:e}),V.$set(tl)},i(e){Gs||(f(p.$$.fragment,e),f(d.$$.fragment,e),f(H.$$.fragment,e),f(_.$$.fragment,e),f(F.$$.fragment,e),f(v.$$.fragment,e),f(A.$$.fragment,e),f(D.$$.fragment,e),f(Q.$$.fragment,e),f(O.$$.fragment,e),f(le.$$.fragment,e),f(ae.$$.fragment,e),f(pe.$$.fragment,e),f(X.$$.fragment,e),f(ce.$$.fragment,e),f(he.$$.fragment,e),f(Je.$$.fragment,e),f(fe.$$.fragment,e),f(Te.$$.fragment,e),f(Ue.$$.fragment,e),f(be.$$.fragment,e),f(V.$$.fragment,e),f(Be.$$.fragment,e),f($e.$$.fragment,e),Gs=!0)},o(e){j(p.$$.fragment,e),j(d.$$.fragment,e),j(H.$$.fragment,e),j(_.$$.fragment,e),j(F.$$.fragment,e),j(v.$$.fragment,e),j(A.$$.fragment,e),j(D.$$.fragment,e),j(Q.$$.fragment,e),j(O.$$.fragment,e),j(le.$$.fragment,e),j(ae.$$.fragment,e),j(pe.$$.fragment,e),j(X.$$.fragment,e),j(ce.$$.fragment,e),j(he.$$.fragment,e),j(Je.$$.fragment,e),j(fe.$$.fragment,e),j(Te.$$.fragment,e),j(Ue.$$.fragment,e),j(be.$$.fragment,e),j(V.$$.fragment,e),j(Be.$$.fragment,e),j($e.$$.fragment,e),Gs=!1},d(e){e&&(t(m),t(n),t(r),t(i),t(y),t(o),t(g),t(I),t(B),t(W),t(Ie),t(N),t(We),t(Y),t(ke),t(Ce),t(S),t(ve),t(Qe),t(z),t(Xe),t(Ve),t(q),t(Re),t(E),t(Ne),t(Ye),t(He),t(L),t(Se),t(P),t(_e),t(ze),t(K),t(Fe),t(qe),t(Ee),t(ee),t(Ae),t(se),t(Le),t(Pe),t(te),t(De),t(Ke),t(ne),t(Oe),t(ie),t(es),t(ss),t(re),t(ls),t(oe),t(ts),t(as),t(ns),t(Me),t(is),t(me),t(ps),t(ye),t(rs),t(de),t(os),t(cs),t(Ms),t(ue),t(ms),t(ys),t(je),t(ds),t(hs),t(Js),t(we),t(us),t(fs),t(ge),t(js),t(Ge),t(Ts),t(Us),t(Ze),t(ws),t(bs),t(gs),t(xe)),t(l),T(p,e),T(d,e),T(H,e),T(_,e),T(F,e),T(v,e),T(A,e),T(D,e),T(Q,e),T(O,e),T(le,e),T(ae,e),T(pe,e),T(X,e),T(ce,e),T(he,e),T(Je,e),T(fe,e),T(Te,e),T(Ue,e),T(be,e),T(V,e),T(Be,e),T($e,e)}}}const xl='{"title":"Pipeline","local":"pipeline","sections":[{"title":"Tasks","local":"tasks","sections":[],"depth":2},{"title":"Parameters","local":"parameters","sections":[{"title":"Device","local":"device","sections":[],"depth":3},{"title":"Batch inference","local":"batch-inference","sections":[],"depth":3},{"title":"Task-specific parameters","local":"task-specific-parameters","sections":[],"depth":3}],"depth":2},{"title":"Chunk batching","local":"chunk-batching","sections":[],"depth":2},{"title":"Large datasets","local":"large-datasets","sections":[],"depth":2},{"title":"Large models","local":"large-models","sections":[],"depth":2}],"depth":1}';function Il(G){return rl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Rl extends ol{constructor(l){super(),cl(this,l,Il,$l,pl,{})}}export{Rl as component};
