import{s as So,f as Vo,o as Ho,n as Ke}from"../chunks/scheduler.25b97de1.js";import{S as Yo,i as Lo,g as l,s as n,r as p,A as Ao,h as d,f as o,c as a,j as R,u as h,x as m,k as v,y as c,a as s,v as f,d as g,t as u,w as _}from"../chunks/index.d9030fc9.js";import{T as Xo}from"../chunks/Tip.baa67368.js";import{D as P}from"../chunks/Docstring.ffac8efa.js";import{C as We}from"../chunks/CodeBlock.e6cd0d95.js";import{E as co}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as B,E as Qo}from"../chunks/EditOnGithub.91d95064.js";function Do(x){let r,M="Example:",b,T,y;return T=new We({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMElkZWZpY3MyTW9kZWwlMkMlMjBJZGVmaWNzMkNvbmZpZyUwQSUyMyUyMEluaXRpYWxpemluZyUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwSWRlZmljczJDb25maWcoKSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBJZGVmaWNzMk1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics2Model, Idefics2Config
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Idefics2Config()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Idefics2Model(configuration)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){r=l("p"),r.textContent=M,b=n(),p(T.$$.fragment)},l(i){r=d(i,"P",{"data-svelte-h":!0}),m(r)!=="svelte-11lpom8"&&(r.textContent=M),b=a(i),h(T.$$.fragment,i)},m(i,I){s(i,r,I),s(i,b,I),f(T,i,I),y=!0},p:Ke,i(i){y||(g(T.$$.fragment,i),y=!0)},o(i){u(T.$$.fragment,i),y=!1},d(i){i&&(o(r),o(b)),_(T,i)}}}function Oo(x){let r,M=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){r=l("p"),r.innerHTML=M},l(b){r=d(b,"P",{"data-svelte-h":!0}),m(r)!=="svelte-fincs2"&&(r.innerHTML=M)},m(b,T){s(b,r,T)},p:Ke,d(b){b&&o(r)}}}function Ko(x){let r,M=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){r=l("p"),r.innerHTML=M},l(b){r=d(b,"P",{"data-svelte-h":!0}),m(r)!=="svelte-fincs2"&&(r.innerHTML=M)},m(b,T){s(b,r,T)},p:Ke,d(b){b&&o(r)}}}function es(x){let r,M="Example:",b,T,y;return T=new We({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbEZvclZpc2lvbjJTZXElMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQSUyMyUyME5vdGUlMjB0aGF0JTIwcGFzc2luZyUyMHRoZSUyMGltYWdlJTIwdXJscyUyMChpbnN0ZWFkJTIwb2YlMjB0aGUlMjBhY3R1YWwlMjBwaWwlMjBpbWFnZXMpJTIwdG8lMjB0aGUlMjBwcm9jZXNzb3IlMjBpcyUyMGFsc28lMjBwb3NzaWJsZSUwQWltYWdlMSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY2MSUyRjkzMDYxLTA1MC05OTE0N0RDRSUyRlN0YXR1ZS1vZi1MaWJlcnR5LUlzbGFuZC1OZXctWW9yay1CYXkuanBnJTIyKSUwQWltYWdlMiUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY1OSUyRjk0NDU5LTA1MC1EQkE0MjQ2NyUyRlNreWxpbmUtQ2hpY2Fnby5qcGclMjIpJTBBaW1hZ2UzJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmNkbi5icml0YW5uaWNhLmNvbSUyRjY4JTJGMTcwODY4LTA1MC04RERFODI2MyUyRkdvbGRlbi1HYXRlLUJyaWRnZS1TYW4tRnJhbmNpc2NvLmpwZyUyMiklMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZU00JTJGaWRlZmljczItOGItYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclZpc2lvbjJTZXEuZnJvbV9wcmV0cmFpbmVkKCUyMkh1Z2dpbmdGYWNlTTQlMkZpZGVmaWNzMi04Yi1iYXNlJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBJTBBQkFEX1dPUkRTX0lEUyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIoJTVCJTIyJTNDaW1hZ2UlM0UlMjIlMkMlMjAlMjIlM0NmYWtlX3Rva2VuX2Fyb3VuZF9pbWFnZSUzRSUyMiU1RCUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzREZhbHNlKS5pbnB1dF9pZHMlMEFFT1NfV09SRFNfSURTJTIwJTNEJTIwJTVCcHJvY2Vzc29yLnRva2VuaXplci5lb3NfdG9rZW5faWQlNUQlMEElMEElMjMlMjBDcmVhdGUlMjBpbnB1dHMlMEFwcm9tcHRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIyJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMHdlJTIwY2FuJTIwc2VlJTIwdGhlJTIwY2l0eSUyMG9mJTIwTmV3JTIwWW9yayUyQyUyMGFuZCUyMG1vcmUlMjBzcGVjaWZpY2FsbHklMjB0aGUlMjBTdGF0dWUlMjBvZiUyMExpYmVydHkuJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMiUyQyUwQSUyMCUyMCUyMkluJTIwd2hpY2glMjBjaXR5JTIwaXMlMjB0aGF0JTIwYnJpZGdlJTIwbG9jYXRlZCUzRiUzQ2ltYWdlJTNFJTIyJTJDJTBBJTVEJTBBaW1hZ2VzJTIwJTNEJTIwJTVCJTVCaW1hZ2UxJTJDJTIwaW1hZ2UyJTVEJTJDJTIwJTVCaW1hZ2UzJTVEJTVEJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0Rwcm9tcHRzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMEdlbmVyYXRlJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwYmFkX3dvcmRzX2lkcyUzREJBRF9XT1JEU19JRFMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwKSUwQWdlbmVyYXRlZF90ZXh0cyUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSUwQSUwQXByaW50KGdlbmVyYXRlZF90ZXh0cyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForVision2Seq
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Note that passing the image urls (instead of the actual pil images) to the processor is also possible</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image1 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image2 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image3 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/68/170868-050-8DDE8263/Golden-Gate-Bridge-San-Francisco.jpg&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForVision2Seq.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b-base&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>BAD_WORDS_IDS = processor.tokenizer([<span class="hljs-string">&quot;&lt;image&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;fake_token_around_image&gt;&quot;</span>], add_special_tokens=<span class="hljs-literal">False</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>EOS_WORDS_IDS = [processor.tokenizer.eos_token_id]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Create inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompts = [
<span class="hljs-meta">... </span>  <span class="hljs-string">&quot;&lt;image&gt;In this image, we can see the city of New York, and more specifically the Statue of Liberty.&lt;image&gt;In this image,&quot;</span>,
<span class="hljs-meta">... </span>  <span class="hljs-string">&quot;In which city is that bridge located?&lt;image&gt;&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>images = [[image1, image2], [image3]]
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=prompts, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs, bad_words_ids=BAD_WORDS_IDS, max_new_tokens=<span class="hljs-number">20</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_texts)
[<span class="hljs-string">&#x27;In this image, we can see the city of New York, and more specifically the Statue of Liberty. In this image, we can see the city of New York, and more specifically the Statue of Liberty.\\n\\n&#x27;</span>, <span class="hljs-string">&#x27;In which city is that bridge located?\\n\\nThe bridge is located in the city of Pittsburgh, Pennsylvania.\\n\\n\\nThe bridge is&#x27;</span>]`,wrap:!1}}),{c(){r=l("p"),r.textContent=M,b=n(),p(T.$$.fragment)},l(i){r=d(i,"P",{"data-svelte-h":!0}),m(r)!=="svelte-11lpom8"&&(r.textContent=M),b=a(i),h(T.$$.fragment,i)},m(i,I){s(i,r,I),s(i,b,I),f(T,i,I),y=!0},p:Ke,i(i){y||(g(T.$$.fragment,i),y=!0)},o(i){u(T.$$.fragment,i),y=!1},d(i){i&&(o(r),o(b)),_(T,i)}}}function ts(x){let r,M="Example:",b,T,y;return T=new We({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwSWRlZmljczJQcm9jZXNzb3IlMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMElkZWZpY3MyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZU00JTJGaWRlZmljczItOGIlMjIlMkMlMjBpbWFnZV9zZXFfbGVuJTNEMiklMEFwcm9jZXNzb3IuaW1hZ2VfcHJvY2Vzc29yLmRvX2ltYWdlX3NwbGl0dGluZyUyMCUzRCUyMEZhbHNlJTIwJTIwJTIzJTIwRm9yY2UlMjBhcyUyMEZhbHNlJTIwdG8lMjBzaW1wbGlmeSUyMHRoZSUyMGV4YW1wbGUlMEElMEF1cmwxJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY2MSUyRjkzMDYxLTA1MC05OTE0N0RDRSUyRlN0YXR1ZS1vZi1MaWJlcnR5LUlzbGFuZC1OZXctWW9yay1CYXkuanBnJTIyJTBBdXJsMiUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGY2RuLmJyaXRhbm5pY2EuY29tJTJGNTklMkY5NDQ1OS0wNTAtREJBNDI0NjclMkZTa3lsaW5lLUNoaWNhZ28uanBnJTIyJTBBJTBBaW1hZ2UxJTJDJTIwaW1hZ2UyJTIwJTNEJTIwbG9hZF9pbWFnZSh1cmwxKSUyQyUyMGxvYWRfaW1hZ2UodXJsMiklMEFpbWFnZXMlMjAlM0QlMjAlNUIlNUJpbWFnZTElNUQlMkMlMjAlNUJpbWFnZTIlNUQlNUQlMEElMEF0ZXh0JTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMHdlJTIwc2VlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyYmxhJTIwYmxhJTIwYmxhJTNDaW1hZ2UlM0UlMjIlMkMlMEElNUQlMEFvdXRwdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwaW1hZ2VzJTNEaW1hZ2VzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQWlucHV0X2lkcyUyMCUzRCUyMG91dHB1dHMuaW5wdXRfaWRzJTBBaW5wdXRfdG9rZW5zJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplci5iYXRjaF9kZWNvZGUoaW5wdXRfaWRzKSUwQXByaW50KGlucHV0X3Rva2Vucyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics2Processor
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = Idefics2Processor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>, image_seq_len=<span class="hljs-number">2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor.image_processor.do_image_splitting = <span class="hljs-literal">False</span>  <span class="hljs-comment"># Force as False to simplify the example</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>url1 = <span class="hljs-string">&quot;https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url2 = <span class="hljs-string">&quot;https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image1, image2 = load_image(url1), load_image(url2)
<span class="hljs-meta">&gt;&gt;&gt; </span>images = [[image1], [image2]]

<span class="hljs-meta">&gt;&gt;&gt; </span>text = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&lt;image&gt;In this image, we see&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;bla bla bla&lt;image&gt;&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = processor(text=text, images=images, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = outputs.input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>input_tokens = processor.tokenizer.batch_decode(input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(input_tokens)
[<span class="hljs-string">&#x27;&lt;s&gt;&lt;fake_token_around_image&gt;&lt;image&gt;&lt;image&gt;&lt;fake_token_around_image&gt; In this image, we see&#x27;</span>, <span class="hljs-string">&#x27;&lt;s&gt; bla bla bla&lt;fake_token_around_image&gt;&lt;image&gt;&lt;image&gt;&lt;fake_token_around_image&gt;&#x27;</span>]`,wrap:!1}}),{c(){r=l("p"),r.textContent=M,b=n(),p(T.$$.fragment)},l(i){r=d(i,"P",{"data-svelte-h":!0}),m(r)!=="svelte-11lpom8"&&(r.textContent=M),b=a(i),h(T.$$.fragment,i)},m(i,I){s(i,r,I),s(i,b,I),f(T,i,I),y=!0},p:Ke,i(i){y||(g(T.$$.fragment,i),y=!0)},o(i){u(T.$$.fragment,i),y=!1},d(i){i&&(o(r),o(b)),_(T,i)}}}function os(x){let r,M,b,T,y,i,I,et,A,mo='The Idefics2 model was proposed in <a href="https://arxiv.org/abs/2405.02246" rel="nofollow">What matters when building vision-language models?</a> by Léo Tronchon, Hugo Laurencon, Victor Sanh. The accompanying blog post can be found <a href="https://huggingface.co/blog/idefics2" rel="nofollow">here</a>.',tt,Q,po=`Idefics2 is an open multimodal model that accepts arbitrary sequences of image and text inputs and produces text
outputs. The model can answer questions about images, describe visual content, create stories grounded on multiple
images, or simply behave as a pure language model without visual inputs. It improves upon IDEFICS-1, notably on
document understanding, OCR, or visual reasoning. Idefics2 is lightweight (8 billion parameters) and treats
images in their native aspect ratio and resolution, which allows for varying inference efficiency.`,ot,D,ho="The abstract from the paper is the following:",st,O,fo="<em>The growing interest in vision-language models (VLMs) has been driven by improvements in large language models and vision transformers. Despite the abundance of literature on this subject, we observe that critical decisions regarding the design of VLMs are often not justified. We argue that these unsupported decisions impede progress in the field by making it difficult to identify which choices improve model performance. To address this issue, we conduct extensive experiments around pre-trained models, architecture choice, data, and training methods. Our consolidation of findings includes the development of Idefics2, an efficient foundational VLM of 8 billion parameters. Idefics2 achieves state-of-the-art performance within its size category across various multimodal benchmarks, and is often on par with models four times its size. We release the model (base, instructed, and chat) along with the datasets created for its training.</em>",nt,q,go,at,K,uo='Idefics2 architecture. Taken from the <a href="https://arxiv.org/abs/2405.02246">original paper.</a>',rt,ee,_o=`This model was contributed by <a href="https://huggingface.co/amyeroberts" rel="nofollow">amyeroberts</a>.
The original code can be found <a href="https://huggingface.co/HuggingFaceM4/idefics2" rel="nofollow">here</a>.`,it,te,lt,oe,bo="<li>Each sample can contain multiple images, and the number of images can vary between samples. The processor will pad the inputs to the maximum number of images in a batch for input to the model.</li> <li>The processor has a <code>do_image_splitting</code> option. If <code>True</code>, each input image will be split into 4 sub-images, and concatenated with the original to form 5 images. This is useful for increasing model performance. Make sure <code>processor.image_processor.do_image_splitting</code> is set to <code>False</code> if the model was not trained with this option.</li> <li><code>text</code> passed to the processor should have the <code>&lt;image&gt;</code> tokens where the images should be inserted. And <code>&lt;end_of_utterance&gt;</code> at the end of each utterance if the text is a chat message.</li> <li>The processor has its own <code>apply_chat_template</code> method to convert chat messages to text that can then be passed as <code>text</code> to the processor.</li>",dt,se,To="Example of how to use the processor on chat messages:",ct,ne,mt,ae,pt,re,yo='The code snippets above showcase inference without any optimization tricks. However, one can drastically speed up the model by leveraging <a href="../perf_train_gpu_one.md#flash-attention-2">Flash Attention</a>, which is a faster implementation of the attention mechanism used inside the model.',ht,ie,Mo="First, make sure to install the latest version of Flash Attention 2 to include the sliding window attention feature.",ft,le,gt,de,Io='Make also sure that you have a hardware that is compatible with Flash-Attention 2. Read more about it in the official documentation of the <a href="https://github.com/Dao-AILab/flash-attention" rel="nofollow">flash attention repository</a>. Make also sure to load your model in half-precision (e.g. <code>torch.float16</code>)',ut,ce,wo="To load and run a model using Flash Attention-2, simply change the code snippet above with the following change:",_t,me,bt,pe,Tt,he,vo='As the Idefics2 model has 8 billion parameters, that would require about 16GB of GPU RAM in half precision (float16), since each parameter is stored in 2 bytes. However, one can shrink down the size of the model using <a href="../quantization.md">quantization</a>. If the model is quantized to 4 bits (or half a byte per parameter), that requires only about 3.5GB of RAM.',yt,fe,Jo='Quantizing a model is as simple as passing a <code>quantization_config</code> to the model. One can change the code snippet above with the changes below. We’ll leverage the BitsAndyBytes quantization (but refer to <a href="../quantization.md">this page</a> for other quantization methods):',Mt,ge,It,ue,wt,_e,ko="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with Idefics2. If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",vt,be,jo='<li>A notebook on how to fine-tune Idefics2 on a custom dataset using the <a href="../main_classes/trainer.md">Trainer</a> can be found <a href="https://colab.research.google.com/drive/1NtcTgRbSBKN7pYD3Vdx1j9m8pt3fhFDB?usp=sharing" rel="nofollow">here</a>. It supports both full fine-tuning as well as (quantized) LoRa.</li> <li>A script regarding how to fine-tune Idefics2 using the TRL library can be found <a href="https://gist.github.com/edbeeching/228652fc6c2b29a1641be5a5778223cb" rel="nofollow">here</a>.</li> <li>Demo notebook regarding fine-tuning Idefics2 for JSON extraction use cases can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Idefics2" rel="nofollow">here</a>. 🌎</li>',Jt,Te,kt,J,ye,Gt,Fe,Uo=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2Model">Idefics2Model</a>. It is used to instantiate a
Idefics2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the model of the Idefics2
<a href="https://huggingface.co/HuggingFaceM4/idefics2-8b" rel="nofollow">HuggingFaceM4/idefics2-8b</a> architecture.`,Pt,Ne,zo=`Configuration objects inherit from <a href="/docs/transformers/v4.41.2/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/v4.41.2/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,qt,E,jt,Me,Ut,k,Ie,Et,Re,xo=`Idefics2 model consisting of a SIGLIP vision encoder and Mistral language decoder
This model inherits from <a href="/docs/transformers/v4.41.2/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Xt,Be,Co=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,St,w,we,Vt,Ge,$o='The <a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2Model">Idefics2Model</a> forward method, overrides the <code>__call__</code> special method.',Ht,X,Yt,Pe,Zo=`Inputs fed to the model can have an arbitrary number of images. To account for this, pixel_values fed to
the model have image padding -> (batch_size, max_num_images, 3, max_heights, max_widths) where
max_num_images is the maximum number of images among the batch_size samples in the batch.`,Lt,qe,Wo=`Padding images are not needed beyond padding the pixel_values at the entrance of the model.
For efficiency, we only pass through the vision_model’s forward the real images by
discarding the padding images i.e. pixel_values of size (image_batch_size, 3, height, width) where
image_batch_size would be 7 when num_images_per_sample=[1, 3, 1, 2] and max_num_images would be 3.`,zt,ve,xt,j,Je,At,Ee,Fo=`The Idefics2 Model with a language modeling head. It is made up a SigLIP vision encoder, with a language modeling head on top.
This model inherits from <a href="/docs/transformers/v4.41.2/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Qt,Xe,No=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Dt,C,ke,Ot,Se,Ro='The <a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2ForConditionalGeneration">Idefics2ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',Kt,S,eo,V,Ct,je,$t,$,Ue,to,Ve,Bo="Constructs a Idefics image processor.",oo,H,ze,so,He,Go="Preprocess a batch of images.",Zt,xe,Wt,U,Ce,no,Ye,Po="Constructs a IDEFICS2 processor which wraps a LLama tokenizer and IDEFICS2 image processor into a single processor.",ao,Le,qo=`<a href="/docs/transformers/v4.41.2/en/model_doc/idefics#transformers.IdeficsProcessor">IdeficsProcessor</a> offers all the functionalities of <a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2ImageProcessor">Idefics2ImageProcessor</a> and <a href="/docs/transformers/v4.41.2/en/model_doc/llama#transformers.LlamaTokenizerFast">LlamaTokenizerFast</a>. See
the docstring of <a href="/docs/transformers/v4.41.2/en/model_doc/idefics#transformers.IdeficsProcessor.__call__"><strong>call</strong>()</a> and <code>decode()</code> for more information.`,ro,G,$e,io,Ae,Eo="Processes the input prompts and returns a BatchEncoding.",lo,Y,Ft,Ze,Nt,Oe,Rt;return y=new B({props:{title:"Idefics2",local:"idefics2",headingTag:"h1"}}),I=new B({props:{title:"Overview",local:"overview",headingTag:"h2"}}),te=new B({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),ne=new We({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwSWRlZmljczJQcm9jZXNzb3IlMkMlMjBJZGVmaWNzMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMGlmJTIwdG9yY2guY3VkYS5pc19hdmFpbGFibGUoKSUyMGVsc2UlMjAlMjJjcHUlMjIlMEElMEF1cmxfMSUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEF1cmxfMiUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDIxOTU3OC5qcGclMjIlMEElMEFpbWFnZV8xJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsXzElMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBaW1hZ2VfMiUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybF8yJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQWltYWdlcyUyMCUzRCUyMCU1QmltYWdlXzElMkMlMjBpbWFnZV8yJTVEJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlN0IlMEElMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIydGV4dCUyMiUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjJXaGF0JUUyJTgwJTk5cyUyMHRoZSUyMGRpZmZlcmVuY2UlMjBiZXR3ZWVuJTIwdGhlc2UlMjB0d28lMjBpbWFnZXMlM0YlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElN0QlNUQlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBJZGVmaWNzMlByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIySHVnZ2luZ0ZhY2VNNCUyRmlkZWZpY3MyLThiJTIyKSUwQW1vZGVsJTIwJTNEJTIwSWRlZmljczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMkh1Z2dpbmdGYWNlTTQlMkZpZGVmaWNzMi04YiUyMiklMEFtb2RlbC50byhkZXZpY2UpJTBBJTBBJTIzJTIwYXQlMjBpbmZlcmVuY2UlMjB0aW1lJTJDJTIwb25lJTIwbmVlZHMlMjB0byUyMHBhc3MlMjAlNjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTYwJTIwaW4lMjBvcmRlciUyMHRvJTIwbWFrZSUyMHN1cmUlMjB0aGUlMjBtb2RlbCUyMGNvbXBsZXRlcyUyMHRoZSUyMHByb21wdCUwQXRleHQlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZShtZXNzYWdlcyUyQyUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUpJTBBcHJpbnQodGV4dCklMEElMjMlMjAnVXNlciUzQSUyMFdoYXQlRTIlODAlOTlzJTIwdGhlJTIwZGlmZmVyZW5jZSUyMGJldHdlZW4lMjB0aGVzZSUyMHR3byUyMGltYWdlcyUzRiUzQ2ltYWdlJTNFJTNDaW1hZ2UlM0UlM0NlbmRfb2ZfdXR0ZXJhbmNlJTNFJTVDbkFzc2lzdGFudCUzQSclMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2VzJTJDJTIwdGV4dCUzRHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhkZXZpY2UpJTBBJTBBZ2VuZXJhdGVkX3RleHQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENTAwKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfdGV4dCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQlMEFwcmludCglMjJHZW5lcmF0ZWQlMjB0ZXh0JTNBJTIyJTJDJTIwZ2VuZXJhdGVkX3RleHQp",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics2Processor, Idefics2ForConditionalGeneration
<span class="hljs-keyword">import</span> torch

device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>

url_1 = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
url_2 = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000219578.jpg&quot;</span>

image_1 = Image.<span class="hljs-built_in">open</span>(requests.get(url_1, stream=<span class="hljs-literal">True</span>).raw)
image_2 = Image.<span class="hljs-built_in">open</span>(requests.get(url_2, stream=<span class="hljs-literal">True</span>).raw)
images = [image_1, image_2]

messages = [{
    <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;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What’s the difference between these two images?&quot;</span>},
        {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>},
        {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>},
    ],
}]

processor = Idefics2Processor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>)
model = Idefics2ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>)
model.to(device)

<span class="hljs-comment"># at inference time, one needs to pass \`add_generation_prompt=True\` in order to make sure the model completes the prompt</span>
text = processor.apply_chat_template(messages, add_generation_prompt=<span class="hljs-literal">True</span>)
<span class="hljs-built_in">print</span>(text)
<span class="hljs-comment"># &#x27;User: What’s the difference between these two images?&lt;image&gt;&lt;image&gt;&lt;end_of_utterance&gt;\\nAssistant:&#x27;</span>

inputs = processor(images=images, text=text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device)

generated_text = model.generate(**inputs, max_new_tokens=<span class="hljs-number">500</span>)
generated_text = processor.batch_decode(generated_text, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Generated text:&quot;</span>, generated_text)`,wrap:!1}}),ae=new B({props:{title:"Model optimizations: Flash Attention",local:"model-optimizations-flash-attention",headingTag:"h2"}}),le=new We({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwZmxhc2gtYXR0biUyMC0tbm8tYnVpbGQtaXNvbGF0aW9u",highlighted:"pip install -U flash-attn --no-build-isolation",wrap:!1}}),me=new We({props:{code:"bW9kZWwlMjAlM0QlMjBJZGVmaWNzMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIySHVnZ2luZ0ZhY2VNNCUyRmlkZWZpY3MyLThiJTIyJTJDJTBBJTJCJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwJTIwJTIwJTIwJTBBJTJCJTIwJTIwJTIwJTIwYXR0bl9pbXBsZW1lbnRhdGlvbiUzRCUyMmZsYXNoX2F0dGVudGlvbl8yJTIyJTJDJTBBKS50byhkZXZpY2Up",highlighted:`model = Idefics2ForConditionalGeneration.from_pretrained(
    &quot;HuggingFaceM4/idefics2-8b&quot;,
<span class="hljs-addition">+    torch_dtype=torch.float16,    </span>
<span class="hljs-addition">+    attn_implementation=&quot;flash_attention_2&quot;,</span>
).to(device)`,wrap:!1}}),pe=new B({props:{title:"Shrinking down Idefics2 using quantization",local:"shrinking-down-idefics2-using-quantization",headingTag:"h2"}}),ge=new We({props:{code:"JTJCJTIwZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJpdHNBbmRCeXRlc0NvbmZpZyUwQSUwQSUyQiUyMHF1YW50aXphdGlvbl9jb25maWclMjAlM0QlMjBCaXRzQW5kQnl0ZXNDb25maWcoJTBBJTJCJTIwJTIwJTIwJTIwbG9hZF9pbl80Yml0JTNEVHJ1ZSUyQyUwQSUyQiUyMCUyMCUyMCUyMGJuYl80Yml0X3F1YW50X3R5cGUlM0QlMjJuZjQlMjIlMkMlMEElMkIlMjAlMjAlMjAlMjBibmJfNGJpdF91c2VfZG91YmxlX3F1YW50JTNEVHJ1ZSUyQyUwQSUyQiUyMCUyMCUyMCUyMGJuYl80Yml0X2NvbXB1dGVfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBJTJCJTIwKSUwQW1vZGVsJTIwJTNEJTIwSWRlZmljczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkh1Z2dpbmdGYWNlTTQlMkZpZGVmaWNzMi04YiUyMiUyQyUwQSUyQiUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMCUyMCUyMCUyMCUwQSUyQiUyMCUyMCUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RxdWFudGl6YXRpb25fY29uZmlnJTJDJTBBKS50byhkZXZpY2Up",highlighted:`<span class="hljs-addition">+ from transformers import BitsAndBytesConfig</span>

<span class="hljs-addition">+ quantization_config = BitsAndBytesConfig(</span>
<span class="hljs-addition">+    load_in_4bit=True,</span>
<span class="hljs-addition">+    bnb_4bit_quant_type=&quot;nf4&quot;,</span>
<span class="hljs-addition">+    bnb_4bit_use_double_quant=True,</span>
<span class="hljs-addition">+    bnb_4bit_compute_dtype=torch.float16</span>
<span class="hljs-addition">+ )</span>
model = Idefics2ForConditionalGeneration.from_pretrained(
    &quot;HuggingFaceM4/idefics2-8b&quot;,
<span class="hljs-addition">+    torch_dtype=torch.float16,    </span>
<span class="hljs-addition">+    quantization_config=quantization_config,</span>
).to(device)`,wrap:!1}}),ue=new B({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Te=new B({props:{title:"Idefics2Config",local:"transformers.Idefics2Config",headingTag:"h2"}}),ye=new P({props:{name:"class transformers.Idefics2Config",anchor:"transformers.Idefics2Config",parameters:[{name:"use_cache",val:" = True"},{name:"image_token_id",val:" = 32001"},{name:"tie_word_embeddings",val:" = False"},{name:"vision_config",val:" = None"},{name:"perceiver_config",val:" = None"},{name:"text_config",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2Config.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should cache the key/value pairs of the attention mechanism.`,name:"use_cache"},{anchor:"transformers.Idefics2Config.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 32001) &#x2014;
The id of the &#x201C;image&#x201D; token.`,name:"image_token_id"},{anchor:"transformers.Idefics2Config.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to tie the word embeddings with the token embeddings.`,name:"tie_word_embeddings"},{anchor:"transformers.Idefics2Config.vision_config",description:`<strong>vision_config</strong> (<code>IdeficsVisionConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom vision config or dict`,name:"vision_config"},{anchor:"transformers.Idefics2Config.perceiver_config",description:`<strong>perceiver_config</strong> (<code>IdeficsPerceiverConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom perceiver config or dict`,name:"perceiver_config"},{anchor:"transformers.Idefics2Config.text_config",description:`<strong>text_config</strong> (<code>MistralConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom text config or dict for the text model`,name:"text_config"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/configuration_idefics2.py#L179"}}),E=new co({props:{anchor:"transformers.Idefics2Config.example",$$slots:{default:[Do]},$$scope:{ctx:x}}}),Me=new B({props:{title:"Idefics2Model",local:"transformers.Idefics2Model",headingTag:"h2"}}),Ie=new P({props:{name:"class transformers.Idefics2Model",anchor:"transformers.Idefics2Model",parameters:[{name:"config",val:": Idefics2Config"}],parametersDescription:[{anchor:"transformers.Idefics2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2Config">Idefics2Config</a> or <code>Idefics2VisionConfig</code>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.41.2/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/modeling_idefics2.py#L1463"}}),we=new P({props:{name:"forward",anchor:"transformers.Idefics2Model.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"pixel_values",val:": Optional = None"},{name:"pixel_attention_mask",val:": Optional = None"},{name:"image_hidden_states",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Idefics2Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Idefics2Model.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.Idefics2Model.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. <a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Idefics2Model.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.Idefics2Model.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Idefics2Model.forward.pixel_values",description:'<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)) -- The tensors corresponding to the input images. Pixel values can be obtained using [AutoImageProcessor](/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/v4.41.2/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/v4.41.2/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics2Model.forward.pixel_attention_mask",description:`<strong>pixel_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics2Model.forward.image_hidden_states",description:`<strong>image_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The hidden states of the image encoder after modality projection and perceiver resampling.`,name:"image_hidden_states"},{anchor:"transformers.Idefics2Model.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.Idefics2Model.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.Idefics2Model.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.Idefics2Model.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.41.2/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/modeling_idefics2.py#L1545"}}),X=new Xo({props:{$$slots:{default:[Oo]},$$scope:{ctx:x}}}),ve=new B({props:{title:"Idefics2ForConditionalGeneration",local:"transformers.Idefics2ForConditionalGeneration",headingTag:"h2"}}),Je=new P({props:{name:"class transformers.Idefics2ForConditionalGeneration",anchor:"transformers.Idefics2ForConditionalGeneration",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Idefics2ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2Config">Idefics2Config</a> or <code>Idefics2VisionConfig</code>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.41.2/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/modeling_idefics2.py#L1687"}}),ke=new P({props:{name:"forward",anchor:"transformers.Idefics2ForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"pixel_values",val:": Optional = None"},{name:"pixel_attention_mask",val:": Optional = None"},{name:"image_hidden_states",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Idefics2ForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. <a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.pixel_values",description:'<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)) -- The tensors corresponding to the input images. Pixel values can be obtained using [AutoImageProcessor](/docs/transformers/v4.41.2/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/v4.41.2/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/v4.41.2/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.pixel_attention_mask",description:`<strong>pixel_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.image_hidden_states",description:`<strong>image_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The hidden states of the image encoder after modality projection and perceiver resampling.`,name:"image_hidden_states"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.41.2/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p>
<p>Args &#x2014;
labels (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>):
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or <code>model.image_token_id</code> (where <code>model</code> is your instance of <code>Idefics2ForConditionalGeneration</code>).
Tokens with indices set to <code>model.image_token_id</code> are ignored (masked), the loss is only
computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/modeling_idefics2.py#L1757",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.idefics2.modeling_idefics2.Idefics2CausalLMOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2Config"
>Idefics2Config</a>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</li>
<li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</li>
<li><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>)
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</li>
<li><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</li>
<li><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</li>
<li><strong>image_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the image embeddings, <code>(batch_size, num_images, sequence_length, hidden_size)</code>.
image_hidden_states of the model produced by the vision encoder, and optionally by the perceiver</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.idefics2.modeling_idefics2.Idefics2CausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),S=new Xo({props:{$$slots:{default:[Ko]},$$scope:{ctx:x}}}),V=new co({props:{anchor:"transformers.Idefics2ForConditionalGeneration.forward.example",$$slots:{default:[es]},$$scope:{ctx:x}}}),je=new B({props:{title:"Idefics2ImageProcessor",local:"transformers.Idefics2ImageProcessor",headingTag:"h2"}}),Ue=new P({props:{name:"class transformers.Idefics2ImageProcessor",anchor:"transformers.Idefics2ImageProcessor",parameters:[{name:"do_convert_rgb",val:": bool = True"},{name:"do_resize",val:": bool = True"},{name:"size",val:": Dict = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": float = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": bool = True"},{name:"do_image_splitting",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2ImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB. This is useful if the input image is of a different format e.g. RGBA.
Only has an effect if the input image is in the PIL format.`,name:"do_convert_rgb"},{anchor:"transformers.Idefics2ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image. The longest edge of the image is resized to  be &lt;= <code>size[&quot;longest_edge&quot;]</code>, with the
shortest edge resized to keep the input aspect ratio, with a minimum size of <code>size[&quot;shortest_edge&quot;]</code>.`,name:"do_resize"},{anchor:"transformers.Idefics2ImageProcessor.size",description:`<strong>size</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
Controls the size of the output image. This is a dictionary containing the keys &#x201C;shortest_edge&#x201D; and &#x201C;longest_edge&#x201D;.`,name:"size"},{anchor:"transformers.Idefics2ImageProcessor.resample",description:`<strong>resample</strong> (<code>Resampling</code>, <em>optional</em>, defaults to <code>Resampling.BILINEAR</code>) &#x2014;
Resampling filter to use when resizing the image.`,name:"resample"},{anchor:"transformers.Idefics2ImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image. If set to <code>True</code>, the image is rescaled to have pixel values between 0 and 1.`,name:"do_rescale"},{anchor:"transformers.Idefics2ImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Idefics2ImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. If set to <code>True</code>, the image is normalized to have a mean of <code>image_mean</code> and
a standard deviation of <code>image_std</code>.`,name:"do_normalize"},{anchor:"transformers.Idefics2ImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IDEFICS_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method. Can be
overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.Idefics2ImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IDEFICS_STANDARD_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.
Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.Idefics2ImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to pad the images to the largest height and width in the batch and number of images per
sample in the batch, such that the returned tensor is of shape (batch_size, max_num_images, num_channels, max_height, max_width).`,name:"do_pad"},{anchor:"transformers.Idefics2ImageProcessor.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to split the image into a sequence 4 equal sub-images concatenated with the original image. That
strategy was first introduced in <a href="https://arxiv.org/abs/2311.06607" rel="nofollow">https://arxiv.org/abs/2311.06607</a>.`,name:"do_image_splitting"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/image_processing_idefics2.py#L181"}}),ze=new P({props:{name:"preprocess",anchor:"transformers.Idefics2ImageProcessor.preprocess",parameters:[{name:"images",val:": Union"},{name:"do_convert_rgb",val:": Optional = None"},{name:"do_resize",val:": Optional = None"},{name:"size",val:": Optional = None"},{name:"resample",val:": Resampling = None"},{name:"do_rescale",val:": Optional = None"},{name:"rescale_factor",val:": Optional = None"},{name:"do_normalize",val:": Optional = None"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": Optional = None"},{name:"do_image_splitting",val:": Optional = None"},{name:"return_tensors",val:": Union = None"},{name:"input_data_format",val:": Optional = None"},{name:"data_format",val:": Optional = <ChannelDimension.FIRST: 'channels_first'>"}],parametersDescription:[{anchor:"transformers.Idefics2ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
A list of images to preprocess.`,name:"images"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the image after resizing. Shortest edge of the image is resized to size[&#x201C;shortest_edge&#x201D;], with
the longest edge resized to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only
has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to
<code>True</code>.`,name:"image_std"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether or not to pad the images to the largest height and width in the batch.`,name:"do_pad"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_image_splitting</code>) &#x2014;
Whether to split the image into a sequence 4 equal sub-images concatenated with the original image. That
strategy was first introduced in <a href="https://arxiv.org/abs/2311.06607" rel="nofollow">https://arxiv.org/abs/2311.06607</a>.`,name:"do_image_splitting"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/image_processing_idefics2.py#L425"}}),xe=new B({props:{title:"Idefics2Processor",local:"transformers.Idefics2Processor",headingTag:"h2"}}),Ce=new P({props:{name:"class transformers.Idefics2Processor",anchor:"transformers.Idefics2Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:" = None"},{name:"image_seq_len",val:": int = 64"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2Processor.image_processor",description:`<strong>image_processor</strong> (<code>Idefics2ImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.41.2/en/model_doc/idefics2#transformers.Idefics2ImageProcessor">Idefics2ImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Idefics2Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizerBase</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase">PreTrainedTokenizerBase</a>. This should correspond with the model&#x2019;s text model. The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.Idefics2Processor.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The length of the image sequence i.e. the number of <image> tokens per image in the input.
This parameter is used to build the string from the input prompt and image tokens and should match the
config.perceiver_config.resampler_n_latents value for the model used.</image>`,name:"image_seq_len"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/processing_idefics2.py#L44"}}),$e=new P({props:{name:"__call__",anchor:"transformers.Idefics2Processor.__call__",parameters:[{name:"text",val:": Union = None"},{name:"images",val:": Union = None"},{name:"image_seq_len",val:": Optional = None"},{name:"padding",val:": Union = False"},{name:"truncation",val:": Union = None"},{name:"max_length",val:": Optional = None"},{name:"is_split_into_words",val:": bool = False"},{name:"add_special_tokens",val:": bool = True"},{name:"return_tensors",val:": Union = None"}],parametersDescription:[{anchor:"transformers.Idefics2Processor.__call__.text",description:`<strong>text</strong> (<code>Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]</code>, <em>optional</em>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
(pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
<code>is_split_into_words=True</code> (to lift the ambiguity with a batch of sequences).</p>
<p>Wherever an image token, <code>&lt;image&gt;</code> is encountered it is expanded to
<code>&lt;fake_token_around_image&gt;</code> + <code>&lt;image&gt;</code> <em> <code>image_seq_len</code> </em> <fake_token_around_image>\`.</fake_token_around_image>`,name:"text"},{anchor:"transformers.Idefics2Processor.__call__.images",description:`<strong>images</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>List[PIL.Image.Image]</code>, <code>List[np.ndarray]</code>, <code>List[torch.Tensor]</code>, <em>optional</em>) &#x2014;
The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
tensor. If is of type <code>List[ImageInput]</code>, it&#x2019;s assumed that this is for a single prompt i.e. of batch size 1.`,name:"images"},{anchor:"transformers.Idefics2Processor.__call__.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the image sequence. If not provided, the default value is used.`,name:"image_seq_len"},{anchor:"transformers.Idefics2Processor.__call__.padding",description:`<strong>padding</strong> (<code>Union[bool, str, PaddingStrategy]</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Padding strategy applied to the input ids. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.pad">PreTrainedTokenizerFast.pad()</a> for more information.`,name:"padding"},{anchor:"transformers.Idefics2Processor.__call__.truncation",description:`<strong>truncation</strong> (<code>Union[bool, str, TruncationStrategy]</code>, <em>optional</em>) &#x2014;
Truncation strategy applied to the input ids. See <code>PreTrainedTokenizerFast.truncate</code> for more information.`,name:"truncation"},{anchor:"transformers.Idefics2Processor.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Maximum length of the returned list and optionally padding/truncation length. See
<a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more information.`,name:"max_length"},{anchor:"transformers.Idefics2Processor.__call__.is_split_into_words",description:`<strong>is_split_into_words</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the input text is split into words or not. If set to <code>True</code>, the tokenizer will skip the
tokenization process and assume the input is already tokenized.`,name:"is_split_into_words"},{anchor:"transformers.Idefics2Processor.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add special tokens or not. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more information.`,name:"add_special_tokens"},{anchor:"transformers.Idefics2Processor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>Union[str, TensorType]</code>, <em>optional</em>) &#x2014;
If set, will return tensors of a particular framework. See <a href="/docs/transformers/v4.41.2/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more
information.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.41.2/src/transformers/models/idefics2/processing_idefics2.py#L99"}}),Y=new co({props:{anchor:"transformers.Idefics2Processor.__call__.example",$$slots:{default:[ts]},$$scope:{ctx:x}}}),Ze=new Qo({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/idefics2.md"}}),{c(){r=l("meta"),M=n(),b=l("p"),T=n(),p(y.$$.fragment),i=n(),p(I.$$.fragment),et=n(),A=l("p"),A.innerHTML=mo,tt=n(),Q=l("p"),Q.textContent=po,ot=n(),D=l("p"),D.textContent=ho,st=n(),O=l("p"),O.innerHTML=fo,nt=n(),q=l("img"),at=n(),K=l("small"),K.innerHTML=uo,rt=n(),ee=l("p"),ee.innerHTML=_o,it=n(),p(te.$$.fragment),lt=n(),oe=l("ul"),oe.innerHTML=bo,dt=n(),se=l("p"),se.textContent=To,ct=n(),p(ne.$$.fragment),mt=n(),p(ae.$$.fragment),pt=n(),re=l("p"),re.innerHTML=yo,ht=n(),ie=l("p"),ie.textContent=Mo,ft=n(),p(le.$$.fragment),gt=n(),de=l("p"),de.innerHTML=Io,ut=n(),ce=l("p"),ce.textContent=wo,_t=n(),p(me.$$.fragment),bt=n(),p(pe.$$.fragment),Tt=n(),he=l("p"),he.innerHTML=vo,yt=n(),fe=l("p"),fe.innerHTML=Jo,Mt=n(),p(ge.$$.fragment),It=n(),p(ue.$$.fragment),wt=n(),_e=l("p"),_e.textContent=ko,vt=n(),be=l("ul"),be.innerHTML=jo,Jt=n(),p(Te.$$.fragment),kt=n(),J=l("div"),p(ye.$$.fragment),Gt=n(),Fe=l("p"),Fe.innerHTML=Uo,Pt=n(),Ne=l("p"),Ne.innerHTML=zo,qt=n(),p(E.$$.fragment),jt=n(),p(Me.$$.fragment),Ut=n(),k=l("div"),p(Ie.$$.fragment),Et=n(),Re=l("p"),Re.innerHTML=xo,Xt=n(),Be=l("p"),Be.innerHTML=Co,St=n(),w=l("div"),p(we.$$.fragment),Vt=n(),Ge=l("p"),Ge.innerHTML=$o,Ht=n(),p(X.$$.fragment),Yt=n(),Pe=l("p"),Pe.textContent=Zo,Lt=n(),qe=l("p"),qe.textContent=Wo,zt=n(),p(ve.$$.fragment),xt=n(),j=l("div"),p(Je.$$.fragment),At=n(),Ee=l("p"),Ee.innerHTML=Fo,Qt=n(),Xe=l("p"),Xe.innerHTML=No,Dt=n(),C=l("div"),p(ke.$$.fragment),Ot=n(),Se=l("p"),Se.innerHTML=Ro,Kt=n(),p(S.$$.fragment),eo=n(),p(V.$$.fragment),Ct=n(),p(je.$$.fragment),$t=n(),$=l("div"),p(Ue.$$.fragment),to=n(),Ve=l("p"),Ve.textContent=Bo,oo=n(),H=l("div"),p(ze.$$.fragment),so=n(),He=l("p"),He.textContent=Go,Zt=n(),p(xe.$$.fragment),Wt=n(),U=l("div"),p(Ce.$$.fragment),no=n(),Ye=l("p"),Ye.textContent=Po,ao=n(),Le=l("p"),Le.innerHTML=qo,ro=n(),G=l("div"),p($e.$$.fragment),io=n(),Ae=l("p"),Ae.textContent=Eo,lo=n(),p(Y.$$.fragment),Ft=n(),p(Ze.$$.fragment),Nt=n(),Oe=l("p"),this.h()},l(e){const t=Ao("svelte-u9bgzb",document.head);r=d(t,"META",{name:!0,content:!0}),t.forEach(o),M=a(e),b=d(e,"P",{}),R(b).forEach(o),T=a(e),h(y.$$.fragment,e),i=a(e),h(I.$$.fragment,e),et=a(e),A=d(e,"P",{"data-svelte-h":!0}),m(A)!=="svelte-2yybt7"&&(A.innerHTML=mo),tt=a(e),Q=d(e,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-5h9xv8"&&(Q.textContent=po),ot=a(e),D=d(e,"P",{"data-svelte-h":!0}),m(D)!=="svelte-vfdo9a"&&(D.textContent=ho),st=a(e),O=d(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-1d8hoqd"&&(O.innerHTML=fo),nt=a(e),q=d(e,"IMG",{src:!0,alt:!0,width:!0}),at=a(e),K=d(e,"SMALL",{"data-svelte-h":!0}),m(K)!=="svelte-1ry3ulw"&&(K.innerHTML=uo),rt=a(e),ee=d(e,"P",{"data-svelte-h":!0}),m(ee)!=="svelte-yuhhqz"&&(ee.innerHTML=_o),it=a(e),h(te.$$.fragment,e),lt=a(e),oe=d(e,"UL",{"data-svelte-h":!0}),m(oe)!=="svelte-ejgnpl"&&(oe.innerHTML=bo),dt=a(e),se=d(e,"P",{"data-svelte-h":!0}),m(se)!=="svelte-hckg3t"&&(se.textContent=To),ct=a(e),h(ne.$$.fragment,e),mt=a(e),h(ae.$$.fragment,e),pt=a(e),re=d(e,"P",{"data-svelte-h":!0}),m(re)!=="svelte-1sb6n2y"&&(re.innerHTML=yo),ht=a(e),ie=d(e,"P",{"data-svelte-h":!0}),m(ie)!=="svelte-o3pzzu"&&(ie.textContent=Mo),ft=a(e),h(le.$$.fragment,e),gt=a(e),de=d(e,"P",{"data-svelte-h":!0}),m(de)!=="svelte-1ehkek3"&&(de.innerHTML=Io),ut=a(e),ce=d(e,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-1pidlee"&&(ce.textContent=wo),_t=a(e),h(me.$$.fragment,e),bt=a(e),h(pe.$$.fragment,e),Tt=a(e),he=d(e,"P",{"data-svelte-h":!0}),m(he)!=="svelte-1ai4ii"&&(he.innerHTML=vo),yt=a(e),fe=d(e,"P",{"data-svelte-h":!0}),m(fe)!=="svelte-mp60zk"&&(fe.innerHTML=Jo),Mt=a(e),h(ge.$$.fragment,e),It=a(e),h(ue.$$.fragment,e),wt=a(e),_e=d(e,"P",{"data-svelte-h":!0}),m(_e)!=="svelte-ig9dca"&&(_e.textContent=ko),vt=a(e),be=d(e,"UL",{"data-svelte-h":!0}),m(be)!=="svelte-1sz5atq"&&(be.innerHTML=jo),Jt=a(e),h(Te.$$.fragment,e),kt=a(e),J=d(e,"DIV",{class:!0});var Z=R(J);h(ye.$$.fragment,Z),Gt=a(Z),Fe=d(Z,"P",{"data-svelte-h":!0}),m(Fe)!=="svelte-19nvqt"&&(Fe.innerHTML=Uo),Pt=a(Z),Ne=d(Z,"P",{"data-svelte-h":!0}),m(Ne)!=="svelte-1t2ffi5"&&(Ne.innerHTML=zo),qt=a(Z),h(E.$$.fragment,Z),Z.forEach(o),jt=a(e),h(Me.$$.fragment,e),Ut=a(e),k=d(e,"DIV",{class:!0});var W=R(k);h(Ie.$$.fragment,W),Et=a(W),Re=d(W,"P",{"data-svelte-h":!0}),m(Re)!=="svelte-178elz6"&&(Re.innerHTML=xo),Xt=a(W),Be=d(W,"P",{"data-svelte-h":!0}),m(Be)!=="svelte-hswkmf"&&(Be.innerHTML=Co),St=a(W),w=d(W,"DIV",{class:!0});var z=R(w);h(we.$$.fragment,z),Vt=a(z),Ge=d(z,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-lnn9sw"&&(Ge.innerHTML=$o),Ht=a(z),h(X.$$.fragment,z),Yt=a(z),Pe=d(z,"P",{"data-svelte-h":!0}),m(Pe)!=="svelte-felb7u"&&(Pe.textContent=Zo),Lt=a(z),qe=d(z,"P",{"data-svelte-h":!0}),m(qe)!=="svelte-58ee4k"&&(qe.textContent=Wo),z.forEach(o),W.forEach(o),zt=a(e),h(ve.$$.fragment,e),xt=a(e),j=d(e,"DIV",{class:!0});var F=R(j);h(Je.$$.fragment,F),At=a(F),Ee=d(F,"P",{"data-svelte-h":!0}),m(Ee)!=="svelte-13ydw3f"&&(Ee.innerHTML=Fo),Qt=a(F),Xe=d(F,"P",{"data-svelte-h":!0}),m(Xe)!=="svelte-hswkmf"&&(Xe.innerHTML=No),Dt=a(F),C=d(F,"DIV",{class:!0});var N=R(C);h(ke.$$.fragment,N),Ot=a(N),Se=d(N,"P",{"data-svelte-h":!0}),m(Se)!=="svelte-1wvoag4"&&(Se.innerHTML=Ro),Kt=a(N),h(S.$$.fragment,N),eo=a(N),h(V.$$.fragment,N),N.forEach(o),F.forEach(o),Ct=a(e),h(je.$$.fragment,e),$t=a(e),$=d(e,"DIV",{class:!0});var Qe=R($);h(Ue.$$.fragment,Qe),to=a(Qe),Ve=d(Qe,"P",{"data-svelte-h":!0}),m(Ve)!=="svelte-1m1ucrf"&&(Ve.textContent=Bo),oo=a(Qe),H=d(Qe,"DIV",{class:!0});var Bt=R(H);h(ze.$$.fragment,Bt),so=a(Bt),He=d(Bt,"P",{"data-svelte-h":!0}),m(He)!=="svelte-1xds4wy"&&(He.textContent=Go),Bt.forEach(o),Qe.forEach(o),Zt=a(e),h(xe.$$.fragment,e),Wt=a(e),U=d(e,"DIV",{class:!0});var L=R(U);h(Ce.$$.fragment,L),no=a(L),Ye=d(L,"P",{"data-svelte-h":!0}),m(Ye)!=="svelte-1jys543"&&(Ye.textContent=Po),ao=a(L),Le=d(L,"P",{"data-svelte-h":!0}),m(Le)!=="svelte-c0proa"&&(Le.innerHTML=qo),ro=a(L),G=d(L,"DIV",{class:!0});var De=R(G);h($e.$$.fragment,De),io=a(De),Ae=d(De,"P",{"data-svelte-h":!0}),m(Ae)!=="svelte-421t2f"&&(Ae.textContent=Eo),lo=a(De),h(Y.$$.fragment,De),De.forEach(o),L.forEach(o),Ft=a(e),h(Ze.$$.fragment,e),Nt=a(e),Oe=d(e,"P",{}),R(Oe).forEach(o),this.h()},h(){v(r,"name","hf:doc:metadata"),v(r,"content",ss),Vo(q.src,go="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/idefics2_architecture.png")||v(q,"src",go),v(q,"alt","drawing"),v(q,"width","600"),v(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){c(document.head,r),s(e,M,t),s(e,b,t),s(e,T,t),f(y,e,t),s(e,i,t),f(I,e,t),s(e,et,t),s(e,A,t),s(e,tt,t),s(e,Q,t),s(e,ot,t),s(e,D,t),s(e,st,t),s(e,O,t),s(e,nt,t),s(e,q,t),s(e,at,t),s(e,K,t),s(e,rt,t),s(e,ee,t),s(e,it,t),f(te,e,t),s(e,lt,t),s(e,oe,t),s(e,dt,t),s(e,se,t),s(e,ct,t),f(ne,e,t),s(e,mt,t),f(ae,e,t),s(e,pt,t),s(e,re,t),s(e,ht,t),s(e,ie,t),s(e,ft,t),f(le,e,t),s(e,gt,t),s(e,de,t),s(e,ut,t),s(e,ce,t),s(e,_t,t),f(me,e,t),s(e,bt,t),f(pe,e,t),s(e,Tt,t),s(e,he,t),s(e,yt,t),s(e,fe,t),s(e,Mt,t),f(ge,e,t),s(e,It,t),f(ue,e,t),s(e,wt,t),s(e,_e,t),s(e,vt,t),s(e,be,t),s(e,Jt,t),f(Te,e,t),s(e,kt,t),s(e,J,t),f(ye,J,null),c(J,Gt),c(J,Fe),c(J,Pt),c(J,Ne),c(J,qt),f(E,J,null),s(e,jt,t),f(Me,e,t),s(e,Ut,t),s(e,k,t),f(Ie,k,null),c(k,Et),c(k,Re),c(k,Xt),c(k,Be),c(k,St),c(k,w),f(we,w,null),c(w,Vt),c(w,Ge),c(w,Ht),f(X,w,null),c(w,Yt),c(w,Pe),c(w,Lt),c(w,qe),s(e,zt,t),f(ve,e,t),s(e,xt,t),s(e,j,t),f(Je,j,null),c(j,At),c(j,Ee),c(j,Qt),c(j,Xe),c(j,Dt),c(j,C),f(ke,C,null),c(C,Ot),c(C,Se),c(C,Kt),f(S,C,null),c(C,eo),f(V,C,null),s(e,Ct,t),f(je,e,t),s(e,$t,t),s(e,$,t),f(Ue,$,null),c($,to),c($,Ve),c($,oo),c($,H),f(ze,H,null),c(H,so),c(H,He),s(e,Zt,t),f(xe,e,t),s(e,Wt,t),s(e,U,t),f(Ce,U,null),c(U,no),c(U,Ye),c(U,ao),c(U,Le),c(U,ro),c(U,G),f($e,G,null),c(G,io),c(G,Ae),c(G,lo),f(Y,G,null),s(e,Ft,t),f(Ze,e,t),s(e,Nt,t),s(e,Oe,t),Rt=!0},p(e,[t]){const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),E.$set(Z);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),X.$set(W);const z={};t&2&&(z.$$scope={dirty:t,ctx:e}),S.$set(z);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),V.$set(F);const N={};t&2&&(N.$$scope={dirty:t,ctx:e}),Y.$set(N)},i(e){Rt||(g(y.$$.fragment,e),g(I.$$.fragment,e),g(te.$$.fragment,e),g(ne.$$.fragment,e),g(ae.$$.fragment,e),g(le.$$.fragment,e),g(me.$$.fragment,e),g(pe.$$.fragment,e),g(ge.$$.fragment,e),g(ue.$$.fragment,e),g(Te.$$.fragment,e),g(ye.$$.fragment,e),g(E.$$.fragment,e),g(Me.$$.fragment,e),g(Ie.$$.fragment,e),g(we.$$.fragment,e),g(X.$$.fragment,e),g(ve.$$.fragment,e),g(Je.$$.fragment,e),g(ke.$$.fragment,e),g(S.$$.fragment,e),g(V.$$.fragment,e),g(je.$$.fragment,e),g(Ue.$$.fragment,e),g(ze.$$.fragment,e),g(xe.$$.fragment,e),g(Ce.$$.fragment,e),g($e.$$.fragment,e),g(Y.$$.fragment,e),g(Ze.$$.fragment,e),Rt=!0)},o(e){u(y.$$.fragment,e),u(I.$$.fragment,e),u(te.$$.fragment,e),u(ne.$$.fragment,e),u(ae.$$.fragment,e),u(le.$$.fragment,e),u(me.$$.fragment,e),u(pe.$$.fragment,e),u(ge.$$.fragment,e),u(ue.$$.fragment,e),u(Te.$$.fragment,e),u(ye.$$.fragment,e),u(E.$$.fragment,e),u(Me.$$.fragment,e),u(Ie.$$.fragment,e),u(we.$$.fragment,e),u(X.$$.fragment,e),u(ve.$$.fragment,e),u(Je.$$.fragment,e),u(ke.$$.fragment,e),u(S.$$.fragment,e),u(V.$$.fragment,e),u(je.$$.fragment,e),u(Ue.$$.fragment,e),u(ze.$$.fragment,e),u(xe.$$.fragment,e),u(Ce.$$.fragment,e),u($e.$$.fragment,e),u(Y.$$.fragment,e),u(Ze.$$.fragment,e),Rt=!1},d(e){e&&(o(M),o(b),o(T),o(i),o(et),o(A),o(tt),o(Q),o(ot),o(D),o(st),o(O),o(nt),o(q),o(at),o(K),o(rt),o(ee),o(it),o(lt),o(oe),o(dt),o(se),o(ct),o(mt),o(pt),o(re),o(ht),o(ie),o(ft),o(gt),o(de),o(ut),o(ce),o(_t),o(bt),o(Tt),o(he),o(yt),o(fe),o(Mt),o(It),o(wt),o(_e),o(vt),o(be),o(Jt),o(kt),o(J),o(jt),o(Ut),o(k),o(zt),o(xt),o(j),o(Ct),o($t),o($),o(Zt),o(Wt),o(U),o(Ft),o(Nt),o(Oe)),o(r),_(y,e),_(I,e),_(te,e),_(ne,e),_(ae,e),_(le,e),_(me,e),_(pe,e),_(ge,e),_(ue,e),_(Te,e),_(ye),_(E),_(Me,e),_(Ie),_(we),_(X),_(ve,e),_(Je),_(ke),_(S),_(V),_(je,e),_(Ue),_(ze),_(xe,e),_(Ce),_($e),_(Y),_(Ze,e)}}}const ss='{"title":"Idefics2","local":"idefics2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Model optimizations: Flash Attention","local":"model-optimizations-flash-attention","sections":[],"depth":2},{"title":"Shrinking down Idefics2 using quantization","local":"shrinking-down-idefics2-using-quantization","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"Idefics2Config","local":"transformers.Idefics2Config","sections":[],"depth":2},{"title":"Idefics2Model","local":"transformers.Idefics2Model","sections":[],"depth":2},{"title":"Idefics2ForConditionalGeneration","local":"transformers.Idefics2ForConditionalGeneration","sections":[],"depth":2},{"title":"Idefics2ImageProcessor","local":"transformers.Idefics2ImageProcessor","sections":[],"depth":2},{"title":"Idefics2Processor","local":"transformers.Idefics2Processor","sections":[],"depth":2}],"depth":1}';function ns(x){return Ho(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ps extends Yo{constructor(r){super(),Lo(this,r,ns,os,So,{})}}export{ps as component};
