import{s as qt,f as Ht,o as Pt,n as Ie}from"../chunks/scheduler.25b97de1.js";import{S as Lt,i as Yt,g as d,s as a,r as h,A as Qt,h as c,f as s,c as r,j as R,u as g,x as M,k as C,y as i,a as l,v as u,d as f,t as _,w as b}from"../chunks/index.d9030fc9.js";import{T as Vt}from"../chunks/Tip.baa67368.js";import{D as ge}from"../chunks/Docstring.ffac8efa.js";import{C as Oe}from"../chunks/CodeBlock.e6cd0d95.js";import{E as wt}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as P,E as St}from"../chunks/EditOnGithub.91d95064.js";function At(x){let o,w="Example:",m,p,T;return p=new Oe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEtvc21vczJDb25maWclMkMlMjBLb3Ntb3MyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwS29zbW9zLTIlMjBrb3Ntb3MtMi1wYXRjaDE0LTIyNCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBLb3Ntb3MyQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMGtvc21vcy0yLXBhdGNoMTQtMjI0JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBLb3Ntb3MyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Kosmos2Config, Kosmos2Model

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Kosmos-2 kosmos-2-patch14-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Kosmos2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the kosmos-2-patch14-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Kosmos2Model(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(){o=d("p"),o.textContent=w,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),u(p,n,y),T=!0},p:Ie,i(n){T||(f(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),b(p,n)}}}function Ot(x){let o,w=`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(){o=d("p"),o.innerHTML=w},l(m){o=c(m,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(m,p){l(m,o,p)},p:Ie,d(m){m&&s(o)}}}function Dt(x){let o,w="Examples:",m,p,T;return p=new Oe({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEtvc21vczJNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwS29zbW9zMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZrb3Ntb3MtMi1wYXRjaDE0LTIyNCUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZrb3Ntb3MtMi1wYXRjaDE0LTIyNCUyMiklMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGbWljcm9zb2Z0JTJGa29zbW9zLTItcGF0Y2gxNC0yMjQlMkZyZXNvbHZlJTJGbWFpbiUyRnNub3dtYW4uanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBdGV4dCUyMCUzRCUyMCglMEElMjAlMjAlMjAlMjAlMjIlM0Nncm91bmRpbmclM0UlMjBBbiUyMGltYWdlJTIwb2YlM0NwaHJhc2UlM0UlMjBhJTIwc25vd21hbiUzQyUyRnBocmFzZSUzRSUzQ29iamVjdCUzRSUzQ3BhdGNoX2luZGV4XzAwNDQlM0UlM0NwYXRjaF9pbmRleF8wODYzJTNFJTIyJTBBJTIwJTIwJTIwJTIwJTIyJTNDJTJGb2JqZWN0JTNFJTIwd2FybWluZyUyMGhpbXNlbGYlMjBieSUzQ3BocmFzZSUzRSUyMGElMjBmaXJlJTNDJTJGcGhyYXNlJTNFJTNDb2JqZWN0JTNFJTNDcGF0Y2hfaW5kZXhfMDAwNSUzRSUzQ3BhdGNoX2luZGV4XzA5MTElM0UlMjIlMEElMjAlMjAlMjAlMjAlMjIlM0MlMkZvYmplY3QlM0UlMjIlMEEpJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwYWRkX2Vvc190b2tlbiUzRFRydWUpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGUlMjAlM0QlMjBtb2RlbCglMEElMjAlMjAlMjAlMjBwaXhlbF92YWx1ZXMlM0RpbnB1dHMlNUIlMjJwaXhlbF92YWx1ZXMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBpbnB1dF9pZHMlM0RpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBhdHRlbnRpb25fbWFzayUzRGlucHV0cyU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2VfZW1iZWRzX3Bvc2l0aW9uX21hc2slM0RpbnB1dHMlNUIlMjJpbWFnZV9lbWJlZHNfcG9zaXRpb25fbWFzayUyMiU1RCUyQyUwQSkubGFzdF9oaWRkZW5fc3RhdGUlMEFsaXN0KGxhc3RfaGlkZGVuX3N0YXRlLnNoYXBlKQ==",highlighted:`<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">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Kosmos2Model

<span class="hljs-meta">&gt;&gt;&gt; </span>model = Kosmos2Model.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/microsoft/kosmos-2-patch14-224/resolve/main/snowman.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>text = (
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&lt;grounding&gt; An image of&lt;phrase&gt; a snowman&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0044&gt;&lt;patch_index_0863&gt;&quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&lt;/object&gt; warming himself by&lt;phrase&gt; a fire&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0005&gt;&lt;patch_index_0911&gt;&quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&lt;/object&gt;&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=text, images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, add_eos_token=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_state = model(
<span class="hljs-meta">... </span>    pixel_values=inputs[<span class="hljs-string">&quot;pixel_values&quot;</span>],
<span class="hljs-meta">... </span>    input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>],
<span class="hljs-meta">... </span>    attention_mask=inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    image_embeds_position_mask=inputs[<span class="hljs-string">&quot;image_embeds_position_mask&quot;</span>],
<span class="hljs-meta">... </span>).last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_state.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">91</span>, <span class="hljs-number">2048</span>]`,wrap:!1}}),{c(){o=d("p"),o.textContent=w,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-kvfsh7"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),u(p,n,y),T=!0},p:Ie,i(n){T||(f(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),b(p,n)}}}function es(x){let o,w=`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(){o=d("p"),o.innerHTML=w},l(m){o=c(m,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(m,p){l(m,o,p)},p:Ie,d(m){m&&s(o)}}}function ts(x){let o,w="Examples:",m,p,T;return p=new Oe({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEtvc21vczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEtvc21vczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmtvc21vcy0yLXBhdGNoMTQtMjI0JTIyKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmtvc21vcy0yLXBhdGNoMTQtMjI0JTIyKSUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZtaWNyb3NvZnQlMkZrb3Ntb3MtMi1wYXRjaDE0LTIyNCUyRnJlc29sdmUlMkZtYWluJTJGc25vd21hbi5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjIlM0Nncm91bmRpbmclM0UlMjBBbiUyMGltYWdlJTIwb2YlMjIlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IodGV4dCUzRHByb21wdCUyQyUyMGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwcGl4ZWxfdmFsdWVzJTNEaW5wdXRzJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTNEaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RpbnB1dHMlNUIlMjJhdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGltYWdlX2VtYmVkcyUzRE5vbmUlMkMlMEElMjAlMjAlMjAlMjBpbWFnZV9lbWJlZHNfcG9zaXRpb25fbWFzayUzRGlucHV0cyU1QiUyMmltYWdlX2VtYmVkc19wb3NpdGlvbl9tYXNrJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2NhY2hlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNENjQlMkMlMEEpJTBBZ2VuZXJhdGVkX3RleHQlMjAlM0QlMjBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlZF9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEJTBBcHJvY2Vzc2VkX3RleHQlMjAlM0QlMjBwcm9jZXNzb3IucG9zdF9wcm9jZXNzX2dlbmVyYXRpb24oZ2VuZXJhdGVkX3RleHQlMkMlMjBjbGVhbnVwX2FuZF9leHRyYWN0JTNERmFsc2UpJTBBcHJvY2Vzc2VkX3RleHQlMEElMEFjYXB0aW9uJTJDJTIwZW50aXRpZXMlMjAlM0QlMjBwcm9jZXNzb3IucG9zdF9wcm9jZXNzX2dlbmVyYXRpb24oZ2VuZXJhdGVkX3RleHQpJTBBY2FwdGlvbiUwQSUwQWVudGl0aWVz",highlighted:`<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">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Kosmos2ForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = Kosmos2ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/microsoft/kosmos-2-patch14-224/resolve/main/snowman.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;&lt;grounding&gt; An image of&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=prompt, images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(
<span class="hljs-meta">... </span>    pixel_values=inputs[<span class="hljs-string">&quot;pixel_values&quot;</span>],
<span class="hljs-meta">... </span>    input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>],
<span class="hljs-meta">... </span>    attention_mask=inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    image_embeds=<span class="hljs-literal">None</span>,
<span class="hljs-meta">... </span>    image_embeds_position_mask=inputs[<span class="hljs-string">&quot;image_embeds_position_mask&quot;</span>],
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">64</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>processed_text = processor.post_process_generation(generated_text, cleanup_and_extract=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processed_text
<span class="hljs-string">&#x27;&lt;grounding&gt; An image of&lt;phrase&gt; a snowman&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0044&gt;&lt;patch_index_0863&gt;&lt;/object&gt; warming himself by&lt;phrase&gt; a fire&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0005&gt;&lt;patch_index_0911&gt;&lt;/object&gt;.&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>caption, entities = processor.post_process_generation(generated_text)
<span class="hljs-meta">&gt;&gt;&gt; </span>caption
<span class="hljs-string">&#x27;An image of a snowman warming himself by a fire.&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>entities
[(<span class="hljs-string">&#x27;a snowman&#x27;</span>, (<span class="hljs-number">12</span>, <span class="hljs-number">21</span>), [(<span class="hljs-number">0.390625</span>, <span class="hljs-number">0.046875</span>, <span class="hljs-number">0.984375</span>, <span class="hljs-number">0.828125</span>)]), (<span class="hljs-string">&#x27;a fire&#x27;</span>, (<span class="hljs-number">41</span>, <span class="hljs-number">47</span>), [(<span class="hljs-number">0.171875</span>, <span class="hljs-number">0.015625</span>, <span class="hljs-number">0.484375</span>, <span class="hljs-number">0.890625</span>)])]`,wrap:!1}}),{c(){o=d("p"),o.textContent=w,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-kvfsh7"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),u(p,n,y),T=!0},p:Ie,i(n){T||(f(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),b(p,n)}}}function ss(x){let o,w,m,p,T,n,y,Ce,L,yt='The KOSMOS-2 model was proposed in <a href="https://arxiv.org/abs/2306.14824" rel="nofollow">Kosmos-2: Grounding Multimodal Large Language Models to the World</a> by Zhiliang Peng, Wenhui Wang, Li Dong, Yaru Hao, Shaohan Huang, Shuming Ma, Furu Wei.',Ue,Y,kt=`KOSMOS-2 is a Transformer-based causal language model and is trained using the next-word prediction task on a web-scale
dataset of grounded image-text pairs <a href="https://huggingface.co/datasets/zzliang/GRIT" rel="nofollow">GRIT</a>. The spatial coordinates of
the bounding boxes in the dataset are converted to a sequence of location tokens, which are appended to their respective
entity text spans (for example, <code>a snowman</code> followed by <code>&lt;patch_index_0044&gt;&lt;patch_index_0863&gt;</code>). The data format is
similar to “hyperlinks” that connect the object regions in an image to their text span in the corresponding caption.`,We,Q,jt="The abstract from the paper is the following:",Fe,S,vt='<em>We introduce Kosmos-2, a Multimodal Large Language Model (MLLM), enabling new capabilities of perceiving object descriptions (e.g., bounding boxes) and grounding text to the visual world. Specifically, we represent refer expressions as links in Markdown, i.e., “[text span](bounding boxes)”, where object descriptions are sequences of location tokens. Together with multimodal corpora, we construct large-scale data of grounded image-text pairs (called GrIT) to train the model. In addition to the existing capabilities of MLLMs (e.g., perceiving general modalities, following instructions, and performing in-context learning), Kosmos-2 integrates the grounding capability into downstream applications. We evaluate Kosmos-2 on a wide range of tasks, including (i) multimodal grounding, such as referring expression comprehension, and phrase grounding, (ii) multimodal referring, such as referring expression generation, (iii) perception-language tasks, and (iv) language understanding and generation. This work lays out the foundation for the development of Embodiment AI and sheds light on the big convergence of language, multimodal perception, action, and world modeling, which is a key step toward artificial general intelligence. Code and pretrained models are available at <a href="https://aka.ms/kosmos-2" rel="nofollow">https://aka.ms/kosmos-2</a>.</em>',Ne,X,Jt,Ze,A,xt='Overview of tasks that KOSMOS-2 can handle. Taken from the <a href="https://arxiv.org/abs/2306.14824">original paper</a>.',Ee,O,Re,D,Xe,ee,$t='This model was contributed by <a href="https://huggingface.co/ydshieh" rel="nofollow">Yih-Dar SHIEH</a>. The original code can be found <a href="https://github.com/microsoft/unilm/tree/master/kosmos-2" rel="nofollow">here</a>.',Be,te,Ge,U,se,De,ue,zt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Model">Kosmos2Model</a>. It is used to instantiate a
KOSMOS-2 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 KOSMOS-2
<a href="https://huggingface.co/microsoft/kosmos-2-patch14-224" rel="nofollow">microsoft/kosmos-2-patch14-224</a> architecture.`,et,B,Ke,oe,Ve,ne,qe,v,ae,tt,fe,It=`Constructs an KOSMOS-2 processor which wraps a KOSMOS-2 image processor and a KOSMOS-2 tokenizer into a single
processor.`,st,_e,Ct=`<a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Processor">Kosmos2Processor</a> offers all the functionalities of <a href="/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> and some functionalities of
<a href="/docs/transformers/main/en/model_doc/xlm-roberta#transformers.XLMRobertaTokenizerFast">XLMRobertaTokenizerFast</a>. See the docstring of <a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Processor.__call__"><strong>call</strong>()</a> and <code>decode()</code>
for more information.`,ot,$,re,nt,be,Ut=`This method uses <a href="/docs/transformers/main/en/model_doc/videomae#transformers.VideoMAEFeatureExtractor.__call__">CLIPImageProcessor.<strong>call</strong>()</a> method to prepare image(s) for the model, and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">XLMRobertaTokenizerFast.<strong>call</strong>()</a> to prepare text for the model.`,at,Me,Wt="Please refer to the docstring of the above two methods for more information.",rt,Te,Ft="The rest of this documentation shows the arguments specific to <code>Kosmos2Processor</code>.",He,le,Pe,k,ie,lt,we,Nt="KOSMOS-2 Model for generating text and image features. The model consists of a vision encoder and a language model.",it,ye,Zt=`This model inherits from <a href="/docs/transformers/main/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.)`,dt,ke,Et=`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.`,ct,z,de,mt,je,Rt='The <a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Model">Kosmos2Model</a> forward method, overrides the <code>__call__</code> special method.',pt,G,ht,K,Le,ce,Ye,j,me,gt,ve,Xt=`KOSMOS-2 Model for generating text and bounding boxes given an image. The model consists of a vision encoder and a
language model.`,ut,Je,Bt=`This model inherits from <a href="/docs/transformers/main/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.)`,ft,xe,Gt=`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,I,pe,bt,$e,Kt='The <a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2ForConditionalGeneration">Kosmos2ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',Mt,V,Tt,q,Qe,he,Se,ze,Ae;return T=new P({props:{title:"KOSMOS-2",local:"kosmos-2",headingTag:"h1"}}),y=new P({props:{title:"Overview",local:"overview",headingTag:"h2"}}),O=new P({props:{title:"Example",local:"example",headingTag:"h2"}}),D=new Oe({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEtvc21vczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEtvc21vczJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmtvc21vcy0yLXBhdGNoMTQtMjI0JTIyKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmtvc21vcy0yLXBhdGNoMTQtMjI0JTIyKSUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZtaWNyb3NvZnQlMkZrb3Ntb3MtMi1wYXRjaDE0LTIyNCUyRnJlc29sdmUlMkZtYWluJTJGc25vd21hbi5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjIlM0Nncm91bmRpbmclM0UlMjBBbiUyMGltYWdlJTIwb2YlMjIlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IodGV4dCUzRHByb21wdCUyQyUyMGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwcGl4ZWxfdmFsdWVzJTNEaW5wdXRzJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTNEaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RpbnB1dHMlNUIlMjJhdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGltYWdlX2VtYmVkcyUzRE5vbmUlMkMlMEElMjAlMjAlMjAlMjBpbWFnZV9lbWJlZHNfcG9zaXRpb25fbWFzayUzRGlucHV0cyU1QiUyMmltYWdlX2VtYmVkc19wb3NpdGlvbl9tYXNrJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2NhY2hlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNENjQlMkMlMEEpJTBBZ2VuZXJhdGVkX3RleHQlMjAlM0QlMjBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlZF9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEJTBBcHJvY2Vzc2VkX3RleHQlMjAlM0QlMjBwcm9jZXNzb3IucG9zdF9wcm9jZXNzX2dlbmVyYXRpb24oZ2VuZXJhdGVkX3RleHQlMkMlMjBjbGVhbnVwX2FuZF9leHRyYWN0JTNERmFsc2UpJTBBcHJvY2Vzc2VkX3RleHQlMEElMEFjYXB0aW9uJTJDJTIwZW50aXRpZXMlMjAlM0QlMjBwcm9jZXNzb3IucG9zdF9wcm9jZXNzX2dlbmVyYXRpb24oZ2VuZXJhdGVkX3RleHQpJTBBY2FwdGlvbiUwQSUwQWVudGl0aWVz",highlighted:`<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">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Kosmos2ForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = Kosmos2ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/kosmos-2-patch14-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/microsoft/kosmos-2-patch14-224/resolve/main/snowman.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;&lt;grounding&gt; An image of&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=prompt, images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(
<span class="hljs-meta">... </span>    pixel_values=inputs[<span class="hljs-string">&quot;pixel_values&quot;</span>],
<span class="hljs-meta">... </span>    input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>],
<span class="hljs-meta">... </span>    attention_mask=inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    image_embeds=<span class="hljs-literal">None</span>,
<span class="hljs-meta">... </span>    image_embeds_position_mask=inputs[<span class="hljs-string">&quot;image_embeds_position_mask&quot;</span>],
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">64</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>processed_text = processor.post_process_generation(generated_text, cleanup_and_extract=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processed_text
<span class="hljs-string">&#x27;&lt;grounding&gt; An image of&lt;phrase&gt; a snowman&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0044&gt;&lt;patch_index_0863&gt;&lt;/object&gt; warming himself by&lt;phrase&gt; a fire&lt;/phrase&gt;&lt;object&gt;&lt;patch_index_0005&gt;&lt;patch_index_0911&gt;&lt;/object&gt;.&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>caption, entities = processor.post_process_generation(generated_text)
<span class="hljs-meta">&gt;&gt;&gt; </span>caption
<span class="hljs-string">&#x27;An image of a snowman warming himself by a fire.&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>entities
[(<span class="hljs-string">&#x27;a snowman&#x27;</span>, (<span class="hljs-number">12</span>, <span class="hljs-number">21</span>), [(<span class="hljs-number">0.390625</span>, <span class="hljs-number">0.046875</span>, <span class="hljs-number">0.984375</span>, <span class="hljs-number">0.828125</span>)]), (<span class="hljs-string">&#x27;a fire&#x27;</span>, (<span class="hljs-number">41</span>, <span class="hljs-number">47</span>), [(<span class="hljs-number">0.171875</span>, <span class="hljs-number">0.015625</span>, <span class="hljs-number">0.484375</span>, <span class="hljs-number">0.890625</span>)])]`,wrap:!1}}),te=new P({props:{title:"Kosmos2Config",local:"transformers.Kosmos2Config",headingTag:"h2"}}),se=new ge({props:{name:"class transformers.Kosmos2Config",anchor:"transformers.Kosmos2Config",parameters:[{name:"text_config",val:" = None"},{name:"vision_config",val:" = None"},{name:"latent_query_num",val:" = 64"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Kosmos2Config.text_config",description:`<strong>text_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <code>Kosmos2TextConfig</code>.`,name:"text_config"},{anchor:"transformers.Kosmos2Config.vision_config",description:`<strong>vision_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <code>Kosmos2VisionConfig</code>.`,name:"vision_config"},{anchor:"transformers.Kosmos2Config.latent_query_num",description:`<strong>latent_query_num</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The number of latent query tokens that represent the image features used in the text decoder component.`,name:"latent_query_num"},{anchor:"transformers.Kosmos2Config.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/kosmos2/configuration_kosmos2.py#L237"}}),B=new wt({props:{anchor:"transformers.Kosmos2Config.example",$$slots:{default:[At]},$$scope:{ctx:x}}}),oe=new P({props:{title:"Kosmos2ImageProcessor",local:"kosmos2imageprocessor",headingTag:"h2"}}),ne=new P({props:{title:"Kosmos2Processor",local:"transformers.Kosmos2Processor",headingTag:"h2"}}),ae=new ge({props:{name:"class transformers.Kosmos2Processor",anchor:"transformers.Kosmos2Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:""},{name:"num_patch_index_tokens",val:" = 1024"},{name:"*kwargs",val:""}],parametersDescription:[{anchor:"transformers.Kosmos2Processor.image_processor",description:`<strong>image_processor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Kosmos2Processor.tokenizer",description:"<strong>tokenizer</strong> (<code>XLMRobertaTokenizerFast</code>) &#x2014;\nAn instance of [&#x2018;XLMRobertaTokenizerFast`]. The tokenizer is a required input.",name:"tokenizer"},{anchor:"transformers.Kosmos2Processor.num_patch_index_tokens",description:`<strong>num_patch_index_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The number of tokens that represent patch indices.`,name:"num_patch_index_tokens"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/kosmos2/processing_kosmos2.py#L68"}}),re=new ge({props:{name:"__call__",anchor:"transformers.Kosmos2Processor.__call__",parameters:[{name:"images",val:": Union = None"},{name:"text",val:": Union = None"},{name:"audio",val:" = None"},{name:"videos",val:" = None"},{name:"**kwargs",val:": Unpack"}],parametersDescription:[{anchor:"transformers.Kosmos2Processor.__call__.bboxes",description:`<strong>bboxes</strong> (<code>Union[List[Tuple[int]], List[Tuple[float]], List[List[Tuple[int]]], List[List[Tuple[float]]]]</code>, <em>optional</em>) &#x2014;
The bounding bboxes associated to <code>texts</code>.`,name:"bboxes"},{anchor:"transformers.Kosmos2Processor.__call__.num_image_tokens",description:`<strong>num_image_tokens</strong> (<code>int</code>, <em>optional</em> defaults to 64) &#x2014;
The number of (consecutive) places that are used to mark the placeholders to store image information.
This should be the same as <code>latent_query_num</code> in the instance of <code>Kosmos2Config</code> you are using.`,name:"num_image_tokens"},{anchor:"transformers.Kosmos2Processor.__call__.first_image_token_id",description:`<strong>first_image_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The token id that will be used for the first place of the subsequence that is reserved to store image
information. If unset, will default to <code>self.tokenizer.unk_token_id + 1</code>.`,name:"first_image_token_id"},{anchor:"transformers.Kosmos2Processor.__call__.add_eos_token",description:`<strong>add_eos_token</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether or not to include <code>EOS</code> token id in the encoding when <code>add_special_tokens=True</code>.`,name:"add_eos_token"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/kosmos2/processing_kosmos2.py#L136"}}),le=new P({props:{title:"Kosmos2Model",local:"transformers.Kosmos2Model",headingTag:"h2"}}),ie=new ge({props:{name:"class transformers.Kosmos2Model",anchor:"transformers.Kosmos2Model",parameters:[{name:"config",val:": Kosmos2Config"}],parametersDescription:[{anchor:"transformers.Kosmos2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Config">Kosmos2Config</a>) &#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/main/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/main/src/transformers/models/kosmos2/modeling_kosmos2.py#L1786"}}),de=new ge({props:{name:"forward",anchor:"transformers.Kosmos2Model.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"input_ids",val:": Optional = None"},{name:"image_embeds_position_mask",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"image_embeds",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"interpolate_pos_encoding",val:": bool = False"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Kosmos2Model.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/videomae#transformers.VideoMAEFeatureExtractor.__call__">CLIPImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Kosmos2Model.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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.Kosmos2Model.forward.image_embeds_position_mask",description:`<strong>image_embeds_position_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to indicate the location in a sequence to insert the image features . Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for places where to put the image features,</li>
<li>0 for places that are not for image features (i.e. for text tokens).</li>
</ul>`,name:"image_embeds_position_mask"},{anchor:"transformers.Kosmos2Model.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>`,name:"attention_mask"},{anchor:"transformers.Kosmos2Model.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</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:"head_mask"},{anchor:"transformers.Kosmos2Model.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up 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>.
image_embeds &#x2014; (<code>torch.FloatTensor</code> of shape <code>(batch_size, latent_query_num, hidden_size)</code>, <em>optional</em>):
Sequence of hidden-states at the output of <code>Kosmos2ImageToTextProjection</code>.`,name:"past_key_values"},{anchor:"transformers.Kosmos2Model.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.Kosmos2Model.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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Kosmos2Model.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.Kosmos2Model.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.Kosmos2Model.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.Kosmos2Model.forward.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>, defaults <code>False</code>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.Kosmos2Model.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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/kosmos2/modeling_kosmos2.py#L1812",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.kosmos2.modeling_kosmos2.Kosmos2ModelOutput</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 (<code>&lt;class 'transformers.models.kosmos2.configuration_kosmos2.Kosmos2Config'&gt;</code>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><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>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><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>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>image_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, latent_query_num, hidden_size)</code>, <em>optional</em>) — Sequence of hidden-states at the output of <code>Kosmos2ImageToTextProjection</code>.</p>
</li>
<li>
<p><strong>projection_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights given by <code>Kosmos2ImageToTextProjection</code>, after the attention softmax, used to compute
the weighted average in the self-attention heads.</p>
</li>
<li>
<p><strong>vision_model_output(<code>BaseModelOutputWithPooling</code>,</strong> <em>optional</em>) — The output of the <code>Kosmos2VisionModel</code>.</p>
</li>
<li>
<p><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 optionally if
<code>config.is_encoder_decoder=True</code> 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 optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.kosmos2.modeling_kosmos2.Kosmos2ModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),G=new Vt({props:{$$slots:{default:[Ot]},$$scope:{ctx:x}}}),K=new wt({props:{anchor:"transformers.Kosmos2Model.forward.example",$$slots:{default:[Dt]},$$scope:{ctx:x}}}),ce=new P({props:{title:"Kosmos2ForConditionalGeneration",local:"transformers.Kosmos2ForConditionalGeneration",headingTag:"h2"}}),me=new ge({props:{name:"class transformers.Kosmos2ForConditionalGeneration",anchor:"transformers.Kosmos2ForConditionalGeneration",parameters:[{name:"config",val:": Kosmos2Config"}],parametersDescription:[{anchor:"transformers.Kosmos2ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/kosmos-2#transformers.Kosmos2Config">Kosmos2Config</a>) &#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/main/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/main/src/transformers/models/kosmos2/modeling_kosmos2.py#L1919"}}),pe=new ge({props:{name:"forward",anchor:"transformers.Kosmos2ForConditionalGeneration.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"input_ids",val:": Optional = None"},{name:"image_embeds_position_mask",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"image_embeds",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"position_ids",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.Kosmos2ForConditionalGeneration.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/videomae#transformers.VideoMAEFeatureExtractor.__call__">CLIPImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Kosmos2ForConditionalGeneration.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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.Kosmos2ForConditionalGeneration.forward.image_embeds_position_mask",description:`<strong>image_embeds_position_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to indicate the location in a sequence to insert the image features . Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for places where to put the image features,</li>
<li>0 for places that are not for image features (i.e. for text tokens).</li>
</ul>`,name:"image_embeds_position_mask"},{anchor:"transformers.Kosmos2ForConditionalGeneration.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>`,name:"attention_mask"},{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</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:"head_mask"},{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up 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>.
image_embeds &#x2014; (<code>torch.FloatTensor</code> of shape <code>(batch_size, latent_query_num, hidden_size)</code>, <em>optional</em>):
Sequence of hidden-states at the output of <code>Kosmos2ImageToTextProjection</code>.`,name:"past_key_values"},{anchor:"transformers.Kosmos2ForConditionalGeneration.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.Kosmos2ForConditionalGeneration.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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.Kosmos2ForConditionalGeneration.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.Kosmos2ForConditionalGeneration.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.Kosmos2ForConditionalGeneration.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.Kosmos2ForConditionalGeneration.forward.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>, defaults <code>False</code>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.Kosmos2ForConditionalGeneration.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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
<code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are
ignored (masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/kosmos2/modeling_kosmos2.py#L1954",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.kosmos2.modeling_kosmos2.Kosmos2ForConditionalGenerationModelOutput</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 (<code>&lt;class 'transformers.models.kosmos2.configuration_kosmos2.Kosmos2Config'&gt;</code>) and inputs.</p>
<ul>
<li>
<p><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).</p>
</li>
<li>
<p><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).</p>
</li>
<li>
<p><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>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><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>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>image_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, latent_query_num, hidden_size)</code>, <em>optional</em>) — Sequence of hidden-states at the output of <code>Kosmos2ImageToTextProjection</code>.</p>
</li>
<li>
<p><strong>projection_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights given by <code>Kosmos2ImageToTextProjection</code>, after the attention softmax, used to compute
the weighted average in the self-attention heads.</p>
</li>
<li>
<p><strong>vision_model_output(<code>BaseModelOutputWithPooling</code>,</strong> <em>optional</em>) — The output of the <code>Kosmos2VisionModel</code>.</p>
</li>
<li>
<p><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 optionally if
<code>config.is_encoder_decoder=True</code> 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 optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.kosmos2.modeling_kosmos2.Kosmos2ForConditionalGenerationModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),V=new Vt({props:{$$slots:{default:[es]},$$scope:{ctx:x}}}),q=new wt({props:{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.example",$$slots:{default:[ts]},$$scope:{ctx:x}}}),he=new St({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/kosmos-2.md"}}),{c(){o=d("meta"),w=a(),m=d("p"),p=a(),h(T.$$.fragment),n=a(),h(y.$$.fragment),Ce=a(),L=d("p"),L.innerHTML=yt,Ue=a(),Y=d("p"),Y.innerHTML=kt,We=a(),Q=d("p"),Q.textContent=jt,Fe=a(),S=d("p"),S.innerHTML=vt,Ne=a(),X=d("img"),Ze=a(),A=d("small"),A.innerHTML=xt,Ee=a(),h(O.$$.fragment),Re=a(),h(D.$$.fragment),Xe=a(),ee=d("p"),ee.innerHTML=$t,Be=a(),h(te.$$.fragment),Ge=a(),U=d("div"),h(se.$$.fragment),De=a(),ue=d("p"),ue.innerHTML=zt,et=a(),h(B.$$.fragment),Ke=a(),h(oe.$$.fragment),Ve=a(),h(ne.$$.fragment),qe=a(),v=d("div"),h(ae.$$.fragment),tt=a(),fe=d("p"),fe.textContent=It,st=a(),_e=d("p"),_e.innerHTML=Ct,ot=a(),$=d("div"),h(re.$$.fragment),nt=a(),be=d("p"),be.innerHTML=Ut,at=a(),Me=d("p"),Me.textContent=Wt,rt=a(),Te=d("p"),Te.innerHTML=Ft,He=a(),h(le.$$.fragment),Pe=a(),k=d("div"),h(ie.$$.fragment),lt=a(),we=d("p"),we.textContent=Nt,it=a(),ye=d("p"),ye.innerHTML=Zt,dt=a(),ke=d("p"),ke.innerHTML=Et,ct=a(),z=d("div"),h(de.$$.fragment),mt=a(),je=d("p"),je.innerHTML=Rt,pt=a(),h(G.$$.fragment),ht=a(),h(K.$$.fragment),Le=a(),h(ce.$$.fragment),Ye=a(),j=d("div"),h(me.$$.fragment),gt=a(),ve=d("p"),ve.textContent=Xt,ut=a(),Je=d("p"),Je.innerHTML=Bt,ft=a(),xe=d("p"),xe.innerHTML=Gt,_t=a(),I=d("div"),h(pe.$$.fragment),bt=a(),$e=d("p"),$e.innerHTML=Kt,Mt=a(),h(V.$$.fragment),Tt=a(),h(q.$$.fragment),Qe=a(),h(he.$$.fragment),Se=a(),ze=d("p"),this.h()},l(e){const t=Qt("svelte-u9bgzb",document.head);o=c(t,"META",{name:!0,content:!0}),t.forEach(s),w=r(e),m=c(e,"P",{}),R(m).forEach(s),p=r(e),g(T.$$.fragment,e),n=r(e),g(y.$$.fragment,e),Ce=r(e),L=c(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-xd2oy9"&&(L.innerHTML=yt),Ue=r(e),Y=c(e,"P",{"data-svelte-h":!0}),M(Y)!=="svelte-19ehga5"&&(Y.innerHTML=kt),We=r(e),Q=c(e,"P",{"data-svelte-h":!0}),M(Q)!=="svelte-vfdo9a"&&(Q.textContent=jt),Fe=r(e),S=c(e,"P",{"data-svelte-h":!0}),M(S)!=="svelte-1tb5s4o"&&(S.innerHTML=vt),Ne=r(e),X=c(e,"IMG",{src:!0,alt:!0,width:!0}),Ze=r(e),A=c(e,"SMALL",{"data-svelte-h":!0}),M(A)!=="svelte-dphpfh"&&(A.innerHTML=xt),Ee=r(e),g(O.$$.fragment,e),Re=r(e),g(D.$$.fragment,e),Xe=r(e),ee=c(e,"P",{"data-svelte-h":!0}),M(ee)!=="svelte-1x2oym7"&&(ee.innerHTML=$t),Be=r(e),g(te.$$.fragment,e),Ge=r(e),U=c(e,"DIV",{class:!0});var E=R(U);g(se.$$.fragment,E),De=r(E),ue=c(E,"P",{"data-svelte-h":!0}),M(ue)!=="svelte-1beb95q"&&(ue.innerHTML=zt),et=r(E),g(B.$$.fragment,E),E.forEach(s),Ke=r(e),g(oe.$$.fragment,e),Ve=r(e),g(ne.$$.fragment,e),qe=r(e),v=c(e,"DIV",{class:!0});var W=R(v);g(ae.$$.fragment,W),tt=r(W),fe=c(W,"P",{"data-svelte-h":!0}),M(fe)!=="svelte-q6hxku"&&(fe.textContent=It),st=r(W),_e=c(W,"P",{"data-svelte-h":!0}),M(_e)!=="svelte-q4b48e"&&(_e.innerHTML=Ct),ot=r(W),$=c(W,"DIV",{class:!0});var F=R($);g(re.$$.fragment,F),nt=r(F),be=c(F,"P",{"data-svelte-h":!0}),M(be)!=="svelte-iva4xh"&&(be.innerHTML=Ut),at=r(F),Me=c(F,"P",{"data-svelte-h":!0}),M(Me)!=="svelte-ws0hzs"&&(Me.textContent=Wt),rt=r(F),Te=c(F,"P",{"data-svelte-h":!0}),M(Te)!=="svelte-ar15lt"&&(Te.innerHTML=Ft),F.forEach(s),W.forEach(s),He=r(e),g(le.$$.fragment,e),Pe=r(e),k=c(e,"DIV",{class:!0});var J=R(k);g(ie.$$.fragment,J),lt=r(J),we=c(J,"P",{"data-svelte-h":!0}),M(we)!=="svelte-6ep7ku"&&(we.textContent=Nt),it=r(J),ye=c(J,"P",{"data-svelte-h":!0}),M(ye)!=="svelte-6pahdo"&&(ye.innerHTML=Zt),dt=r(J),ke=c(J,"P",{"data-svelte-h":!0}),M(ke)!=="svelte-hswkmf"&&(ke.innerHTML=Et),ct=r(J),z=c(J,"DIV",{class:!0});var N=R(z);g(de.$$.fragment,N),mt=r(N),je=c(N,"P",{"data-svelte-h":!0}),M(je)!=="svelte-1yam5u8"&&(je.innerHTML=Rt),pt=r(N),g(G.$$.fragment,N),ht=r(N),g(K.$$.fragment,N),N.forEach(s),J.forEach(s),Le=r(e),g(ce.$$.fragment,e),Ye=r(e),j=c(e,"DIV",{class:!0});var Z=R(j);g(me.$$.fragment,Z),gt=r(Z),ve=c(Z,"P",{"data-svelte-h":!0}),M(ve)!=="svelte-ydmd28"&&(ve.textContent=Xt),ut=r(Z),Je=c(Z,"P",{"data-svelte-h":!0}),M(Je)!=="svelte-6pahdo"&&(Je.innerHTML=Bt),ft=r(Z),xe=c(Z,"P",{"data-svelte-h":!0}),M(xe)!=="svelte-hswkmf"&&(xe.innerHTML=Gt),_t=r(Z),I=c(Z,"DIV",{class:!0});var H=R(I);g(pe.$$.fragment,H),bt=r(H),$e=c(H,"P",{"data-svelte-h":!0}),M($e)!=="svelte-1p9m7ni"&&($e.innerHTML=Kt),Mt=r(H),g(V.$$.fragment,H),Tt=r(H),g(q.$$.fragment,H),H.forEach(s),Z.forEach(s),Qe=r(e),g(he.$$.fragment,e),Se=r(e),ze=c(e,"P",{}),R(ze).forEach(s),this.h()},h(){C(o,"name","hf:doc:metadata"),C(o,"content",os),Ht(X.src,Jt="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/kosmos_2_overview.jpg")||C(X,"src",Jt),C(X,"alt","drawing"),C(X,"width","600"),C(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(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){i(document.head,o),l(e,w,t),l(e,m,t),l(e,p,t),u(T,e,t),l(e,n,t),u(y,e,t),l(e,Ce,t),l(e,L,t),l(e,Ue,t),l(e,Y,t),l(e,We,t),l(e,Q,t),l(e,Fe,t),l(e,S,t),l(e,Ne,t),l(e,X,t),l(e,Ze,t),l(e,A,t),l(e,Ee,t),u(O,e,t),l(e,Re,t),u(D,e,t),l(e,Xe,t),l(e,ee,t),l(e,Be,t),u(te,e,t),l(e,Ge,t),l(e,U,t),u(se,U,null),i(U,De),i(U,ue),i(U,et),u(B,U,null),l(e,Ke,t),u(oe,e,t),l(e,Ve,t),u(ne,e,t),l(e,qe,t),l(e,v,t),u(ae,v,null),i(v,tt),i(v,fe),i(v,st),i(v,_e),i(v,ot),i(v,$),u(re,$,null),i($,nt),i($,be),i($,at),i($,Me),i($,rt),i($,Te),l(e,He,t),u(le,e,t),l(e,Pe,t),l(e,k,t),u(ie,k,null),i(k,lt),i(k,we),i(k,it),i(k,ye),i(k,dt),i(k,ke),i(k,ct),i(k,z),u(de,z,null),i(z,mt),i(z,je),i(z,pt),u(G,z,null),i(z,ht),u(K,z,null),l(e,Le,t),u(ce,e,t),l(e,Ye,t),l(e,j,t),u(me,j,null),i(j,gt),i(j,ve),i(j,ut),i(j,Je),i(j,ft),i(j,xe),i(j,_t),i(j,I),u(pe,I,null),i(I,bt),i(I,$e),i(I,Mt),u(V,I,null),i(I,Tt),u(q,I,null),l(e,Qe,t),u(he,e,t),l(e,Se,t),l(e,ze,t),Ae=!0},p(e,[t]){const E={};t&2&&(E.$$scope={dirty:t,ctx:e}),B.$set(E);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),G.$set(W);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),K.$set(F);const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),V.$set(J);const N={};t&2&&(N.$$scope={dirty:t,ctx:e}),q.$set(N)},i(e){Ae||(f(T.$$.fragment,e),f(y.$$.fragment,e),f(O.$$.fragment,e),f(D.$$.fragment,e),f(te.$$.fragment,e),f(se.$$.fragment,e),f(B.$$.fragment,e),f(oe.$$.fragment,e),f(ne.$$.fragment,e),f(ae.$$.fragment,e),f(re.$$.fragment,e),f(le.$$.fragment,e),f(ie.$$.fragment,e),f(de.$$.fragment,e),f(G.$$.fragment,e),f(K.$$.fragment,e),f(ce.$$.fragment,e),f(me.$$.fragment,e),f(pe.$$.fragment,e),f(V.$$.fragment,e),f(q.$$.fragment,e),f(he.$$.fragment,e),Ae=!0)},o(e){_(T.$$.fragment,e),_(y.$$.fragment,e),_(O.$$.fragment,e),_(D.$$.fragment,e),_(te.$$.fragment,e),_(se.$$.fragment,e),_(B.$$.fragment,e),_(oe.$$.fragment,e),_(ne.$$.fragment,e),_(ae.$$.fragment,e),_(re.$$.fragment,e),_(le.$$.fragment,e),_(ie.$$.fragment,e),_(de.$$.fragment,e),_(G.$$.fragment,e),_(K.$$.fragment,e),_(ce.$$.fragment,e),_(me.$$.fragment,e),_(pe.$$.fragment,e),_(V.$$.fragment,e),_(q.$$.fragment,e),_(he.$$.fragment,e),Ae=!1},d(e){e&&(s(w),s(m),s(p),s(n),s(Ce),s(L),s(Ue),s(Y),s(We),s(Q),s(Fe),s(S),s(Ne),s(X),s(Ze),s(A),s(Ee),s(Re),s(Xe),s(ee),s(Be),s(Ge),s(U),s(Ke),s(Ve),s(qe),s(v),s(He),s(Pe),s(k),s(Le),s(Ye),s(j),s(Qe),s(Se),s(ze)),s(o),b(T,e),b(y,e),b(O,e),b(D,e),b(te,e),b(se),b(B),b(oe,e),b(ne,e),b(ae),b(re),b(le,e),b(ie),b(de),b(G),b(K),b(ce,e),b(me),b(pe),b(V),b(q),b(he,e)}}}const os='{"title":"KOSMOS-2","local":"kosmos-2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Example","local":"example","sections":[],"depth":2},{"title":"Kosmos2Config","local":"transformers.Kosmos2Config","sections":[],"depth":2},{"title":"Kosmos2ImageProcessor","local":"kosmos2imageprocessor","sections":[],"depth":2},{"title":"Kosmos2Processor","local":"transformers.Kosmos2Processor","sections":[],"depth":2},{"title":"Kosmos2Model","local":"transformers.Kosmos2Model","sections":[],"depth":2},{"title":"Kosmos2ForConditionalGeneration","local":"transformers.Kosmos2ForConditionalGeneration","sections":[],"depth":2}],"depth":1}';function ns(x){return Pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ps extends Lt{constructor(o){super(),Yt(this,o,ns,ss,qt,{})}}export{ps as component};
