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 K,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 yt}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as P,E as St}from"../chunks/EditOnGithub.91d95064.js";function At(x){let o,y="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=y,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=y),m=r(n),g(p.$$.fragment,n)},m(n,w){l(n,o,w),l(n,m,w),u(p,n,w),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,y=`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=y},l(m){o=c(m,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=y)},m(m,p){l(m,o,p)},p:Ie,d(m){m&&s(o)}}}function Dt(x){let o,y="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=y,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-kvfsh7"&&(o.textContent=y),m=r(n),g(p.$$.fragment,n)},m(n,w){l(n,o,w),l(n,m,w),u(p,n,w),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,y=`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=y},l(m){o=c(m,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=y)},m(m,p){l(m,o,p)},p:Ie,d(m){m&&s(o)}}}function ts(x){let o,y="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=y,m=a(),h(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),M(o)!=="svelte-kvfsh7"&&(o.textContent=y),m=r(n),g(p.$$.fragment,n)},m(n,w){l(n,o,w),l(n,m,w),u(p,n,w),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,y,m,p,T,n,w,Ce,L,wt='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.`,Fe,Q,jt="The abstract from the paper is the following:",We,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,E,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>.',Re,O,Ke,D,Ee,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>.',Ge,te,Xe,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,G,Be,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/deit#transformers.DeiTFeatureExtractor.__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,Ft="Please refer to the docstring of the above two methods for more information.",rt,Te,Wt="The rest of this documentation shows the arguments specific to <code>Kosmos2Processor</code>.",He,le,Pe,k,ie,lt,ye,Nt="KOSMOS-2 Model for generating text and image features. The model consists of a vision encoder and a language model.",it,we,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,Rt=`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,Kt='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,X,ht,B,Le,ce,Ye,j,me,gt,ve,Et=`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,Gt=`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,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,I,pe,bt,$e,Bt='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"}}),w=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#L206"}}),G=new yt({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:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]] = None"},{name:"text",val:": typing.Union[str, typing.List[str]] = None"},{name:"audio",val:" = None"},{name:"videos",val:" = None"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.models.kosmos2.processing_kosmos2.Kosmos2ProcessorKwargs]"}],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#L1788"}}),de=new ge({props:{name:"forward",anchor:"transformers.Kosmos2Model.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"image_embeds_position_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"image_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": bool = False"},{name:"return_dict",val:": typing.Optional[bool] = 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/deit#transformers.DeiTFeatureExtractor.__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>.`,name:"past_key_values"},{anchor:"transformers.Kosmos2Model.forward.image_embeds",description:`<strong>image_embeds</strong> &#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:"image_embeds"},{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#L1814",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>
`}}),X=new Vt({props:{$$slots:{default:[Ot]},$$scope:{ctx:x}}}),B=new yt({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#L1921"}}),pe=new ge({props:{name:"forward",anchor:"transformers.Kosmos2ForConditionalGeneration.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"image_embeds_position_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"image_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = 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/deit#transformers.DeiTFeatureExtractor.__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>.`,name:"past_key_values"},{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.image_embeds",description:`<strong>image_embeds</strong> &#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:"image_embeds"},{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#L1956",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 yt({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"),y=a(),m=d("p"),p=a(),h(T.$$.fragment),n=a(),h(w.$$.fragment),Ce=a(),L=d("p"),L.innerHTML=wt,Ue=a(),Y=d("p"),Y.innerHTML=kt,Fe=a(),Q=d("p"),Q.textContent=jt,We=a(),S=d("p"),S.innerHTML=vt,Ne=a(),E=d("img"),Ze=a(),A=d("small"),A.innerHTML=xt,Re=a(),h(O.$$.fragment),Ke=a(),h(D.$$.fragment),Ee=a(),ee=d("p"),ee.innerHTML=$t,Ge=a(),h(te.$$.fragment),Xe=a(),U=d("div"),h(se.$$.fragment),De=a(),ue=d("p"),ue.innerHTML=zt,et=a(),h(G.$$.fragment),Be=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=Ft,rt=a(),Te=d("p"),Te.innerHTML=Wt,He=a(),h(le.$$.fragment),Pe=a(),k=d("div"),h(ie.$$.fragment),lt=a(),ye=d("p"),ye.textContent=Nt,it=a(),we=d("p"),we.innerHTML=Zt,dt=a(),ke=d("p"),ke.innerHTML=Rt,ct=a(),z=d("div"),h(de.$$.fragment),mt=a(),je=d("p"),je.innerHTML=Kt,pt=a(),h(X.$$.fragment),ht=a(),h(B.$$.fragment),Le=a(),h(ce.$$.fragment),Ye=a(),j=d("div"),h(me.$$.fragment),gt=a(),ve=d("p"),ve.textContent=Et,ut=a(),Je=d("p"),Je.innerHTML=Gt,ft=a(),xe=d("p"),xe.innerHTML=Xt,_t=a(),I=d("div"),h(pe.$$.fragment),bt=a(),$e=d("p"),$e.innerHTML=Bt,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),y=r(e),m=c(e,"P",{}),K(m).forEach(s),p=r(e),g(T.$$.fragment,e),n=r(e),g(w.$$.fragment,e),Ce=r(e),L=c(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-xd2oy9"&&(L.innerHTML=wt),Ue=r(e),Y=c(e,"P",{"data-svelte-h":!0}),M(Y)!=="svelte-19ehga5"&&(Y.innerHTML=kt),Fe=r(e),Q=c(e,"P",{"data-svelte-h":!0}),M(Q)!=="svelte-vfdo9a"&&(Q.textContent=jt),We=r(e),S=c(e,"P",{"data-svelte-h":!0}),M(S)!=="svelte-1tb5s4o"&&(S.innerHTML=vt),Ne=r(e),E=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),Re=r(e),g(O.$$.fragment,e),Ke=r(e),g(D.$$.fragment,e),Ee=r(e),ee=c(e,"P",{"data-svelte-h":!0}),M(ee)!=="svelte-1x2oym7"&&(ee.innerHTML=$t),Ge=r(e),g(te.$$.fragment,e),Xe=r(e),U=c(e,"DIV",{class:!0});var R=K(U);g(se.$$.fragment,R),De=r(R),ue=c(R,"P",{"data-svelte-h":!0}),M(ue)!=="svelte-1beb95q"&&(ue.innerHTML=zt),et=r(R),g(G.$$.fragment,R),R.forEach(s),Be=r(e),g(oe.$$.fragment,e),Ve=r(e),g(ne.$$.fragment,e),qe=r(e),v=c(e,"DIV",{class:!0});var F=K(v);g(ae.$$.fragment,F),tt=r(F),fe=c(F,"P",{"data-svelte-h":!0}),M(fe)!=="svelte-q6hxku"&&(fe.textContent=It),st=r(F),_e=c(F,"P",{"data-svelte-h":!0}),M(_e)!=="svelte-q4b48e"&&(_e.innerHTML=Ct),ot=r(F),$=c(F,"DIV",{class:!0});var W=K($);g(re.$$.fragment,W),nt=r(W),be=c(W,"P",{"data-svelte-h":!0}),M(be)!=="svelte-1u6g4st"&&(be.innerHTML=Ut),at=r(W),Me=c(W,"P",{"data-svelte-h":!0}),M(Me)!=="svelte-ws0hzs"&&(Me.textContent=Ft),rt=r(W),Te=c(W,"P",{"data-svelte-h":!0}),M(Te)!=="svelte-ar15lt"&&(Te.innerHTML=Wt),W.forEach(s),F.forEach(s),He=r(e),g(le.$$.fragment,e),Pe=r(e),k=c(e,"DIV",{class:!0});var J=K(k);g(ie.$$.fragment,J),lt=r(J),ye=c(J,"P",{"data-svelte-h":!0}),M(ye)!=="svelte-6ep7ku"&&(ye.textContent=Nt),it=r(J),we=c(J,"P",{"data-svelte-h":!0}),M(we)!=="svelte-6pahdo"&&(we.innerHTML=Zt),dt=r(J),ke=c(J,"P",{"data-svelte-h":!0}),M(ke)!=="svelte-hswkmf"&&(ke.innerHTML=Rt),ct=r(J),z=c(J,"DIV",{class:!0});var N=K(z);g(de.$$.fragment,N),mt=r(N),je=c(N,"P",{"data-svelte-h":!0}),M(je)!=="svelte-1yam5u8"&&(je.innerHTML=Kt),pt=r(N),g(X.$$.fragment,N),ht=r(N),g(B.$$.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=K(j);g(me.$$.fragment,Z),gt=r(Z),ve=c(Z,"P",{"data-svelte-h":!0}),M(ve)!=="svelte-ydmd28"&&(ve.textContent=Et),ut=r(Z),Je=c(Z,"P",{"data-svelte-h":!0}),M(Je)!=="svelte-6pahdo"&&(Je.innerHTML=Gt),ft=r(Z),xe=c(Z,"P",{"data-svelte-h":!0}),M(xe)!=="svelte-hswkmf"&&(xe.innerHTML=Xt),_t=r(Z),I=c(Z,"DIV",{class:!0});var H=K(I);g(pe.$$.fragment,H),bt=r(H),$e=c(H,"P",{"data-svelte-h":!0}),M($e)!=="svelte-1p9m7ni"&&($e.innerHTML=Bt),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",{}),K(ze).forEach(s),this.h()},h(){C(o,"name","hf:doc:metadata"),C(o,"content",os),Ht(E.src,Jt="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/kosmos_2_overview.jpg")||C(E,"src",Jt),C(E,"alt","drawing"),C(E,"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,y,t),l(e,m,t),l(e,p,t),u(T,e,t),l(e,n,t),u(w,e,t),l(e,Ce,t),l(e,L,t),l(e,Ue,t),l(e,Y,t),l(e,Fe,t),l(e,Q,t),l(e,We,t),l(e,S,t),l(e,Ne,t),l(e,E,t),l(e,Ze,t),l(e,A,t),l(e,Re,t),u(O,e,t),l(e,Ke,t),u(D,e,t),l(e,Ee,t),l(e,ee,t),l(e,Ge,t),u(te,e,t),l(e,Xe,t),l(e,U,t),u(se,U,null),i(U,De),i(U,ue),i(U,et),u(G,U,null),l(e,Be,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,ye),i(k,it),i(k,we),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(X,z,null),i(z,ht),u(B,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 R={};t&2&&(R.$$scope={dirty:t,ctx:e}),G.$set(R);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),X.$set(F);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),B.$set(W);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(w.$$.fragment,e),f(O.$$.fragment,e),f(D.$$.fragment,e),f(te.$$.fragment,e),f(se.$$.fragment,e),f(G.$$.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(X.$$.fragment,e),f(B.$$.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),_(w.$$.fragment,e),_(O.$$.fragment,e),_(D.$$.fragment,e),_(te.$$.fragment,e),_(se.$$.fragment,e),_(G.$$.fragment,e),_(oe.$$.fragment,e),_(ne.$$.fragment,e),_(ae.$$.fragment,e),_(re.$$.fragment,e),_(le.$$.fragment,e),_(ie.$$.fragment,e),_(de.$$.fragment,e),_(X.$$.fragment,e),_(B.$$.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(y),s(m),s(p),s(n),s(Ce),s(L),s(Ue),s(Y),s(Fe),s(Q),s(We),s(S),s(Ne),s(E),s(Ze),s(A),s(Re),s(Ke),s(Ee),s(ee),s(Ge),s(Xe),s(U),s(Be),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(w,e),b(O,e),b(D,e),b(te,e),b(se),b(G),b(oe,e),b(ne,e),b(ae),b(re),b(le,e),b(ie),b(de),b(X),b(B),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};
