import{s as Ht,f as Lt,o as Yt,n as Ie}from"../chunks/scheduler.25b97de1.js";import{S as Qt,i as St,g as d,s as a,r as u,A as At,h as c,f as s,c as r,j as E,u as g,x as h,k as C,y as i,a as l,v as f,d as _,t as b,w as M}from"../chunks/index.d9030fc9.js";import{T as Pt}from"../chunks/Tip.baa67368.js";import{D as he}from"../chunks/Docstring.e257edda.js";import{C as Oe}from"../chunks/CodeBlock.e6cd0d95.js";import{E as wt}from"../chunks/ExampleCodeBlock.20db4b6e.js";import{H as ze,E as Ot}from"../chunks/EditOnGithub.91d95064.js";function Dt(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(),u(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),h(o)!=="svelte-11lpom8"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),f(p,n,y),T=!0},p:Ie,i(n){T||(_(p.$$.fragment,n),T=!0)},o(n){b(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),M(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}),h(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:"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(),u(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),h(o)!=="svelte-kvfsh7"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),f(p,n,y),T=!0},p:Ie,i(n){T||(_(p.$$.fragment,n),T=!0)},o(n){b(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),M(p,n)}}}function ss(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}),h(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(m,p){l(m,o,p)},p:Ie,d(m){m&&s(o)}}}function os(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(),u(p.$$.fragment)},l(n){o=c(n,"P",{"data-svelte-h":!0}),h(o)!=="svelte-kvfsh7"&&(o.textContent=w),m=r(n),g(p.$$.fragment,n)},m(n,y){l(n,o,y),l(n,m,y),f(p,n,y),T=!0},p:Ie,i(n){T||(_(p.$$.fragment,n),T=!0)},o(n){b(p.$$.fragment,n),T=!1},d(n){n&&(s(o),s(m)),M(p,n)}}}function ns(x){let o,w,m,p,T,n,y,Ce,H,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,L,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.`,Ne,Y,jt="The abstract from the paper is the following:",We,Q,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>',Fe,X,Jt,Ze,S,xt='Overview of tasks that KOSMOS-2 can handle. Taken from the <a href="https://arxiv.org/abs/2306.14824">original paper</a>.',Re,A,Ee,O,Xe,D,zt='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,ee,Ge,U,te,De,ue,$t=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_31172/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,Ve,se,Ke,oe,qe,v,ne,tt,ge,It=`Constructs an KOSMOS-2 processor which wraps a KOSMOS-2 image processor and a KOSMOS-2 tokenizer into a single
processor.`,st,fe,Ct=`<a href="/docs/transformers/pr_31172/en/model_doc/kosmos-2#transformers.Kosmos2Processor">Kosmos2Processor</a> offers all the functionalities of <a href="/docs/transformers/pr_31172/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> and some functionalities of
<a href="/docs/transformers/pr_31172/en/model_doc/xlm-roberta#transformers.XLMRobertaTokenizerFast">XLMRobertaTokenizerFast</a>. See the docstring of <a href="/docs/transformers/pr_31172/en/model_doc/kosmos-2#transformers.Kosmos2Processor.__call__"><strong>call</strong>()</a> and <code>decode()</code>
for more information.`,ot,z,ae,nt,_e,Ut=`This method uses <a href="/docs/transformers/pr_31172/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__">CLIPImageProcessor.<strong>call</strong>()</a> method to prepare image(s) for the model, and
<a href="/docs/transformers/pr_31172/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">XLMRobertaTokenizerFast.<strong>call</strong>()</a> to prepare text for the model.`,at,be,Nt="Please refer to the docstring of the above two methods for more information.",rt,Me,Wt="The rest of this documentation shows the arguments specific to <code>Kosmos2Processor</code>.",Pe,re,Ft="## Kosmos2Model[[transformers.Kosmos2Model]]",He,k,le,lt,Te,Zt="KOSMOS-2 Model for generating text and image features. The model consists of a vision encoder and a language model.",it,we,Rt=`This model inherits from <a href="/docs/transformers/pr_31172/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,ye,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,$,ie,mt,ke,Xt='The <a href="/docs/transformers/pr_31172/en/model_doc/kosmos-2#transformers.Kosmos2Model">Kosmos2Model</a> forward method, overrides the <code>__call__</code> special method.',pt,G,ht,V,Le,de,Bt="## Kosmos2ForConditionalGeneration[[transformers.Kosmos2ForConditionalGeneration]]",Ye,j,ce,ut,je,Gt=`KOSMOS-2 Model for generating text and bounding boxes given an image. The model consists of a vision encoder and a
language model.`,gt,ve,Vt=`This model inherits from <a href="/docs/transformers/pr_31172/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,Je,Kt=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,_t,I,me,bt,xe,qt='The <a href="/docs/transformers/pr_31172/en/model_doc/kosmos-2#transformers.Kosmos2ForConditionalGeneration">Kosmos2ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',Mt,K,Tt,q,Qe,pe,Se,$e,Ae;return T=new ze({props:{title:"KOSMOS-2",local:"kosmos-2",headingTag:"h1"}}),y=new ze({props:{title:"Overview",local:"overview",headingTag:"h2"}}),A=new ze({props:{title:"Example",local:"example",headingTag:"h2"}}),O=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}}),ee=new ze({props:{title:"Kosmos2Config",local:"transformers.Kosmos2Config",headingTag:"h2"}}),te=new he({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/vr_31172/src/transformers/models/kosmos2/configuration_kosmos2.py#L237"}}),B=new wt({props:{anchor:"transformers.Kosmos2Config.example",$$slots:{default:[Dt]},$$scope:{ctx:x}}}),se=new ze({props:{title:"Kosmos2ImageProcessor",local:"kosmos2imageprocessor",headingTag:"h2"}}),oe=new ze({props:{title:"Kosmos2Processor",local:"transformers.Kosmos2Processor",headingTag:"h2"}}),ne=new he({props:{name:"class transformers.Kosmos2Processor",anchor:"transformers.Kosmos2Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:""},{name:"num_patch_index_tokens",val:" = 1024"}],parametersDescription:[{anchor:"transformers.Kosmos2Processor.image_processor",description:`<strong>image_processor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/pr_31172/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/vr_31172/src/transformers/models/kosmos2/processing_kosmos2.py#L38"}}),ae=new he({props:{name:"__call__",anchor:"transformers.Kosmos2Processor.__call__",parameters:[{name:"images",val:": Union = None"},{name:"text",val:": Union = None"},{name:"bboxes",val:": Union = None"},{name:"num_image_tokens",val:": Optional = 64"},{name:"first_image_token_id",val:": Optional = None"},{name:"add_special_tokens",val:": bool = True"},{name:"add_eos_token",val:": bool = False"},{name:"padding",val:": Union = False"},{name:"truncation",val:": Union = None"},{name:"max_length",val:": Optional = None"},{name:"pad_to_multiple_of",val:": Optional = None"},{name:"return_attention_mask",val:": Optional = None"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"return_tensors",val:": Union = None"},{name:"**kwargs",val:""}],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>, 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/vr_31172/src/transformers/models/kosmos2/processing_kosmos2.py#L105"}}),le=new he({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/pr_31172/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/pr_31172/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/vr_31172/src/transformers/models/kosmos2/modeling_kosmos2.py#L1729"}}),ie=new he({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:"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/pr_31172/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/pr_31172/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__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/pr_31172/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_31172/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_31172/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.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_31172/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_31172/src/transformers/models/kosmos2/modeling_kosmos2.py#L1755",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 Pt({props:{$$slots:{default:[es]},$$scope:{ctx:x}}}),V=new wt({props:{anchor:"transformers.Kosmos2Model.forward.example",$$slots:{default:[ts]},$$scope:{ctx:x}}}),ce=new he({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/pr_31172/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/pr_31172/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/vr_31172/src/transformers/models/kosmos2/modeling_kosmos2.py#L1860"}}),me=new he({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/pr_31172/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/pr_31172/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__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/pr_31172/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_31172/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_31172/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.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_31172/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/vr_31172/src/transformers/models/kosmos2/modeling_kosmos2.py#L1895",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>
`}}),K=new Pt({props:{$$slots:{default:[ss]},$$scope:{ctx:x}}}),q=new wt({props:{anchor:"transformers.Kosmos2ForConditionalGeneration.forward.example",$$slots:{default:[os]},$$scope:{ctx:x}}}),pe=new Ot({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(),u(T.$$.fragment),n=a(),u(y.$$.fragment),Ce=a(),H=d("p"),H.innerHTML=yt,Ue=a(),L=d("p"),L.innerHTML=kt,Ne=a(),Y=d("p"),Y.textContent=jt,We=a(),Q=d("p"),Q.innerHTML=vt,Fe=a(),X=d("img"),Ze=a(),S=d("small"),S.innerHTML=xt,Re=a(),u(A.$$.fragment),Ee=a(),u(O.$$.fragment),Xe=a(),D=d("p"),D.innerHTML=zt,Be=a(),u(ee.$$.fragment),Ge=a(),U=d("div"),u(te.$$.fragment),De=a(),ue=d("p"),ue.innerHTML=$t,et=a(),u(B.$$.fragment),Ve=a(),u(se.$$.fragment),Ke=a(),u(oe.$$.fragment),qe=a(),v=d("div"),u(ne.$$.fragment),tt=a(),ge=d("p"),ge.textContent=It,st=a(),fe=d("p"),fe.innerHTML=Ct,ot=a(),z=d("div"),u(ae.$$.fragment),nt=a(),_e=d("p"),_e.innerHTML=Ut,at=a(),be=d("p"),be.textContent=Nt,rt=a(),Me=d("p"),Me.innerHTML=Wt,Pe=a(),re=d("p"),re.textContent=Ft,He=a(),k=d("div"),u(le.$$.fragment),lt=a(),Te=d("p"),Te.textContent=Zt,it=a(),we=d("p"),we.innerHTML=Rt,dt=a(),ye=d("p"),ye.innerHTML=Et,ct=a(),$=d("div"),u(ie.$$.fragment),mt=a(),ke=d("p"),ke.innerHTML=Xt,pt=a(),u(G.$$.fragment),ht=a(),u(V.$$.fragment),Le=a(),de=d("p"),de.textContent=Bt,Ye=a(),j=d("div"),u(ce.$$.fragment),ut=a(),je=d("p"),je.textContent=Gt,gt=a(),ve=d("p"),ve.innerHTML=Vt,ft=a(),Je=d("p"),Je.innerHTML=Kt,_t=a(),I=d("div"),u(me.$$.fragment),bt=a(),xe=d("p"),xe.innerHTML=qt,Mt=a(),u(K.$$.fragment),Tt=a(),u(q.$$.fragment),Qe=a(),u(pe.$$.fragment),Se=a(),$e=d("p"),this.h()},l(e){const t=At("svelte-u9bgzb",document.head);o=c(t,"META",{name:!0,content:!0}),t.forEach(s),w=r(e),m=c(e,"P",{}),E(m).forEach(s),p=r(e),g(T.$$.fragment,e),n=r(e),g(y.$$.fragment,e),Ce=r(e),H=c(e,"P",{"data-svelte-h":!0}),h(H)!=="svelte-xd2oy9"&&(H.innerHTML=yt),Ue=r(e),L=c(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-19ehga5"&&(L.innerHTML=kt),Ne=r(e),Y=c(e,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-vfdo9a"&&(Y.textContent=jt),We=r(e),Q=c(e,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-1tb5s4o"&&(Q.innerHTML=vt),Fe=r(e),X=c(e,"IMG",{src:!0,alt:!0,width:!0}),Ze=r(e),S=c(e,"SMALL",{"data-svelte-h":!0}),h(S)!=="svelte-dphpfh"&&(S.innerHTML=xt),Re=r(e),g(A.$$.fragment,e),Ee=r(e),g(O.$$.fragment,e),Xe=r(e),D=c(e,"P",{"data-svelte-h":!0}),h(D)!=="svelte-1x2oym7"&&(D.innerHTML=zt),Be=r(e),g(ee.$$.fragment,e),Ge=r(e),U=c(e,"DIV",{class:!0});var R=E(U);g(te.$$.fragment,R),De=r(R),ue=c(R,"P",{"data-svelte-h":!0}),h(ue)!=="svelte-a7zh14"&&(ue.innerHTML=$t),et=r(R),g(B.$$.fragment,R),R.forEach(s),Ve=r(e),g(se.$$.fragment,e),Ke=r(e),g(oe.$$.fragment,e),qe=r(e),v=c(e,"DIV",{class:!0});var N=E(v);g(ne.$$.fragment,N),tt=r(N),ge=c(N,"P",{"data-svelte-h":!0}),h(ge)!=="svelte-q6hxku"&&(ge.textContent=It),st=r(N),fe=c(N,"P",{"data-svelte-h":!0}),h(fe)!=="svelte-1e33a36"&&(fe.innerHTML=Ct),ot=r(N),z=c(N,"DIV",{class:!0});var W=E(z);g(ae.$$.fragment,W),nt=r(W),_e=c(W,"P",{"data-svelte-h":!0}),h(_e)!=="svelte-1t14jn9"&&(_e.innerHTML=Ut),at=r(W),be=c(W,"P",{"data-svelte-h":!0}),h(be)!=="svelte-ws0hzs"&&(be.textContent=Nt),rt=r(W),Me=c(W,"P",{"data-svelte-h":!0}),h(Me)!=="svelte-ar15lt"&&(Me.innerHTML=Wt),W.forEach(s),N.forEach(s),Pe=r(e),re=c(e,"P",{"data-svelte-h":!0}),h(re)!=="svelte-16o3i2e"&&(re.textContent=Ft),He=r(e),k=c(e,"DIV",{class:!0});var J=E(k);g(le.$$.fragment,J),lt=r(J),Te=c(J,"P",{"data-svelte-h":!0}),h(Te)!=="svelte-6ep7ku"&&(Te.textContent=Zt),it=r(J),we=c(J,"P",{"data-svelte-h":!0}),h(we)!=="svelte-1czo7a0"&&(we.innerHTML=Rt),dt=r(J),ye=c(J,"P",{"data-svelte-h":!0}),h(ye)!=="svelte-1ydu1el"&&(ye.innerHTML=Et),ct=r(J),$=c(J,"DIV",{class:!0});var F=E($);g(ie.$$.fragment,F),mt=r(F),ke=c(F,"P",{"data-svelte-h":!0}),h(ke)!=="svelte-zgo8yg"&&(ke.innerHTML=Xt),pt=r(F),g(G.$$.fragment,F),ht=r(F),g(V.$$.fragment,F),F.forEach(s),J.forEach(s),Le=r(e),de=c(e,"P",{"data-svelte-h":!0}),h(de)!=="svelte-s08sbw"&&(de.textContent=Bt),Ye=r(e),j=c(e,"DIV",{class:!0});var Z=E(j);g(ce.$$.fragment,Z),ut=r(Z),je=c(Z,"P",{"data-svelte-h":!0}),h(je)!=="svelte-ydmd28"&&(je.textContent=Gt),gt=r(Z),ve=c(Z,"P",{"data-svelte-h":!0}),h(ve)!=="svelte-1czo7a0"&&(ve.innerHTML=Vt),ft=r(Z),Je=c(Z,"P",{"data-svelte-h":!0}),h(Je)!=="svelte-1ydu1el"&&(Je.innerHTML=Kt),_t=r(Z),I=c(Z,"DIV",{class:!0});var P=E(I);g(me.$$.fragment,P),bt=r(P),xe=c(P,"P",{"data-svelte-h":!0}),h(xe)!=="svelte-1brhi6e"&&(xe.innerHTML=qt),Mt=r(P),g(K.$$.fragment,P),Tt=r(P),g(q.$$.fragment,P),P.forEach(s),Z.forEach(s),Qe=r(e),g(pe.$$.fragment,e),Se=r(e),$e=c(e,"P",{}),E($e).forEach(s),this.h()},h(){C(o,"name","hf:doc:metadata"),C(o,"content",as),Lt(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(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(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($,"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),f(T,e,t),l(e,n,t),f(y,e,t),l(e,Ce,t),l(e,H,t),l(e,Ue,t),l(e,L,t),l(e,Ne,t),l(e,Y,t),l(e,We,t),l(e,Q,t),l(e,Fe,t),l(e,X,t),l(e,Ze,t),l(e,S,t),l(e,Re,t),f(A,e,t),l(e,Ee,t),f(O,e,t),l(e,Xe,t),l(e,D,t),l(e,Be,t),f(ee,e,t),l(e,Ge,t),l(e,U,t),f(te,U,null),i(U,De),i(U,ue),i(U,et),f(B,U,null),l(e,Ve,t),f(se,e,t),l(e,Ke,t),f(oe,e,t),l(e,qe,t),l(e,v,t),f(ne,v,null),i(v,tt),i(v,ge),i(v,st),i(v,fe),i(v,ot),i(v,z),f(ae,z,null),i(z,nt),i(z,_e),i(z,at),i(z,be),i(z,rt),i(z,Me),l(e,Pe,t),l(e,re,t),l(e,He,t),l(e,k,t),f(le,k,null),i(k,lt),i(k,Te),i(k,it),i(k,we),i(k,dt),i(k,ye),i(k,ct),i(k,$),f(ie,$,null),i($,mt),i($,ke),i($,pt),f(G,$,null),i($,ht),f(V,$,null),l(e,Le,t),l(e,de,t),l(e,Ye,t),l(e,j,t),f(ce,j,null),i(j,ut),i(j,je),i(j,gt),i(j,ve),i(j,ft),i(j,Je),i(j,_t),i(j,I),f(me,I,null),i(I,bt),i(I,xe),i(I,Mt),f(K,I,null),i(I,Tt),f(q,I,null),l(e,Qe,t),f(pe,e,t),l(e,Se,t),l(e,$e,t),Ae=!0},p(e,[t]){const R={};t&2&&(R.$$scope={dirty:t,ctx:e}),B.$set(R);const N={};t&2&&(N.$$scope={dirty:t,ctx:e}),G.$set(N);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),V.$set(W);const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),K.$set(J);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),q.$set(F)},i(e){Ae||(_(T.$$.fragment,e),_(y.$$.fragment,e),_(A.$$.fragment,e),_(O.$$.fragment,e),_(ee.$$.fragment,e),_(te.$$.fragment,e),_(B.$$.fragment,e),_(se.$$.fragment,e),_(oe.$$.fragment,e),_(ne.$$.fragment,e),_(ae.$$.fragment,e),_(le.$$.fragment,e),_(ie.$$.fragment,e),_(G.$$.fragment,e),_(V.$$.fragment,e),_(ce.$$.fragment,e),_(me.$$.fragment,e),_(K.$$.fragment,e),_(q.$$.fragment,e),_(pe.$$.fragment,e),Ae=!0)},o(e){b(T.$$.fragment,e),b(y.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(B.$$.fragment,e),b(se.$$.fragment,e),b(oe.$$.fragment,e),b(ne.$$.fragment,e),b(ae.$$.fragment,e),b(le.$$.fragment,e),b(ie.$$.fragment,e),b(G.$$.fragment,e),b(V.$$.fragment,e),b(ce.$$.fragment,e),b(me.$$.fragment,e),b(K.$$.fragment,e),b(q.$$.fragment,e),b(pe.$$.fragment,e),Ae=!1},d(e){e&&(s(w),s(m),s(p),s(n),s(Ce),s(H),s(Ue),s(L),s(Ne),s(Y),s(We),s(Q),s(Fe),s(X),s(Ze),s(S),s(Re),s(Ee),s(Xe),s(D),s(Be),s(Ge),s(U),s(Ve),s(Ke),s(qe),s(v),s(Pe),s(re),s(He),s(k),s(Le),s(de),s(Ye),s(j),s(Qe),s(Se),s($e)),s(o),M(T,e),M(y,e),M(A,e),M(O,e),M(ee,e),M(te),M(B),M(se,e),M(oe,e),M(ne),M(ae),M(le),M(ie),M(G),M(V),M(ce),M(me),M(K),M(q),M(pe,e)}}}const as='{"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}],"depth":1}';function rs(x){return Yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class us extends Qt{constructor(o){super(),St(this,o,rs,ns,Ht,{})}}export{us as component};
