import{s as ie,o as Me,n as os}from"../chunks/scheduler.01eeda35.js";import{S as re,i as ce,g as J,s as p,r as U,A as me,h as T,f as l,c as o,j as ne,u as j,x as h,k as pe,y as ye,a,v as w,d as f,t as I,w as g}from"../chunks/index.6dd51b66.js";import{T as oe}from"../chunks/Tip.de9bae2b.js";import{C as B}from"../chunks/CodeBlock.19ec9b8c.js";import{H as Ms,E as Je}from"../chunks/index.58fe8f9d.js";import{H as Te,a as Xs}from"../chunks/HfOption.f7f04550.js";function de(x){let n,u='The <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.ImageTextToTextPipeline">ImageTextToTextPipeline</a> accepts chats in the OpenAI format to make inference easier and more accessible.';return{c(){n=J("p"),n.innerHTML=u},l(i){n=T(i,"P",{"data-svelte-h":!0}),h(n)!=="svelte-18ohruh"&&(n.innerHTML=u)},m(i,M){a(i,n,M)},p:os,d(i){i&&l(n)}}}function he(x){let n,u="Loading a video from <code>&quot;url&quot;</code> is only supported by the PyAV or Decord backends.";return{c(){n=J("p"),n.innerHTML=u},l(i){n=T(i,"P",{"data-svelte-h":!0}),h(n)!=="svelte-1ddif0x"&&(n.innerHTML=u)},m(i,M){a(i,n,M)},p:os,d(i){i&&l(n)}}}function ue(x){let n,u="The <code>num_frames</code> parameter controls how many frames to uniformly sample from the video. Each checkpoint has a maximum frame count it was pretrained with and exceeding this count can significantly lower generation quality. It’s important to choose a frame count that fits both the model capacity and your hardware resources. If <code>num_frames</code> isn’t specified, the entire video is loaded without any frame sampling.",i,M,y,c,m='These inputs are now ready to be used in <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>.',C;return M=new B({props:{code:"cHJvY2Vzc2VkX2NoYXQlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZSglMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2ZyYW1lcyUzRDMyJTJDJTBBJTIwJTIwJTIwJTIwdmlkZW9fbG9hZF9iYWNrZW5kJTNEJTIyZGVjb3JkJTIyJTJDJTBBKSUwQXByaW50KHByb2Nlc3NlZF9jaGF0LmtleXMoKSk=",highlighted:`processed_chat = processor.apply_chat_template(
    messages,
    add_generation_prompt=<span class="hljs-literal">True</span>,
    tokenize=<span class="hljs-literal">True</span>,
    return_dict=<span class="hljs-literal">True</span>,
    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
    num_frames=<span class="hljs-number">32</span>,
    video_load_backend=<span class="hljs-string">&quot;decord&quot;</span>,
)
<span class="hljs-built_in">print</span>(processed_chat.keys())`,wrap:!1}}),{c(){n=J("p"),n.innerHTML=u,i=p(),U(M.$$.fragment),y=p(),c=J("p"),c.innerHTML=m},l(e){n=T(e,"P",{"data-svelte-h":!0}),h(n)!=="svelte-1ilhsfw"&&(n.innerHTML=u),i=o(e),j(M.$$.fragment,e),y=o(e),c=T(e,"P",{"data-svelte-h":!0}),h(c)!=="svelte-uo4xlo"&&(c.innerHTML=m)},m(e,r){a(e,n,r),a(e,i,r),w(M,e,r),a(e,y,r),a(e,c,r),C=!0},p:os,i(e){C||(f(M.$$.fragment,e),C=!0)},o(e){I(M.$$.fragment,e),C=!1},d(e){e&&(l(n),l(i),l(y),l(c)),g(M,e)}}}function Ue(x){let n,u="For longer videos, it may be better to sample more frames for better representation with the <code>video_fps</code> parameter. This determines how many frames per second to extract. As an example, if a video is 10 seconds long and <code>video_fps=2</code>, then the model samples 20 frames. In other words, 2 frames are uniformly sampled every 10 seconds.",i,M,y;return M=new B({props:{code:"cHJvY2Vzc2VkX2NoYXQlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZSglMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB2aWRlb19mcHMlM0QzMiUyQyUwQSUyMCUyMCUyMCUyMHZpZGVvX2xvYWRfYmFja2VuZCUzRCUyMmRlY29yZCUyMiUyQyUwQSklMEFwcmludChwcm9jZXNzZWRfY2hhdC5rZXlzKCkp",highlighted:`processed_chat = processor.apply_chat_template(
    messages,
    add_generation_prompt=<span class="hljs-literal">True</span>,
    tokenize=<span class="hljs-literal">True</span>,
    return_dict=<span class="hljs-literal">True</span>,
    video_fps=<span class="hljs-number">32</span>,
    video_load_backend=<span class="hljs-string">&quot;decord&quot;</span>,
)
<span class="hljs-built_in">print</span>(processed_chat.keys())`,wrap:!1}}),{c(){n=J("p"),n.innerHTML=u,i=p(),U(M.$$.fragment)},l(c){n=T(c,"P",{"data-svelte-h":!0}),h(n)!=="svelte-xuidqz"&&(n.innerHTML=u),i=o(c),j(M.$$.fragment,c)},m(c,m){a(c,n,m),a(c,i,m),w(M,c,m),y=!0},p:os,i(c){y||(f(M.$$.fragment,c),y=!0)},o(c){I(M.$$.fragment,c),y=!1},d(c){c&&(l(n),l(i)),g(M,c)}}}function je(x){let n,u="Some models don’t sample frames <em>uniformly</em> and require more complex logic to determine which frames to use. For example, the model may have an <em>adaptive frame selection</em> or if the model prioritizes <em>key moments</em> in a video rather than evenly spaced frames.",i,M,y="If a model has a different sampling strategy, you can write a function that customizes frame selection. The function should include the following requirements.",c,m,C="<li>Use the <code>sample_indices_fn</code> parameter to pass a callable function for sampling.</li> <li>If provided, this function <em>overrides</em> the standard <code>num_frames</code> and <code>fps</code> parameters.</li> <li>The function receives all the parameters passed to <code>load_video</code> and must return valid frame indices to sample from.</li>",e,r,q="An example function is shown below. This gives you full control over frame selection, making the model more adaptable to different video scenarios.",$,b,v;return b=new B({props:{code:"ZGVmJTIwc2FtcGxlX2luZGljZXNfZm4obWV0YWRhdGElMkMlMjAqKmt3YXJncyklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBzYW1wbGVzJTIwb25seSUyMHRoZSUyMGZpcnN0JTIwYW5kJTIwdGhlJTIwc2Vjb25kJTIwZnJhbWUlMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlNUIwJTJDJTIwMSU1RCUwQSUwQXByb2Nlc3NlZF9jaGF0JTIwJTNEJTIwcHJvY2Vzc29yLmFwcGx5X2NoYXRfdGVtcGxhdGUoJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlMkMlMEElMjAlMjAlMjAlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwc2FtcGxlX2luZGljZXNfZm4lM0RzYW1wbGVfaW5kaWNlc19mbiUyQyUwQSUyMCUyMCUyMCUyMHZpZGVvX2xvYWRfYmFja2VuZCUzRCUyMmRlY29yZCUyMiUyQyUwQSklMEFwcmludChwcm9jZXNzZWRfY2hhdC5rZXlzKCkp",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">sample_indices_fn</span>(<span class="hljs-params">metadata, **kwargs</span>):
    <span class="hljs-comment"># samples only the first and the second frame</span>
    <span class="hljs-keyword">return</span> [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]

processed_chat = processor.apply_chat_template(
    messages,
    add_generation_prompt=<span class="hljs-literal">True</span>,
    tokenize=<span class="hljs-literal">True</span>,
    return_dict=<span class="hljs-literal">True</span>,
    sample_indices_fn=sample_indices_fn,
    video_load_backend=<span class="hljs-string">&quot;decord&quot;</span>,
)
<span class="hljs-built_in">print</span>(processed_chat.keys())`,wrap:!1}}),{c(){n=J("p"),n.innerHTML=u,i=p(),M=J("p"),M.textContent=y,c=p(),m=J("ul"),m.innerHTML=C,e=p(),r=J("p"),r.textContent=q,$=p(),U(b.$$.fragment)},l(d){n=T(d,"P",{"data-svelte-h":!0}),h(n)!=="svelte-1ek7sfx"&&(n.innerHTML=u),i=o(d),M=T(d,"P",{"data-svelte-h":!0}),h(M)!=="svelte-ovbw0q"&&(M.textContent=y),c=o(d),m=T(d,"UL",{"data-svelte-h":!0}),h(m)!=="svelte-1r30s8"&&(m.innerHTML=C),e=o(d),r=T(d,"P",{"data-svelte-h":!0}),h(r)!=="svelte-1eabw1j"&&(r.textContent=q),$=o(d),j(b.$$.fragment,d)},m(d,Z){a(d,n,Z),a(d,i,Z),a(d,M,Z),a(d,c,Z),a(d,m,Z),a(d,e,Z),a(d,r,Z),a(d,$,Z),w(b,d,Z),v=!0},p:os,i(d){v||(f(b.$$.fragment,d),v=!0)},o(d){I(b.$$.fragment,d),v=!1},d(d){d&&(l(n),l(i),l(M),l(c),l(m),l(e),l(r),l($)),g(b,d)}}}function we(x){let n,u="Videos may also exist as a set of sampled frames stored as images rather than the full video file.",i,M,y="In this case, pass a list of image file paths and the processor automatically concatenates them into a video. Make sure all images are the same size since they are assumed to be from the same video.",c,m,C;return m=new B({props:{code:"ZnJhbWVzX3BhdGhzJTIwJTNEJTIwJTVCJTIyJTJGcGF0aCUyRnRvJTJGZnJhbWUwLnBuZyUyMiUyQyUyMCUyMiUyRnBhdGglMkZ0byUyRmZyYW1lNS5wbmclMjIlMkMlMjAlMjIlMkZwYXRoJTJGdG8lMkZmcmFtZTEwLnBuZyUyMiU1RCUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJ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SUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEEpJTBBcHJpbnQocHJvY2Vzc2VkX2NoYXQua2V5cygpKQ==",highlighted:`frames_paths = [<span class="hljs-string">&quot;/path/to/frame0.png&quot;</span>, <span class="hljs-string">&quot;/path/to/frame5.png&quot;</span>, <span class="hljs-string">&quot;/path/to/frame10.png&quot;</span>]
messages = [
    {
        <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
        <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;You are a friendly chatbot who always responds in the style of a pirate&quot;</span>}],
    },
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;video&quot;</span>, <span class="hljs-string">&quot;path&quot;</span>: frames_paths},
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What do you see in this video?&quot;</span>},
        ],
    },
]

