Buckets:
| import{s as io,o as lo,n as Re}from"../chunks/scheduler.25b97de1.js";import{S as co,i as mo,g as l,s,r as h,A as po,h as c,f as o,c as n,j as Z,u as f,x as g,k as N,y as d,a,v as u,d as _,t as y,w as M}from"../chunks/index.d9030fc9.js";import{T as ro}from"../chunks/Tip.baa67368.js";import{D as F}from"../chunks/Docstring.ffac8efa.js";import{C as mt}from"../chunks/CodeBlock.e6cd0d95.js";import{E as qt}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H,E as go}from"../chunks/EditOnGithub.91d95064.js";function ho(C){let r,I="Example:",m,p,b;return p=new mt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMElkZWZpY3MzTW9kZWwlMkMlMjBJZGVmaWNzM0NvbmZpZyUwQSUyMyUyMEluaXRpYWxpemluZyUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwSWRlZmljczNDb25maWcoKSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBJZGVmaWNzM01vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics3Model, Idefics3Config | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = Idefics3Config() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the configuration</span> | |
| <span class="hljs-meta">>>> </span>model = Idefics3Model(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,wrap:!1}}),{c(){r=l("p"),r.textContent=I,m=s(),h(p.$$.fragment)},l(i){r=c(i,"P",{"data-svelte-h":!0}),g(r)!=="svelte-11lpom8"&&(r.textContent=I),m=n(i),f(p.$$.fragment,i)},m(i,T){a(i,r,T),a(i,m,T),u(p,i,T),b=!0},p:Re,i(i){b||(_(p.$$.fragment,i),b=!0)},o(i){y(p.$$.fragment,i),b=!1},d(i){i&&(o(r),o(m)),M(p,i)}}}function fo(C){let r,I=`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=I},l(m){r=c(m,"P",{"data-svelte-h":!0}),g(r)!=="svelte-fincs2"&&(r.innerHTML=I)},m(m,p){a(m,r,p)},p:Re,d(m){m&&o(r)}}}function uo(C){let r,I=`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=I},l(m){r=c(m,"P",{"data-svelte-h":!0}),g(r)!=="svelte-fincs2"&&(r.innerHTML=I)},m(m,p){a(m,r,p)},p:Re,d(m){m&&o(r)}}}function _o(C){let r,I="Example:",m,p,b;return p=new mt({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbEZvclZpc2lvbjJTZXElMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQSUyMyUyME5vdGUlMj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tlbnMlM0QyNTYpJTBBZ2VuZXJhdGVkX3RleHRzJTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTBBJTBBcHJpbnQoZ2VuZXJhdGVkX3RleHRzJTVCMCU1RCklMEElMEFwcmludChnZW5lcmF0ZWRfdGV4dHMlNUIxJTVEKQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> requests | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForVision2Seq | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-meta">>>> </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">>>> </span>image1 = load_image(<span class="hljs-string">"https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>image2 = load_image(<span class="hljs-string">"https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>image3 = load_image(<span class="hljs-string">"https://cdn.britannica.com/68/170868-050-8DDE8263/Golden-Gate-Bridge-San-Francisco.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"HuggingFaceM4/Idefics3-8B-Llama3"</span>) | |
| <span class="hljs-meta">>>> </span>model = AutoModelForVision2Seq.from_pretrained(<span class="hljs-string">"HuggingFaceM4/Idefics3-8B-Llama3"</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">"auto"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Create inputs</span> | |
| <span class="hljs-meta">>>> </span>messages = [ | |
| <span class="hljs-meta">... </span> { | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"content"</span>: [ | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"In this image, we can see the city of New York, and more specifically the Statue of Liberty."</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"What can we see in this image?"</span>}, | |
| <span class="hljs-meta">... </span> ] | |
| <span class="hljs-meta">... </span> }, | |
| <span class="hljs-meta">... </span> { | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"content"</span>: [ | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"image"</span>}, | |
| <span class="hljs-meta">... </span> {<span class="hljs-string">"type"</span>: <span class="hljs-string">"text"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"In which city is that bridge located?"</span>}, | |
| <span class="hljs-meta">... </span> ] | |
| <span class="hljs-meta">... </span> } | |
| <span class="hljs-meta">... </span>] | |
| <span class="hljs-meta">>>> </span>prompts = [processor.apply_chat_template([message], add_generation_prompt=<span class="hljs-literal">True</span>) <span class="hljs-keyword">for</span> message <span class="hljs-keyword">in</span> messages] | |
| <span class="hljs-meta">>>> </span>images = [[image1, image2], [image3]] | |
| <span class="hljs-meta">>>> </span>inputs = processor(text=prompts, images=images, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Generate</span> | |
| <span class="hljs-meta">>>> </span>generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">256</span>) | |
| <span class="hljs-meta">>>> </span>generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">print</span>(generated_texts[<span class="hljs-number">0</span>]) | |
| Assistant: There are buildings, trees, lights, <span class="hljs-keyword">and</span> water visible <span class="hljs-keyword">in</span> this image. | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">print</span>(generated_texts[<span class="hljs-number">1</span>]) | |
| Assistant: The bridge <span class="hljs-keyword">is</span> <span class="hljs-keyword">in</span> San Francisco.`,wrap:!1}}),{c(){r=l("p"),r.textContent=I,m=s(),h(p.$$.fragment)},l(i){r=c(i,"P",{"data-svelte-h":!0}),g(r)!=="svelte-11lpom8"&&(r.textContent=I),m=n(i),f(p.$$.fragment,i)},m(i,T){a(i,r,T),a(i,m,T),u(p,i,T),b=!0},p:Re,i(i){b||(_(p.$$.fragment,i),b=!0)},o(i){y(p.$$.fragment,i),b=!1},d(i){i&&(o(r),o(m)),M(p,i)}}}function yo(C){let r,I="Example:",m,p,b;return p=new mt({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwSWRlZmljczNQcm9jZXNzb3IlMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMElkZWZpY3MzUHJvY2Vzc29yLmZyb21fcHJ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JTIwJTNEJTIwb3V0cHV0cy5pbnB1dF9pZHMlMEFpbnB1dF90b2tlbnMlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLmJhdGNoX2RlY29kZShpbnB1dF9pZHMpJTBBcHJpbnQoaW5wdXRfdG9rZW5zKQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> requests | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics3Processor | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-meta">>>> </span>processor = Idefics3Processor.from_pretrained(<span class="hljs-string">"HuggingFaceM4/Idefics3-8B-Llama3"</span>) | |
| <span class="hljs-meta">>>> </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">>>> </span>url1 = <span class="hljs-string">"https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"</span> | |
| <span class="hljs-meta">>>> </span>url2 = <span class="hljs-string">"https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg"</span> | |
| <span class="hljs-meta">>>> </span>image1, image2 = load_image(url1), load_image(url2) | |
| <span class="hljs-meta">>>> </span>images = [[image1], [image2]] | |
| <span class="hljs-meta">>>> </span>text = [ | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"<image>In this image, we see"</span>, | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"bla bla bla<image>"</span>, | |
| <span class="hljs-meta">... </span>] | |
| <span class="hljs-meta">>>> </span>outputs = processor(images=images, text=text, return_tensors=<span class="hljs-string">"pt"</span>, padding=<span class="hljs-literal">True</span>) | |
| <span class="hljs-meta">>>> </span>input_ids = outputs.input_ids | |
| <span class="hljs-meta">>>> </span>input_tokens = processor.tokenizer.batch_decode(input_ids) | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">print</span>(input_tokens) | |
| [<span class="hljs-string">'<|begin_of_text|><fake_token_around_image><global-img>((<image>)*169)<fake_token_around_image> In this image, we see'</span>, <span class="hljs-string">'<|reserved_special_token_0|><|reserved_special_token_0|><|reserved_special_token_0|><|begin_of_text|>bla bla bla<fake_token_around_image><global-img>((<image>)*169)<fake_token_around_image>'</span>]`,wrap:!1}}),{c(){r=l("p"),r.textContent=I,m=s(),h(p.$$.fragment)},l(i){r=c(i,"P",{"data-svelte-h":!0}),g(r)!=="svelte-11lpom8"&&(r.textContent=I),m=n(i),f(p.$$.fragment,i)},m(i,T){a(i,r,T),a(i,m,T),u(p,i,T),b=!0},p:Re,i(i){b||(_(p.$$.fragment,i),b=!0)},o(i){y(p.$$.fragment,i),b=!1},d(i){i&&(o(r),o(m)),M(p,i)}}}function Mo(C){let r,I,m,p,b,i,T,Fe,Y,Zt='The Idefics3 model was proposed in <a href="https://huggingface.co/papers/2408.12637" rel="nofollow">Building and better understanding vision-language models: insights and future directions</a> by Hugo Laurençon, Andrés Marafioti, Victor Sanh, and Léo Tronchon.',Ge,X,Nt="Idefics3 is an adaptation of the Idefics2 model with three main differences:",Se,V,Rt="<li>It uses Llama3 for the text model.</li> <li>It uses an updated processing logic for the images.</li> <li>It removes the perceiver.</li>",Be,D,Ft="The abstract from the paper is the following:",Le,O,Gt="<em>The field of vision-language models (VLMs), which take images and texts as inputs and output texts, is rapidly evolving and has yet to reach consensus on several key aspects of the development pipeline, including data, architecture, and training methods. This paper can be seen as a tutorial for building a VLM. We begin by providing a comprehensive overview of the current state-of-the-art approaches, highlighting the strengths and weaknesses of each, addressing the major challenges in the field, and suggesting promising research directions for underexplored areas. We then walk through the practical steps to build Idefics3-8B, a powerful VLM that significantly outperforms its predecessor Idefics2-8B, while being trained efficiently, exclusively on open datasets, and using a straightforward pipeline. These steps include the creation of Docmatix, a dataset for improving document understanding capabilities, which is 240 times larger than previously available datasets. We release the model along with the datasets created for its training.</em>",Ee,K,Qe,ee,St="Input images are processed either by upsampling (if resizing is enabled) or at their original resolution. The resizing behavior depends on two parameters: do_resize and size.",Ae,te,Bt="If <code>do_resize</code> is set to <code>True</code>, the model resizes images so that the longest edge is 4<em>364 pixels by default.\nThe default resizing behavior can be customized by passing a dictionary to the <code>size</code> parameter. For example, `{“longest_edge”: 4</em> 364}` is the default, but you can change it to a different value if needed.",He,oe,Lt="Here’s how to control resizing and set a custom size:",Ye,se,Xe,ne,Et="Additionally, the <code>max_image_size</code> parameter, which controls the size of each square patch the image is decomposed into, is set to 364 by default but can be adjusted as needed. After resizing (if applicable), the image processor decomposes the images into square patches based on the <code>max_image_size</code> parameter.",Ve,ae,Qt='This model was contributed by <a href="https://huggingface.co/amyeroberts" rel="nofollow">amyeroberts</a> and <a href="https://huggingface.co/andito" rel="nofollow">andimarafioti</a>.',De,re,Oe,w,ie,pt,Ie,At=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3Model">Idefics3Model</a>. It is used to instantiate a | |
| Idefics3 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 Idefics3 | |
| <a href="https://huggingface.co/HuggingFaceM4/Idefics3-8B-Llama3" rel="nofollow">HuggingFaceM4/Idefics3-8B-Llama3</a> architecture.`,gt,Te,Ht=`Configuration objects inherit from <a href="/docs/transformers/pr_34748/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/pr_34748/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,ht,G,Ke,de,et,v,le,ft,we,Yt=`Idefics3 model consisting of a SIGLIP vision encoder and Llama3 language decoder | |
| This model inherits from <a href="/docs/transformers/pr_34748/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.)`,ut,ve,Xt=`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.`,_t,k,ce,yt,Ue,Vt='The <a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3Model">Idefics3Model</a> forward method, overrides the <code>__call__</code> special method.',Mt,S,bt,je,Dt=`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. | |
| 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.`,tt,me,ot,U,pe,It,Ce,Ot=`The Idefics3 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/pr_34748/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.)`,Tt,ke,Kt=`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.`,wt,z,ge,vt,ze,eo='The <a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3ForConditionalGeneration">Idefics3ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',Ut,B,jt,L,st,he,nt,x,fe,Ct,xe,to="Constructs a Idefics3 image processor.",kt,E,ue,zt,Je,oo="Preprocess a batch of images.",at,_e,rt,j,ye,xt,$e,so="Constructs a Idefics3 processor which wraps a LLama tokenizer and Idefics3 image processor into a single processor.",Jt,We,no=`<a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3Processor">Idefics3Processor</a> offers all the functionalities of <a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3ImageProcessor">Idefics3ImageProcessor</a> and <code>Idefics3TokenizerFast</code>. See | |
| the docstring of <a href="/docs/transformers/pr_34748/en/model_doc/idefics#transformers.IdeficsProcessor.__call__"><strong>call</strong>()</a> and <code>decode()</code> for more information.`,$t,R,Me,Wt,Pe,ao="Processes the input prompts and returns a BatchEncoding.",Pt,Q,it,be,dt,Ne,lt;return b=new H({props:{title:"Idefics3",local:"idefics3",headingTag:"h1"}}),T=new H({props:{title:"Overview",local:"overview",headingTag:"h2"}}),K=new H({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),se=new mt({props:{code:"aW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwSWRlZmljczNJbWFnZVByb2Nlc3Nvcihkb19yZXNpemUlM0RUcnVlJTJDJTIwc2l6ZSUzRCU3QiUyMmxvbmdlc3RfZWRnZSUyMiUzQSUyMDIlMjAqJTIwMzY0JTdEJTJDJTIwbWF4X2ltYWdlX3NpemUlM0QzNjQp",highlighted:'image_processor = Idefics3ImageProcessor(do_resize=<span class="hljs-literal">True</span>, size={<span class="hljs-string">"longest_edge"</span>: <span class="hljs-number">2</span> * <span class="hljs-number">364</span>}, max_image_size=<span class="hljs-number">364</span>)',wrap:!1}}),re=new H({props:{title:"Idefics3Config",local:"transformers.Idefics3Config",headingTag:"h2"}}),ie=new F({props:{name:"class transformers.Idefics3Config",anchor:"transformers.Idefics3Config",parameters:[{name:"use_cache",val:" = True"},{name:"image_token_id",val:" = 128257"},{name:"tie_word_embeddings",val:" = False"},{name:"vision_config",val:" = None"},{name:"text_config",val:" = None"},{name:"scale_factor",val:" = 2"},{name:"pad_token_id",val:" = 128002"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics3Config.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not the model should cache the key/value pairs of the attention mechanism. Only | |
| relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.Idefics3Config.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 128257) — | |
| The id of the “image” token.`,name:"image_token_id"},{anchor:"transformers.Idefics3Config.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to tie the word embeddings with the token embeddings.`,name:"tie_word_embeddings"},{anchor:"transformers.Idefics3Config.vision_config",description:`<strong>vision_config</strong> (<code>IdeficsVisionConfig</code> or <code>dict</code>, <em>optional</em>, defaults to <code>IdeficsVisionConfig</code>) — | |
| Custom vision config or dict for the vision tower`,name:"vision_config"},{anchor:"transformers.Idefics3Config.text_config",description:`<strong>text_config</strong> (<code>PretrainedConfig</code> or <code>dict</code>, <em>optional</em>, defaults to <code>LlamaConfig</code>) — | |
| Custom text config or dict for the text model`,name:"text_config"},{anchor:"transformers.Idefics3Config.scale_factor",description:`<strong>scale_factor</strong> (<code>int</code>, <em>optional</em>, defaults to 2) — | |
| The scale factor for the image encoder.`,name:"scale_factor"},{anchor:"transformers.Idefics3Config.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 128002) — | |
| The id of the padding token.`,name:"pad_token_id"}],source:"https://github.com/huggingface/transformers/blob/vr_34748/src/transformers/models/idefics3/configuration_idefics3.py#L108"}}),G=new qt({props:{anchor:"transformers.Idefics3Config.example",$$slots:{default:[ho]},$$scope:{ctx:C}}}),de=new H({props:{title:"Idefics3Model",local:"transformers.Idefics3Model",headingTag:"h2"}}),le=new F({props:{name:"class transformers.Idefics3Model",anchor:"transformers.Idefics3Model",parameters:[{name:"config",val:": Idefics3Config"}],parametersDescription:[{anchor:"transformers.Idefics3Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3Config">Idefics3Config</a> or <code>Idefics3VisionConfig</code>) — | |
| 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/pr_34748/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/vr_34748/src/transformers/models/idefics3/modeling_idefics3.py#L819"}}),ce=new F({props:{name:"forward",anchor:"transformers.Idefics3Model.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.Idefics3Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| 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/pr_34748/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_34748/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_34748/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.Idefics3Model.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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/pr_34748/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_34748/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_34748/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.Idefics3Model.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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.Idefics3Model.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>) — | |
| 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’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.Idefics3Model.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>) — | |
| 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’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Idefics3Model.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/pr_34748/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/pr_34748/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/pr_34748/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics3Model.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>) — | |
| Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics3Model.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>) — | |
| The hidden states of the image encoder after modality projection.`,name:"image_hidden_states"},{anchor:"transformers.Idefics3Model.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3Model.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3Model.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3Model.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_34748/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_34748/src/transformers/models/idefics3/modeling_idefics3.py#L907"}}),S=new ro({props:{$$slots:{default:[fo]},$$scope:{ctx:C}}}),me=new H({props:{title:"Idefics3ForConditionalGeneration",local:"transformers.Idefics3ForConditionalGeneration",headingTag:"h2"}}),pe=new F({props:{name:"class transformers.Idefics3ForConditionalGeneration",anchor:"transformers.Idefics3ForConditionalGeneration",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Idefics3ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3Config">Idefics3Config</a> or <code>Idefics3VisionConfig</code>) — | |
| 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/pr_34748/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/vr_34748/src/transformers/models/idefics3/modeling_idefics3.py#L1043"}}),ge=new F({props:{name:"forward",anchor:"transformers.Idefics3ForConditionalGeneration.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.Idefics3ForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| 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/pr_34748/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_34748/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_34748/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.Idefics3ForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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/pr_34748/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_34748/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_34748/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.Idefics3ForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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.Idefics3ForConditionalGeneration.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>) — | |
| 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’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.Idefics3ForConditionalGeneration.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>) — | |
| 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’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.Idefics3ForConditionalGeneration.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/pr_34748/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/pr_34748/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/pr_34748/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics3ForConditionalGeneration.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>) — | |
| Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics3ForConditionalGeneration.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>) — | |
| The hidden states of the image encoder after modality projection.`,name:"image_hidden_states"},{anchor:"transformers.Idefics3ForConditionalGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3ForConditionalGeneration.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3ForConditionalGeneration.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.Idefics3ForConditionalGeneration.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_34748/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p> | |
| <p>Args — | |
| 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>Idefics3ForConditionalGeneration</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/vr_34748/src/transformers/models/idefics3/modeling_idefics3.py#L1109",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <code>transformers.models.idefics3.modeling_idefics3.Idefics3CausalLMOutputWithPast</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/pr_34748/en/model_doc/idefics3#transformers.Idefics3Config" | |
| >Idefics3Config</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</li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>transformers.models.idefics3.modeling_idefics3.Idefics3CausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),B=new ro({props:{$$slots:{default:[uo]},$$scope:{ctx:C}}}),L=new qt({props:{anchor:"transformers.Idefics3ForConditionalGeneration.forward.example",$$slots:{default:[_o]},$$scope:{ctx:C}}}),he=new H({props:{title:"Idefics3ImageProcessor",local:"transformers.Idefics3ImageProcessor",headingTag:"h2"}}),fe=new F({props:{name:"class transformers.Idefics3ImageProcessor",anchor:"transformers.Idefics3ImageProcessor",parameters:[{name:"do_convert_rgb",val:": bool = True"},{name:"do_resize",val:": bool = True"},{name:"size",val:": Dict = None"},{name:"resample",val:": Resampling = <Resampling.LANCZOS: 1>"},{name:"do_image_splitting",val:": bool = True"},{name:"max_image_size",val:": Dict = None"},{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:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics3ImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| 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.Idefics3ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to resize the image. The longest edge of the image is resized to be <= <code>size["longest_edge"]</code>, with the | |
| shortest edge resized to keep the input aspect ratio.`,name:"do_resize"},{anchor:"transformers.Idefics3ImageProcessor.size",description:`<strong>size</strong> (<code>Dict</code>, <em>optional</em>, defaults to <code>{"longest_edge" -- 4 * 364}</code>): | |
| Controls the size of the output image. This is a dictionary containing the key “longest_edge”. | |
| The image will be resized such that the longest edge is <= <code>size["longest_edge"]</code> and the shortest edge is resized | |
| to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.Idefics3ImageProcessor.resample",description:`<strong>resample</strong> (<code>Resampling</code>, <em>optional</em>, defaults to <code>Resampling.LANCZOS</code>) — | |
| Resampling filter to use when resizing the image.`,name:"resample"},{anchor:"transformers.Idefics3ImageProcessor.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to split the image into sub-images concatenated with the original image. They are split into patches | |
| such that each patch has a size of <code>max_image_size["height"]</code> x <code>max_image_size["width"]</code>.`,name:"do_image_splitting"},{anchor:"transformers.Idefics3ImageProcessor.max_image_size",description:`<strong>max_image_size</strong> (<code>Dict</code>, <em>optional</em>, defaults to <code>{"longest_edge" -- 364}</code>): | |
| Maximum resolution of the patches of images accepted by the model. This is a dictionary containing the key “longest_edge”.`,name:"max_image_size"},{anchor:"transformers.Idefics3ImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| 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.Idefics3ImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Idefics3ImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| 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.Idefics3ImageProcessor.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>) — | |
| 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.Idefics3ImageProcessor.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>) — | |
| 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.Idefics3ImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| 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"}],source:"https://github.com/huggingface/transformers/blob/vr_34748/src/transformers/models/idefics3/image_processing_idefics3.py#L291"}}),ue=new F({props:{name:"preprocess",anchor:"transformers.Idefics3ImageProcessor.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_image_splitting",val:": Optional = None"},{name:"do_rescale",val:": Optional = None"},{name:"max_image_size",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:"return_tensors",val:": Union = None"},{name:"return_row_col_info",val:": bool = False"},{name:"data_format",val:": Optional = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": Union = None"}],parametersDescription:[{anchor:"transformers.Idefics3ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) — | |
| A list of images to preprocess.`,name:"images"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) — | |
| Size of the image after resizing. With the longest edge resized to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.resample</code>) — | |
| 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.Idefics3ImageProcessor.preprocess.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_image_splitting</code>) — | |
| Whether to split the image into sub-images concatenated with the original image. They are split into patches | |
| such that each patch has a size of <code>max_image_size["height"]</code> x <code>max_image_size["width"]</code>.`,name:"do_image_splitting"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.max_image_size",description:`<strong>max_image_size</strong> (<code>Dict</code>, <em>optional</em>, defaults to <code>self.max_image_size</code>) — | |
| Maximum resolution of the images. If the image is larger than this size, the image is split into patches.`,name:"max_image_size"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Idefics3ImageProcessor.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>) — | |
| 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.Idefics3ImageProcessor.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>) — | |
| 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.Idefics3ImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) — | |
| Whether or not to pad the images to the largest height and width in the batch.`,name:"do_pad"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) — | |
| 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>'tf'</code>: Return a batch of type <code>tf.Tensor</code>.</li> | |
| <li><code>TensorType.PYTORCH</code> or <code>'pt'</code>: Return a batch of type <code>torch.Tensor</code>.</li> | |
| <li><code>TensorType.NUMPY</code> or <code>'np'</code>: Return a batch of type <code>np.ndarray</code>.</li> | |
| <li><code>TensorType.JAX</code> or <code>'jax'</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li> | |
| </ul>`,name:"return_tensors"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.return_row_col_info",description:`<strong>return_row_col_info</strong> (<code>bool</code>, <em>optional</em>, default to <code>False</code>) — | |
| Whether to return the number of rows and columns of the split images. This is used for the | |
| <code>Idefics3Processor</code> to generate prompt strings based on the number of rows and columns.`,name:"return_row_col_info"},{anchor:"transformers.Idefics3ImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) — | |
| The channel dimension format for the output image. Can be one of:<ul> | |
| <li><code>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</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.Idefics3ImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) — | |
| 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>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/vr_34748/src/transformers/models/idefics3/image_processing_idefics3.py#L642"}}),_e=new H({props:{title:"Idefics3Processor",local:"transformers.Idefics3Processor",headingTag:"h2"}}),ye=new F({props:{name:"class transformers.Idefics3Processor",anchor:"transformers.Idefics3Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:" = None"},{name:"image_seq_len",val:": int = 169"},{name:"chat_template",val:": str = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics3Processor.image_processor",description:`<strong>image_processor</strong> (<code>Idefics3ImageProcessor</code>) — | |
| An instance of <a href="/docs/transformers/pr_34748/en/model_doc/idefics3#transformers.Idefics3ImageProcessor">Idefics3ImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Idefics3Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizerBase</code>, <em>optional</em>) — | |
| An instance of <a href="/docs/transformers/pr_34748/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase">PreTrainedTokenizerBase</a>. This should correspond with the model’s text model. The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.Idefics3Processor.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 169) — | |
| 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 | |
| value the model used. It is computed as: image_seq_len = int(((image_size // patch_size) <strong> 2) / (scale_factor</strong>2))</image>`,name:"image_seq_len"},{anchor:"transformers.Idefics3Processor.chat_template",description:`<strong>chat_template</strong> (<code>str</code>, <em>optional</em>) — A Jinja template which will be used to convert lists of messages | |
| in a chat into a tokenizable string.`,name:"chat_template"}],source:"https://github.com/huggingface/transformers/blob/vr_34748/src/transformers/models/idefics3/processing_idefics3.py#L111"}}),Me=new F({props:{name:"__call__",anchor:"transformers.Idefics3Processor.__call__",parameters:[{name:"images",val:": Union = None"},{name:"text",val:": Union = None"},{name:"audio",val:" = None"},{name:"videos",val:" = None"},{name:"image_seq_len",val:": Optional = None"},{name:"**kwargs",val:": Unpack"}],parametersDescription:[{anchor:"transformers.Idefics3Processor.__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>) — | |
| 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’s assumed that this is for a single prompt i.e. of batch size 1.`,name:"images"},{anchor:"transformers.Idefics3Processor.__call__.text",description:`<strong>text</strong> (<code>Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]</code>, <em>optional</em>) — | |
| 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). | |
| Wherever an image token, <code><image></code> is encountered it is expanded to | |
| <code><fake_token_around_image></code> + <code><row_x_col_y></code> + <code><image></code> <em> <code>image_seq_len</code> </em> <fake_token_around_image>\`.</fake_token_around_image>`,name:"text"},{anchor:"transformers.Idefics3Processor.__call__.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>) — | |
| The length of the image sequence. If not provided, the default value of self.image_seq_len is used. | |
| image_seq_len should be equal to int(((image_size // patch_size) <strong> 2) / (scale_factor</strong>2))`,name:"image_seq_len"},{anchor:"transformers.Idefics3Processor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>Union[str, TensorType]</code>, <em>optional</em>) — | |
| If set, will return tensors of a particular framework. See <a href="/docs/transformers/pr_34748/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/vr_34748/src/transformers/models/idefics3/processing_idefics3.py#L174"}}),Q=new qt({props:{anchor:"transformers.Idefics3Processor.__call__.example",$$slots:{default:[yo]},$$scope:{ctx:C}}}),be=new go({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/idefics3.md"}}),{c(){r=l("meta"),I=s(),m=l("p"),p=s(),h(b.$$.fragment),i=s(),h(T.$$.fragment),Fe=s(),Y=l("p"),Y.innerHTML=Zt,Ge=s(),X=l("p"),X.textContent=Nt,Se=s(),V=l("ul"),V.innerHTML=Rt,Be=s(),D=l("p"),D.textContent=Ft,Le=s(),O=l("p"),O.innerHTML=Gt,Ee=s(),h(K.$$.fragment),Qe=s(),ee=l("p"),ee.textContent=St,Ae=s(),te=l("p"),te.innerHTML=Bt,He=s(),oe=l("p"),oe.textContent=Lt,Ye=s(),h(se.$$.fragment),Xe=s(),ne=l("p"),ne.innerHTML=Et,Ve=s(),ae=l("p"),ae.innerHTML=Qt,De=s(),h(re.$$.fragment),Oe=s(),w=l("div"),h(ie.$$.fragment),pt=s(),Ie=l("p"),Ie.innerHTML=At,gt=s(),Te=l("p"),Te.innerHTML=Ht,ht=s(),h(G.$$.fragment),Ke=s(),h(de.$$.fragment),et=s(),v=l("div"),h(le.$$.fragment),ft=s(),we=l("p"),we.innerHTML=Yt,ut=s(),ve=l("p"),ve.innerHTML=Xt,_t=s(),k=l("div"),h(ce.$$.fragment),yt=s(),Ue=l("p"),Ue.innerHTML=Vt,Mt=s(),h(S.$$.fragment),bt=s(),je=l("p"),je.textContent=Dt,tt=s(),h(me.$$.fragment),ot=s(),U=l("div"),h(pe.$$.fragment),It=s(),Ce=l("p"),Ce.innerHTML=Ot,Tt=s(),ke=l("p"),ke.innerHTML=Kt,wt=s(),z=l("div"),h(ge.$$.fragment),vt=s(),ze=l("p"),ze.innerHTML=eo,Ut=s(),h(B.$$.fragment),jt=s(),h(L.$$.fragment),st=s(),h(he.$$.fragment),nt=s(),x=l("div"),h(fe.$$.fragment),Ct=s(),xe=l("p"),xe.textContent=to,kt=s(),E=l("div"),h(ue.$$.fragment),zt=s(),Je=l("p"),Je.textContent=oo,at=s(),h(_e.$$.fragment),rt=s(),j=l("div"),h(ye.$$.fragment),xt=s(),$e=l("p"),$e.textContent=so,Jt=s(),We=l("p"),We.innerHTML=no,$t=s(),R=l("div"),h(Me.$$.fragment),Wt=s(),Pe=l("p"),Pe.textContent=ao,Pt=s(),h(Q.$$.fragment),it=s(),h(be.$$.fragment),dt=s(),Ne=l("p"),this.h()},l(e){const t=po("svelte-u9bgzb",document.head);r=c(t,"META",{name:!0,content:!0}),t.forEach(o),I=n(e),m=c(e,"P",{}),Z(m).forEach(o),p=n(e),f(b.$$.fragment,e),i=n(e),f(T.$$.fragment,e),Fe=n(e),Y=c(e,"P",{"data-svelte-h":!0}),g(Y)!=="svelte-1m8d2ny"&&(Y.innerHTML=Zt),Ge=n(e),X=c(e,"P",{"data-svelte-h":!0}),g(X)!=="svelte-1ox6z7j"&&(X.textContent=Nt),Se=n(e),V=c(e,"UL",{"data-svelte-h":!0}),g(V)!=="svelte-1nmvj8w"&&(V.innerHTML=Rt),Be=n(e),D=c(e,"P",{"data-svelte-h":!0}),g(D)!=="svelte-vfdo9a"&&(D.textContent=Ft),Le=n(e),O=c(e,"P",{"data-svelte-h":!0}),g(O)!=="svelte-lkhlij"&&(O.innerHTML=Gt),Ee=n(e),f(K.$$.fragment,e),Qe=n(e),ee=c(e,"P",{"data-svelte-h":!0}),g(ee)!=="svelte-ff9k4v"&&(ee.textContent=St),Ae=n(e),te=c(e,"P",{"data-svelte-h":!0}),g(te)!=="svelte-y46b2t"&&(te.innerHTML=Bt),He=n(e),oe=c(e,"P",{"data-svelte-h":!0}),g(oe)!=="svelte-1nkyanl"&&(oe.textContent=Lt),Ye=n(e),f(se.$$.fragment,e),Xe=n(e),ne=c(e,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-1f79iiu"&&(ne.innerHTML=Et),Ve=n(e),ae=c(e,"P",{"data-svelte-h":!0}),g(ae)!=="svelte-18htqbw"&&(ae.innerHTML=Qt),De=n(e),f(re.$$.fragment,e),Oe=n(e),w=c(e,"DIV",{class:!0});var J=Z(w);f(ie.$$.fragment,J),pt=n(J),Ie=c(J,"P",{"data-svelte-h":!0}),g(Ie)!=="svelte-zxy8aw"&&(Ie.innerHTML=At),gt=n(J),Te=c(J,"P",{"data-svelte-h":!0}),g(Te)!=="svelte-1kqr1dz"&&(Te.innerHTML=Ht),ht=n(J),f(G.$$.fragment,J),J.forEach(o),Ke=n(e),f(de.$$.fragment,e),et=n(e),v=c(e,"DIV",{class:!0});var $=Z(v);f(le.$$.fragment,$),ft=n($),we=c($,"P",{"data-svelte-h":!0}),g(we)!=="svelte-1crfva7"&&(we.innerHTML=Yt),ut=n($),ve=c($,"P",{"data-svelte-h":!0}),g(ve)!=="svelte-hswkmf"&&(ve.innerHTML=Xt),_t=n($),k=c($,"DIV",{class:!0});var W=Z(k);f(ce.$$.fragment,W),yt=n(W),Ue=c(W,"P",{"data-svelte-h":!0}),g(Ue)!=="svelte-1b42ikf"&&(Ue.innerHTML=Vt),Mt=n(W),f(S.$$.fragment,W),bt=n(W),je=c(W,"P",{"data-svelte-h":!0}),g(je)!=="svelte-1opccf8"&&(je.textContent=Dt),W.forEach(o),$.forEach(o),tt=n(e),f(me.$$.fragment,e),ot=n(e),U=c(e,"DIV",{class:!0});var P=Z(U);f(pe.$$.fragment,P),It=n(P),Ce=c(P,"P",{"data-svelte-h":!0}),g(Ce)!=="svelte-ak83mw"&&(Ce.innerHTML=Ot),Tt=n(P),ke=c(P,"P",{"data-svelte-h":!0}),g(ke)!=="svelte-hswkmf"&&(ke.innerHTML=Kt),wt=n(P),z=c(P,"DIV",{class:!0});var q=Z(z);f(ge.$$.fragment,q),vt=n(q),ze=c(q,"P",{"data-svelte-h":!0}),g(ze)!=="svelte-1s31qzh"&&(ze.innerHTML=eo),Ut=n(q),f(B.$$.fragment,q),jt=n(q),f(L.$$.fragment,q),q.forEach(o),P.forEach(o),st=n(e),f(he.$$.fragment,e),nt=n(e),x=c(e,"DIV",{class:!0});var qe=Z(x);f(fe.$$.fragment,qe),Ct=n(qe),xe=c(qe,"P",{"data-svelte-h":!0}),g(xe)!=="svelte-1atvvs0"&&(xe.textContent=to),kt=n(qe),E=c(qe,"DIV",{class:!0});var ct=Z(E);f(ue.$$.fragment,ct),zt=n(ct),Je=c(ct,"P",{"data-svelte-h":!0}),g(Je)!=="svelte-1xds4wy"&&(Je.textContent=oo),ct.forEach(o),qe.forEach(o),at=n(e),f(_e.$$.fragment,e),rt=n(e),j=c(e,"DIV",{class:!0});var A=Z(j);f(ye.$$.fragment,A),xt=n(A),$e=c(A,"P",{"data-svelte-h":!0}),g($e)!=="svelte-1kh2zup"&&($e.textContent=so),Jt=n(A),We=c(A,"P",{"data-svelte-h":!0}),g(We)!=="svelte-1mgqiku"&&(We.innerHTML=no),$t=n(A),R=c(A,"DIV",{class:!0});var Ze=Z(R);f(Me.$$.fragment,Ze),Wt=n(Ze),Pe=c(Ze,"P",{"data-svelte-h":!0}),g(Pe)!=="svelte-421t2f"&&(Pe.textContent=ao),Pt=n(Ze),f(Q.$$.fragment,Ze),Ze.forEach(o),A.forEach(o),it=n(e),f(be.$$.fragment,e),dt=n(e),Ne=c(e,"P",{}),Z(Ne).forEach(o),this.h()},h(){N(r,"name","hf:doc:metadata"),N(r,"content",bo),N(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(j,"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){d(document.head,r),a(e,I,t),a(e,m,t),a(e,p,t),u(b,e,t),a(e,i,t),u(T,e,t),a(e,Fe,t),a(e,Y,t),a(e,Ge,t),a(e,X,t),a(e,Se,t),a(e,V,t),a(e,Be,t),a(e,D,t),a(e,Le,t),a(e,O,t),a(e,Ee,t),u(K,e,t),a(e,Qe,t),a(e,ee,t),a(e,Ae,t),a(e,te,t),a(e,He,t),a(e,oe,t),a(e,Ye,t),u(se,e,t),a(e,Xe,t),a(e,ne,t),a(e,Ve,t),a(e,ae,t),a(e,De,t),u(re,e,t),a(e,Oe,t),a(e,w,t),u(ie,w,null),d(w,pt),d(w,Ie),d(w,gt),d(w,Te),d(w,ht),u(G,w,null),a(e,Ke,t),u(de,e,t),a(e,et,t),a(e,v,t),u(le,v,null),d(v,ft),d(v,we),d(v,ut),d(v,ve),d(v,_t),d(v,k),u(ce,k,null),d(k,yt),d(k,Ue),d(k,Mt),u(S,k,null),d(k,bt),d(k,je),a(e,tt,t),u(me,e,t),a(e,ot,t),a(e,U,t),u(pe,U,null),d(U,It),d(U,Ce),d(U,Tt),d(U,ke),d(U,wt),d(U,z),u(ge,z,null),d(z,vt),d(z,ze),d(z,Ut),u(B,z,null),d(z,jt),u(L,z,null),a(e,st,t),u(he,e,t),a(e,nt,t),a(e,x,t),u(fe,x,null),d(x,Ct),d(x,xe),d(x,kt),d(x,E),u(ue,E,null),d(E,zt),d(E,Je),a(e,at,t),u(_e,e,t),a(e,rt,t),a(e,j,t),u(ye,j,null),d(j,xt),d(j,$e),d(j,Jt),d(j,We),d(j,$t),d(j,R),u(Me,R,null),d(R,Wt),d(R,Pe),d(R,Pt),u(Q,R,null),a(e,it,t),u(be,e,t),a(e,dt,t),a(e,Ne,t),lt=!0},p(e,[t]){const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),G.$set(J);const $={};t&2&&($.$$scope={dirty:t,ctx:e}),S.$set($);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),B.$set(W);const P={};t&2&&(P.$$scope={dirty:t,ctx:e}),L.$set(P);const q={};t&2&&(q.$$scope={dirty:t,ctx:e}),Q.$set(q)},i(e){lt||(_(b.$$.fragment,e),_(T.$$.fragment,e),_(K.$$.fragment,e),_(se.$$.fragment,e),_(re.$$.fragment,e),_(ie.$$.fragment,e),_(G.$$.fragment,e),_(de.$$.fragment,e),_(le.$$.fragment,e),_(ce.$$.fragment,e),_(S.$$.fragment,e),_(me.$$.fragment,e),_(pe.$$.fragment,e),_(ge.$$.fragment,e),_(B.$$.fragment,e),_(L.$$.fragment,e),_(he.$$.fragment,e),_(fe.$$.fragment,e),_(ue.$$.fragment,e),_(_e.$$.fragment,e),_(ye.$$.fragment,e),_(Me.$$.fragment,e),_(Q.$$.fragment,e),_(be.$$.fragment,e),lt=!0)},o(e){y(b.$$.fragment,e),y(T.$$.fragment,e),y(K.$$.fragment,e),y(se.$$.fragment,e),y(re.$$.fragment,e),y(ie.$$.fragment,e),y(G.$$.fragment,e),y(de.$$.fragment,e),y(le.$$.fragment,e),y(ce.$$.fragment,e),y(S.$$.fragment,e),y(me.$$.fragment,e),y(pe.$$.fragment,e),y(ge.$$.fragment,e),y(B.$$.fragment,e),y(L.$$.fragment,e),y(he.$$.fragment,e),y(fe.$$.fragment,e),y(ue.$$.fragment,e),y(_e.$$.fragment,e),y(ye.$$.fragment,e),y(Me.$$.fragment,e),y(Q.$$.fragment,e),y(be.$$.fragment,e),lt=!1},d(e){e&&(o(I),o(m),o(p),o(i),o(Fe),o(Y),o(Ge),o(X),o(Se),o(V),o(Be),o(D),o(Le),o(O),o(Ee),o(Qe),o(ee),o(Ae),o(te),o(He),o(oe),o(Ye),o(Xe),o(ne),o(Ve),o(ae),o(De),o(Oe),o(w),o(Ke),o(et),o(v),o(tt),o(ot),o(U),o(st),o(nt),o(x),o(at),o(rt),o(j),o(it),o(dt),o(Ne)),o(r),M(b,e),M(T,e),M(K,e),M(se,e),M(re,e),M(ie),M(G),M(de,e),M(le),M(ce),M(S),M(me,e),M(pe),M(ge),M(B),M(L),M(he,e),M(fe),M(ue),M(_e,e),M(ye),M(Me),M(Q),M(be,e)}}}const bo='{"title":"Idefics3","local":"idefics3","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Idefics3Config","local":"transformers.Idefics3Config","sections":[],"depth":2},{"title":"Idefics3Model","local":"transformers.Idefics3Model","sections":[],"depth":2},{"title":"Idefics3ForConditionalGeneration","local":"transformers.Idefics3ForConditionalGeneration","sections":[],"depth":2},{"title":"Idefics3ImageProcessor","local":"transformers.Idefics3ImageProcessor","sections":[],"depth":2},{"title":"Idefics3Processor","local":"transformers.Idefics3Processor","sections":[],"depth":2}],"depth":1}';function Io(C){return lo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zo extends co{constructor(r){super(),mo(this,r,Io,Mo,io,{})}}export{zo as component}; | |
Xet Storage Details
- Size:
- 78.4 kB
- Xet hash:
- 76f35a0da1231106d4a25561d74c3efe147f50d11e1f456f106556cafb5503d7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.