processed_chat = processor.apply_chat_template(
    messages,
    add_generation_prompt=<span class="hljs-literal">True</span>,
    tokenize=<span class="hljs-literal">True</span>,
    return_dict=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(processed_chat.keys())`,wrap:!1}}),{c(){n=J("p"),n.textContent=u,i=p(),M=J("p"),M.textContent=y,c=p(),U(m.$$.fragment)},l(e){n=T(e,"P",{"data-svelte-h":!0}),h(n)!=="svelte-o026q6"&&(n.textContent=u),i=o(e),M=T(e,"P",{"data-svelte-h":!0}),h(M)!=="svelte-l4ijxy"&&(M.textContent=y),c=o(e),j(m.$$.fragment,e)},m(e,r){a(e,n,r),a(e,i,r),a(e,M,r),a(e,c,r),w(m,e,r),C=!0},p:os,i(e){C||(f(m.$$.fragment,e),C=!0)},o(e){I(m.$$.fragment,e),C=!1},d(e){e&&(l(n),l(i),l(M),l(c)),g(m,e)}}}function fe(x){let n,u,i,M,y,c,m,C;return n=new Xs({props:{id:"sampling",option:"fixed number of frames",$$slots:{default:[ue]},$$scope:{ctx:x}}}),i=new Xs({props:{id:"sampling",option:"fps",$$slots:{default:[Ue]},$$scope:{ctx:x}}}),y=new Xs({props:{id:"sampling",option:"custom frame sampling",$$slots:{default:[je]},$$scope:{ctx:x}}}),m=new Xs({props:{id:"sampling",option:"list of image frames",$$slots:{default:[we]},$$scope:{ctx:x}}}),{c(){U(n.$$.fragment),u=p(),U(i.$$.fragment),M=p(),U(y.$$.fragment),c=p(),U(m.$$.fragment)},l(e){j(n.$$.fragment,e),u=o(e),j(i.$$.fragment,e),M=o(e),j(y.$$.fragment,e),c=o(e),j(m.$$.fragment,e)},m(e,r){w(n,e,r),a(e,u,r),w(i,e,r),a(e,M,r),w(y,e,r),a(e,c,r),w(m,e,r),C=!0},p(e,r){const q={};r&2&&(q.$$scope={dirty:r,ctx:e}),n.$set(q);const $={};r&2&&($.$$scope={dirty:r,ctx:e}),i.$set($);const b={};r&2&&(b.$$scope={dirty:r,ctx:e}),y.$set(b);const v={};r&2&&(v.$$scope={dirty:r,ctx:e}),m.$set(v)},i(e){C||(f(n.$$.fragment,e),f(i.$$.fragment,e),f(y.$$.fragment,e),f(m.$$.fragment,e),C=!0)},o(e){I(n.$$.fragment,e),I(i.$$.fragment,e),I(y.$$.fragment,e),I(m.$$.fragment,e),C=!1},d(e){e&&(l(u),l(M),l(c)),g(n,e),g(i,e),g(y,e),g(m,e)}}}function Ie(x){let n,u,i,M,y,c,m,C='Multimodal model chat templates expect a similar <a href="./chat_templating">template</a> as text-only models. It needs <code>messages</code> that includes a dictionary of the <code>role</code> and <code>content</code>.',e,r,q='Multimodal templates are included in the <a href="./processors">Processor</a> class and require an additional <code>type</code> key for specifying whether the included content is an image, video, or text.',$,b,v="This guide will show you how to format chat templates for multimodal models as well as some best practices for configuring the template",d,Z,rs,A,Rs='<a href="/docs/transformers/main/en/main_classes/pipelines#transformers.ImageTextToTextPipeline">ImageTextToTextPipeline</a> is a high-level image and text generation class with a “chat mode”. Chat mode is enabled when a conversational model is detected and the chat prompt is <a href="./llm_tutorial#wrong-prompt-format">properly formatted</a>.',cs,N,Vs="Start by building a chat history with the following two roles.",ms,E,Ws="<li><code>system</code> describes how the model should behave and respond when you’re chatting with it. This role isn’t supported by all chat models.</li> <li><code>user</code> is where you enter your first message to the model.</li>",ys,k,Js,X,Ys='Create a <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.ImageTextToTextPipeline">ImageTextToTextPipeline</a> and pass the chat to it. For large models, setting <a href="./models#big-model-inference">device_map=“auto”</a> helps load the model quicker and automatically places it on the fastest device available. Changing the data type to <a href="./models#model-data-type">torch.bfloat16</a> also helps save memory.',Ts,G,ds,R,hs,V,us,W,zs='For multimodal models that accept images like <a href="./model_doc/llava">LLaVA</a>, include the following in <code>content</code> as shown below.',Us,Y,Ss="<li>The content <code>&quot;type&quot;</code> can be an <code>&quot;image&quot;</code> or <code>&quot;text&quot;</code>.</li> <li>For images, it can be a link to the image (<code>&quot;url&quot;</code>), a file path (<code>&quot;path&quot;</code>), or <code>&quot;base64&quot;</code>. Images are automatically loaded, processed, and prepared into pixel values as inputs to the model.</li>",js,z,ws,S,Hs='Pass <code>messages</code> to <a href="/docs/transformers/main/en/main_classes/processors#transformers.ProcessorMixin.apply_chat_template">apply_chat_template()</a> to tokenize the input content and return the <code>input_ids</code> and <code>pixel_values</code>.',fs,H,Is,F,Fs='These inputs are now ready to be used in <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>.',gs,L,Cs,P,Ls='Some vision models also support video inputs. The message format is very similar to the format for <a href="#image-inputs">image inputs</a>.',bs,D,Ps='<li>The content <code>&quot;type&quot;</code> should be <code>&quot;video&quot;</code> to indicate the content is a video.</li> <li>For videos, it can be a link to the video (<code>&quot;url&quot;</code>) or it could be a file path (<code>&quot;path&quot;</code>). Videos loaded from a URL can only be decoded with <a href="https://pyav.basswood-io.com/docs/stable/" rel="nofollow">PyAV</a> or <a href="https://github.com/dmlc/decord" rel="nofollow">Decord</a>.</li>',Zs,_,xs,K,$s,O,Ds='Pass <code>messages</code> to <a href="/docs/transformers/main/en/main_classes/processors#transformers.ProcessorMixin.apply_chat_template">apply_chat_template()</a> to tokenize the input content. There are a few extra parameters to include in <a href="/docs/transformers/main/en/main_classes/processors#transformers.ProcessorMixin.apply_chat_template">apply_chat_template()</a> that controls the sampling process.',vs,ss,Ks='The <code>video_load_backend</code> parameter refers to a specific framework to load a video. It supports <a href="https://pyav.basswood-io.com/docs/stable/" rel="nofollow">PyAV</a>, <a href="https://github.com/dmlc/decord" rel="nofollow">Decord</a>, <a href="https://github.com/opencv/opencv" rel="nofollow">OpenCV</a>, and <a href="https://pytorch.org/vision/stable/index.html" rel="nofollow">torchvision</a>.',Bs,es,Os="The examples below use Decord as the backend because it is a bit faster than PyAV.",qs,Q,Gs,ls,_s,ts,se='You can create a custom chat template with <a href="https://jinja.palletsprojects.com/en/3.1.x/templates/" rel="nofollow">Jinja</a> and set it with <a href="/docs/transformers/main/en/main_classes/processors#transformers.ProcessorMixin.apply_chat_template">apply_chat_template()</a>. Refer to the <a href="./chat_templating_writing">Template writing</a> guide for more details.',Qs,as,ee='For example, to enable a template to handle a <em>list of content</em> from multiple modalities while still supporting plain strings for text-only inference, specify how to handle the <code>content[&#39;type&#39;]</code> if it is an image or text as shown below in the Llama 3.2 Vision Instruct <a href="https://huggingface.co/meta-llama/Llama-3.2-11B-Vision-Instruct/blob/main/chat_template.json" rel="nofollow">template</a>.',As,ns,Ns,ps,Es,is,ks;return y=new Ms({props:{title:"Multimodal templates",local:"multimodal-templates",headingTag:"h1"}}),Z=new Ms({props:{title:"ImageTextToTextPipeline",local:"imagetexttotextpipeline",headingTag:"h2"}}),k=new B({props:{code:"bWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBmcmllbmRseSUyMGNoYXRib3QlMjB3aG8lMjBhbHdheXMlMjByZXNwb25kcyUyMGluJTIwdGhlJTIwc3R5bGUlMjBvZiUyMGElMjBwaXJhdGUlMjIlN0QlNUQlMkMlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlMkMlMjAlMjJ1cmwlMjIlM0ElMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyV2hhdCUyMGFyZSUyMHRoZXNlJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTVE",highlighted:`messages = [
    {
        <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
        <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;You are a friendly chatbot who always responds in the style of a pirate&quot;</span>}],
    },
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>},
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What are these?&quot;</span>},
        ],
    },
]`,wrap:!1}}),G=new oe({props:{warning:!1,$$slots:{default:[de]},$$scope:{ctx:x}}}),R=new B({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lKCUyMmltYWdlLXRleHQtdG8tdGV4dCUyMiUyQyUyMG1vZGVsJTNEJTIybGxhdmEtaGYlMkZsbGF2YS1vbmV2aXNpb24tcXdlbjItMC41Yi1vdi1oZiUyMiUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZWxpbmUodGV4dCUzRG1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UaGUlMjBjYXQlMjBvbiUyMHRoZSUyMGxlZnQlMjBoYXMlMjBhJTIwc3RyaXBlZCUyMGNvYXQlMkMlMjB0eXBpY2FsJTIwb2YlMjB0YWJieSUyMGNhdHMlMkMlMjBhbmQlMjBpcyUyMGx5aW5nJTIwb24lMjBpdHMlMjBzaWRlJTIwd2l0aCUyMGl0cyUyMGhlYWQlMjByZXN0aW5nJTIwb24lMjB0aGUnJTdEJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipeline = pipeline(<span class="hljs-string">&quot;image-text-to-text&quot;</span>, model=<span class="hljs-string">&quot;llava-hf/llava-onevision-qwen2-0.5b-ov-hf&quot;</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>, torch_dtype=torch.float16)
pipeline(text=messages, max_new_tokens=<span class="hljs-number">50</span>, return_full_text=<span class="hljs-literal">False</span>)
[{<span class="hljs-string">&#x27;input_text&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;system&#x27;</span>,
    <span class="hljs-string">&#x27;content&#x27;</span>: [{<span class="hljs-string">&#x27;type&#x27;</span>: <span class="hljs-string">&#x27;text&#x27;</span>,
      <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;You are a friendly chatbot who always responds in the style of a pirate&#x27;</span>}]},
   {<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;user&#x27;</span>,
    <span class="hljs-string">&#x27;content&#x27;</span>: [{<span class="hljs-string">&#x27;type&#x27;</span>: <span class="hljs-string">&#x27;image&#x27;</span>,
      <span class="hljs-string">&#x27;url&#x27;</span>: <span class="hljs-string">&#x27;http://images.cocodataset.org/val2017/000000039769.jpg&#x27;</span>},
     {<span class="hljs-string">&#x27;type&#x27;</span>: <span class="hljs-string">&#x27;text&#x27;</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;What are these?&#x27;</span>}]}],
  <span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;The image shows two cats lying on a pink surface, which appears to be a cushion or a soft blanket. The cat on the left has a striped coat, typical of tabby cats, and is lying on its side with its head resting on the&#x27;</span>}]`,wrap:!1}}),V=new Ms({props:{title:"Image inputs",local:"image-inputs",headingTag:"h2"}}),z=new B({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBMbGF2YU9uZXZpc2lvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwTGxhdmFPbmV2aXNpb25Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmxsYXZhLWhmJTJGbGxhdmEtb25ldmlzaW9uLXF3ZW4yLTAuNWItb3YtaGYlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybGxhdmEtaGYlMkZsbGF2YS1vbmV2aXNpb24tcXdlbjItMC41Yi1vdi1oZiUyMiklMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJjb250ZW50JTIyJTNBJTIwJTVCJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyWW91JTIwYXJlJTIwYSUyMGZyaWVuZGx5JTIwY2hhdGJvdCUyMHdobyUyMGFsd2F5cyUyMHJlc3BvbmRzJTIwaW4lMjB0aGUlMjBzdHlsZSUyMG9mJTIwYSUyMHBpcmF0ZSUyMiU3RCU1RCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiUyQyUyMCUyMnVybCUyMiUzQSUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIydGV4dCUyMiUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjJXaGF0JTIwYXJlJTIwdGhlc2UlM0YlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElNUQ=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LlavaOnevisionForConditionalGeneration

model = LlavaOnevisionForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;llava-hf/llava-onevision-qwen2-0.5b-ov-hf&quot;</span>)
processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;llava-hf/llava-onevision-qwen2-0.5b-ov-hf&quot;</span>)

messages = [
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;You are a friendly chatbot who always responds in the style of a pirate&quot;</span>}],
    },
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>},
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What are these?&quot;</span>},
        ],
    },
]`,wrap:!1}}),H=new B({props:{code:"cHJvY2Vzc2VkX2NoYXQlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZShtZXNzYWdlcyUyQyUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMjB0b2tlbml6ZSUzRFRydWUlMkMlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXByaW50KHByb2Nlc3NlZF9jaGF0LmtleXMoKSk=",highlighted:`processed_chat = processor.apply_chat_template(messages, add_generation_prompt=<span class="hljs-literal">True</span>, tokenize=<span class="hljs-literal">True</span>, return_dict=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(processed_chat.keys())`,wrap:!1}}),L=new Ms({props:{title:"Video inputs",local:"video-inputs",headingTag:"h2"}}),_=new oe({props:{warning:!0,$$slots:{default:[he]},$$scope:{ctx:x}}}),K=new B({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBMbGF2YU9uZXZpc2lvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIybGxhdmEtaGYlMkZsbGF2YS1vbmV2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ubnlfNzIwXzEwc18xME1CLm1wNCUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoYXQlMjBkbyUyMHlvdSUyMHNlZSUyMGluJTIwdGhpcyUyMHZpZGVvJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTVE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LlavaOnevisionForConditionalGeneration

model_id = <span class="hljs-string">&quot;llava-hf/llava-onevision-qwen2-0.5b-ov-hf&quot;</span>
model = LlavaOnevisionForConditionalGeneration.from_pretrained(model_id)
processor = AutoProcessor.from_pretrained(model_id)

messages = [
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;You are a friendly chatbot who always responds in the style of a pirate&quot;</span>}],
    },
    {
      <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
      <span class="hljs-string">&quot;content&quot;</span>: [
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;video&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_10MB.mp4&quot;</span>},
            {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What do you see in this video?&quot;</span>},
        ],
    },
]`,wrap:!1}}),Q=new Te({props:{id:"sampling",options:["fixed number of frames","fps","custom frame sampling","list of image frames"],$$slots:{default:[fe]},$$scope:{ctx:x}}}),ls=new Ms({props:{title:"Template configuration",local:"template-configuration",headingTag:"h2"}}),ns=new B({props:{code:"JTdCJTI1JTIwZm9yJTIwbWVzc2FnZSUyMGluJTIwbWVzc2FnZXMlMjAlMjUlN0QlMEElN0IlMjUlMjBpZiUyMGxvb3AuaW5kZXgwJTIwJTNEJTNEJTIwMCUyMCUyNSU3RCU3QiU3QiUyMGJvc190b2tlbiUyMCU3RCU3RCU3QiUyNSUyMGVuZGlmJTIwJTI1JTdEJTBBJTdCJTdCJTIwJyUzQyU3Q3N0YXJ0X2hlYWRlcl9pZCU3QyUzRSclMjAlMkIlMjBtZXNzYWdlJTVCJ3JvbGUnJTVEJTIwJTJCJTIwJyUzQyU3Q2VuZF9oZWFkZXJfaWQlN0MlM0UlNUNuJTVDbiclMjAlN0QlN0QlMEElN0IlMjUlMjBpZiUyMG1lc3NhZ2UlNUInY29udGVudCclNUQlMjBpcyUyMHN0cmluZyUyMCUyNSU3RCUwQSU3QiU3QiUyMG1lc3NhZ2UlNUInY29udGVudCclNUQlMjAlN0QlN0QlMEElN0IlMjUlMjBlbHNlJTIwJTI1JTdEJTBBJTdCJTI1JTIwZm9yJTIwY29udGVudCUyMGluJTIwbWVzc2FnZSU1Qidjb250ZW50JyU1RCUyMCUyNSU3RCUwQSU3QiUyNSUyMGlmJTIwY29udGVudCU1Qid0eXBlJyU1RCUyMCUzRCUzRCUyMCdpbWFnZSclMjAlMjUlN0QlMEElN0IlN0IlMjAnJTNDJTdDaW1hZ2UlN0MlM0UnJTIwJTdEJTdEJTBBJTdCJTI1JTIwZWxpZiUyMGNvbnRlbnQlNUIndHlwZSclNUQlMjAlM0QlM0QlMjAndGV4dCclMjAlMjUlN0QlMEElN0IlN0IlMjBjb250ZW50JTVCJ3RleHQnJTVEJTIwJTdEJTdEJTBBJTdCJTI1JTIwZW5kaWYlMjAlMjUlN0QlMEElN0IlMjUlMjBlbmRmb3IlMjAlMjUlN0QlMEElN0IlMjUlMjBlbmRpZiUyMCUyNSU3RCUwQSU3QiU3QiUyMCclM0MlN0Nlb3RfaWQlN0MlM0UnJTIwJTdEJTdEJTBBJTdCJTI1JTIwZW5kZm9yJTIwJTI1JTdEJTBBJTdCJTI1JTIwaWYlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlMjAlMjUlN0QlN0IlN0IlMjAnJTNDJTdDc3RhcnRfaGVhZGVyX2lkJTdDJTNFYXNzaXN0YW50JTNDJTdDZW5kX2hlYWRlcl9pZCU3QyUzRSU1Q24lNUNuJyUyMCU3RCU3RCU3QiUyNSUyMGVuZGlmJTIwJTI1JTdE",highlighted:`<span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">for</span></span> message <span class="hljs-keyword">in</span> messages %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">if</span></span> loop.index0 == 0 %}</span><span class="hljs-template-variable">{{ bos_token }}</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endif</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ &#x27;&lt;|start_header_id|&gt;&#x27; + message[&#x27;role&#x27;] + &#x27;&lt;|end_header_id|&gt;\\n\\n&#x27; }}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">if</span></span> message[&#x27;content&#x27;] is string %}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ message[&#x27;content&#x27;] }}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">else</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">for</span></span> content <span class="hljs-keyword">in</span> message[&#x27;content&#x27;] %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">if</span></span> content[&#x27;type&#x27;] == &#x27;image&#x27; %}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ &#x27;&lt;|image|&gt;&#x27; }}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">elif</span></span> content[&#x27;type&#x27;] == &#x27;text&#x27; %}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ content[&#x27;text&#x27;] }}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endif</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endfor</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endif</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-variable">{{ &#x27;&lt;|eot_id|&gt;&#x27; }}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endfor</span></span> %}</span><span class="language-xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">if</span></span> add_generation_prompt %}</span><span class="hljs-template-variable">{{ &#x27;&lt;|start_header_id|&gt;assistant&lt;|end_header_id|&gt;\\n\\n&#x27; }}</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-name">endif</span></span> %}</span>`,wrap:!1}}),ps=new Je({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/chat_templating_multimodal.md"}}),{c(){n=J("meta"),u=p(),i=J("p"),M=p(),U(y.$$.fragment),c=p(),m=J("p"),m.innerHTML=C,e=p(),r=J("p"),r.innerHTML=q,$=p(),b=J("p"),b.textContent=v,d=p(),U(Z.$$.fragment),rs=p(),A=J("p"),A.innerHTML=Rs,cs=p(),N=J("p"),N.textContent=Vs,ms=p(),E=J("ul"),E.innerHTML=Ws,ys=p(),U(k.$$.fragment),Js=p(),X=J("p"),X.innerHTML=Ys,Ts=p(),U(G.$$.fragment),ds=p(),U(R.$$.fragment),hs=p(),U(V.$$.fragment),us=p(),W=J("p"),W.innerHTML=zs,Us=p(),Y=J("ul"),Y.innerHTML=Ss,js=p(),U(z.$$.fragment),ws=p(),S=J("p"),S.innerHTML=Hs,fs=p(),U(H.$$.fragment),Is=p(),F=J("p"),F.innerHTML=Fs,gs=p(),U(L.$$.fragment),Cs=p(),P=J("p"),P.innerHTML=Ls,bs=p(),D=J("ul"),D.innerHTML=Ps,Zs=p(),U(_.$$.fragment),xs=p(),U(K.$$.fragment),$s=p(),O=J("p"),O.innerHTML=Ds,vs=p(),ss=J("p"),ss.innerHTML=Ks,Bs=p(),es=J("p"),es.textContent=Os,qs=p(),U(Q.$$.fragment),Gs=p(),U(ls.$$.fragment),_s=p(),ts=J("p"),ts.innerHTML=se,Qs=p(),as=J("p"),as.innerHTML=ee,As=p(),U(ns.$$.fragment),Ns=p(),U(ps.$$.fragment),Es=p(),is=J("p"),this.h()},l(s){const t=me("svelte-u9bgzb",document.head);n=T(t,"META",{name:!0,content:!0}),t.forEach(l),u=o(s),i=T(s,"P",{}),ne(i).forEach(l),M=o(s),j(y.$$.fragment,s),c=o(s),m=T(s,"P",{"data-svelte-h":!0}),h(m)!=="svelte-1agojlz"&&(m.innerHTML=C),e=o(s),r=T(s,"P",{"data-svelte-h":!0}),h(r)!=="svelte-1cx8i0m"&&(r.innerHTML=q),$=o(s),b=T(s,"P",{"data-svelte-h":!0}),h(b)!=="svelte-gm7wkx"&&(b.textContent=v),d=o(s),j(Z.$$.fragment,s),rs=o(s),A=T(s,"P",{"data-svelte-h":!0}),h(A)!=="svelte-znexrk"&&(A.innerHTML=Rs),cs=o(s),N=T(s,"P",{"data-svelte-h":!0}),h(N)!=="svelte-1rwc0gb"&&(N.textContent=Vs),ms=o(s),E=T(s,"UL",{"data-svelte-h":!0}),h(E)!=="svelte-dldyqw"&&(E.innerHTML=Ws),ys=o(s),j(k.$$.fragment,s),Js=o(s),X=T(s,"P",{"data-svelte-h":!0}),h(X)!=="svelte-1x8ndqo"&&(X.innerHTML=Ys),Ts=o(s),j(G.$$.fragment,s),ds=o(s),j(R.$$.fragment,s),hs=o(s),j(V.$$.fragment,s),us=o(s),W=T(s,"P",{"data-svelte-h":!0}),h(W)!=="svelte-bjpyoz"&&(W.innerHTML=zs),Us=o(s),Y=T(s,"UL",{"data-svelte-h":!0}),h(Y)!=="svelte-17i21u2"&&(Y.innerHTML=Ss),js=o(s),j(z.$$.fragment,s),ws=o(s),S=T(s,"P",{"data-svelte-h":!0}),h(S)!=="svelte-po3wbg"&&(S.innerHTML=Hs),fs=o(s),j(H.$$.fragment,s),Is=o(s),F=T(s,"P",{"data-svelte-h":!0}),h(F)!=="svelte-uo4xlo"&&(F.innerHTML=Fs),gs=o(s),j(L.$$.fragment,s),Cs=o(s),P=T(s,"P",{"data-svelte-h":!0}),h(P)!=="svelte-1ldrrkv"&&(P.innerHTML=Ls),bs=o(s),D=T(s,"UL",{"data-svelte-h":!0}),h(D)!=="svelte-1qmo9q2"&&(D.innerHTML=Ps),Zs=o(s),j(_.$$.fragment,s),xs=o(s),j(K.$$.fragment,s),$s=o(s),O=T(s,"P",{"data-svelte-h":!0}),h(O)!=="svelte-gv51q6"&&(O.innerHTML=Ds),vs=o(s),ss=T(s,"P",{"data-svelte-h":!0}),h(ss)!=="svelte-mmdb9c"&&(ss.innerHTML=Ks),Bs=o(s),es=T(s,"P",{"data-svelte-h":!0}),h(es)!=="svelte-12n779"&&(es.textContent=Os),qs=o(s),j(Q.$$.fragment,s),Gs=o(s),j(ls.$$.fragment,s),_s=o(s),ts=T(s,"P",{"data-svelte-h":!0}),h(ts)!=="svelte-1fbpi9q"&&(ts.innerHTML=se),Qs=o(s),as=T(s,"P",{"data-svelte-h":!0}),h(as)!=="svelte-1gbnbdg"&&(as.innerHTML=ee),As=o(s),j(ns.$$.fragment,s),Ns=o(s),j(ps.$$.fragment,s),Es=o(s),is=T(s,"P",{}),ne(is).forEach(l),this.h()},h(){pe(n,"name","hf:doc:metadata"),pe(n,"content",ge)},m(s,t){ye(document.head,n),a(s,u,t),a(s,i,t),a(s,M,t),w(y,s,t),a(s,c,t),a(s,m,t),a(s,e,t),a(s,r,t),a(s,$,t),a(s,b,t),a(s,d,t),w(Z,s,t),a(s,rs,t),a(s,A,t),a(s,cs,t),a(s,N,t),a(s,ms,t),a(s,E,t),a(s,ys,t),w(k,s,t),a(s,Js,t),a(s,X,t),a(s,Ts,t),w(G,s,t),a(s,ds,t),w(R,s,t),a(s,hs,t),w(V,s,t),a(s,us,t),a(s,W,t),a(s,Us,t),a(s,Y,t),a(s,js,t),w(z,s,t),a(s,ws,t),a(s,S,t),a(s,fs,t),w(H,s,t),a(s,Is,t),a(s,F,t),a(s,gs,t),w(L,s,t),a(s,Cs,t),a(s,P,t),a(s,bs,t),a(s,D,t),a(s,Zs,t),w(_,s,t),a(s,xs,t),w(K,s,t),a(s,$s,t),a(s,O,t),a(s,vs,t),a(s,ss,t),a(s,Bs,t),a(s,es,t),a(s,qs,t),w(Q,s,t),a(s,Gs,t),w(ls,s,t),a(s,_s,t),a(s,ts,t),a(s,Qs,t),a(s,as,t),a(s,As,t),w(ns,s,t),a(s,Ns,t),w(ps,s,t),a(s,Es,t),a(s,is,t),ks=!0},p(s,[t]){const le={};t&2&&(le.$$scope={dirty:t,ctx:s}),G.$set(le);const te={};t&2&&(te.$$scope={dirty:t,ctx:s}),_.$set(te);const ae={};t&2&&(ae.$$scope={dirty:t,ctx:s}),Q.$set(ae)},i(s){ks||(f(y.$$.fragment,s),f(Z.$$.fragment,s),f(k.$$.fragment,s),f(G.$$.fragment,s),f(R.$$.fragment,s),f(V.$$.fragment,s),f(z.$$.fragment,s),f(H.$$.fragment,s),f(L.$$.fragment,s),f(_.$$.fragment,s),f(K.$$.fragment,s),f(Q.$$.fragment,s),f(ls.$$.fragment,s),f(ns.$$.fragment,s),f(ps.$$.fragment,s),ks=!0)},o(s){I(y.$$.fragment,s),I(Z.$$.fragment,s),I(k.$$.fragment,s),I(G.$$.fragment,s),I(R.$$.fragment,s),I(V.$$.fragment,s),I(z.$$.fragment,s),I(H.$$.fragment,s),I(L.$$.fragment,s),I(_.$$.fragment,s),I(K.$$.fragment,s),I(Q.$$.fragment,s),I(ls.$$.fragment,s),I(ns.$$.fragment,s),I(ps.$$.fragment,s),ks=!1},d(s){s&&(l(u),l(i),l(M),l(c),l(m),l(e),l(r),l($),l(b),l(d),l(rs),l(A),l(cs),l(N),l(ms),l(E),l(ys),l(Js),l(X),l(Ts),l(ds),l(hs),l(us),l(W),l(Us),l(Y),l(js),l(ws),l(S),l(fs),l(Is),l(F),l(gs),l(Cs),l(P),l(bs),l(D),l(Zs),l(xs),l($s),l(O),l(vs),l(ss),l(Bs),l(es),l(qs),l(Gs),l(_s),l(ts),l(Qs),l(as),l(As),l(Ns),l(Es),l(is)),l(n),g(y,s),g(Z,s),g(k,s),g(G,s),g(R,s),g(V,s),g(z,s),g(H,s),g(L,s),g(_,s),g(K,s),g(Q,s),g(ls,s),g(ns,s),g(ps,s)}}}const ge='{"title":"Multimodal templates","local":"multimodal-templates","sections":[{"title":"ImageTextToTextPipeline","local":"imagetexttotextpipeline","sections":[],"depth":2},{"title":"Image inputs","local":"image-inputs","sections":[],"depth":2},{"title":"Video inputs","local":"video-inputs","sections":[],"depth":2},{"title":"Template configuration","local":"template-configuration","sections":[],"depth":2}],"depth":1}';function Ce(x){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends re{constructor(n){super(),ce(this,n,Ce,Ie,ie,{})}}export{qe as component};
