import{s as et,o as tt,n as He}from"../chunks/scheduler.25b97de1.js";import{S as nt,i as ot,g as m,s,r as f,A as at,h as d,f as n,c as r,j as W,u as h,x as $,k as B,y as i,a as l,v as u,d as _,t as b,w as v}from"../chunks/index.d9030fc9.js";import{T as st}from"../chunks/Tip.baa67368.js";import{D as le}from"../chunks/Docstring.ffac8efa.js";import{C as Ke}from"../chunks/CodeBlock.e6cd0d95.js";import{E as Oe}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as de,E as rt}from"../chunks/EditOnGithub.91d95064.js";function it(x){let a,P="Example:",p,c,g;return c=new Ke({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFBhbGlHZW1tYUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUyQyUyMFBhbGlHZW1tYUNvbmZpZyUyQyUyMFNpZ2xpcFZpc2lvbkNvbmZpZyUyQyUyMEdlbW1hQ29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFNpZ2xpcC1saWtlJTIwdmlzaW9uJTIwY29uZmlnJTBBdmlzaW9uX2NvbmZpZyUyMCUzRCUyMFNpZ2xpcFZpc2lvbkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFBhbGlHZW1tYSUyMGNvbmZpZyUwQXRleHRfY29uZmlnJTIwJTNEJTIwR2VtbWFDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBQYWxpR2VtbWElMjBwYWxpZ2VtbWEtM2ItMjI0JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFBhbGlHZW1tYUNvbmZpZyh2aXNpb25fY29uZmlnJTJDJTIwdGV4dF9jb25maWcpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwZnJvbSUyMHRoZSUyMHBhbGlnZW1tYS0zYi0yMjQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFBhbGlHZW1tYUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbihjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> PaliGemmaForConditionalGeneration, PaliGemmaConfig, SiglipVisionConfig, GemmaConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Siglip-like vision config</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>vision_config = SiglipVisionConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a PaliGemma config</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text_config = GemmaConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a PaliGemma paligemma-3b-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = PaliGemmaConfig(vision_config, text_config)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the paligemma-3b-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = PaliGemmaForConditionalGeneration(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(){a=m("p"),a.textContent=P,p=s(),f(c.$$.fragment)},l(o){a=d(o,"P",{"data-svelte-h":!0}),$(a)!=="svelte-11lpom8"&&(a.textContent=P),p=r(o),h(c.$$.fragment,o)},m(o,y){l(o,a,y),l(o,p,y),u(c,o,y),g=!0},p:He,i(o){g||(_(c.$$.fragment,o),g=!0)},o(o){b(c.$$.fragment,o),g=!1},d(o){o&&(n(a),n(p)),v(c,o)}}}function lt(x){let a,P=`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(){a=m("p"),a.innerHTML=P},l(p){a=d(p,"P",{"data-svelte-h":!0}),$(a)!=="svelte-fincs2"&&(a.innerHTML=P)},m(p,c){l(p,a,c)},p:He,d(p){p&&n(a)}}}function mt(x){let a,P="Example:",p,c,g;return c=new Ke({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMFBhbGlHZW1tYUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwUGFsaUdlbW1hRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZQYWxpR2VtbWEtdGVzdC0yMjRweC1oZiUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZQYWxpR2VtbWEtdGVzdC0yMjRweC1oZiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJhbnN3ZXIlMjBlbiUyMFdoZXJlJTIwaXMlMjB0aGUlMjBjb3clMjBzdGFuZGluZyUzRiUyMiUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZndi1oZiUyRlBhbGlHZW1tYS10ZXN0LTIyNHB4LWhmJTJGcmVzb2x2ZSUyRm1haW4lMkZjb3dfYmVhY2hfMS5wbmclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IodGV4dCUzRHByb21wdCUyQyUyMGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBHZW5lcmF0ZSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X2xlbmd0aCUzRDMwKSUwQXByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjBjbGVhbl91cF90b2tlbml6YXRpb25fc3BhY2VzJTNERmFsc2UpJTVCMCU1RA==",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, PaliGemmaForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = PaliGemmaForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;google/PaliGemma-test-224px-hf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;google/PaliGemma-test-224px-hf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;answer en Where is the cow standing?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/gv-hf/PaliGemma-test-224px-hf/resolve/main/cow_beach_1.png&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>inputs = processor(text=prompt, images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(**inputs, max_length=<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>]
<span class="hljs-string">&quot;answer en Where is the cow standing?\\nbeach&quot;</span>`,wrap:!1}}),{c(){a=m("p"),a.textContent=P,p=s(),f(c.$$.fragment)},l(o){a=d(o,"P",{"data-svelte-h":!0}),$(a)!=="svelte-11lpom8"&&(a.textContent=P),p=r(o),h(c.$$.fragment,o)},m(o,y){l(o,a,y),l(o,p,y),u(c,o,y),g=!0},p:He,i(o){g||(_(c.$$.fragment,o),g=!0)},o(o){b(c.$$.fragment,o),g=!1},d(o){o&&(n(a),n(p)),v(c,o)}}}function dt(x){let a,P,p,c,g,o,y,ce,H,Ve="The PaliGemma model was proposed by Google. It is a 3B VLM composed by a Siglip-400m vision encoder and a Gemma-2B decoder linked by a multimodal linear projection. It is not a chat model with images. It cuts an image into a fixed number of VIT tokens and prepends it to an optional prompt. One particularity is that the model uses full block attention on all the image tokens plus the input text tokens. It comes in 3 resolutions, 224x224, 448x448 and 896x896 with 3 base models, with 55 fine-tuned versions for different tasks, and 2 mix models.",pe,V,Le='This model was contributed by <a href="https://huggingface.co/Molbap" rel="nofollow">Molbap</a>.',ge,L,fe,G,R,$e,O,Re=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaForConditionalGeneration">PaliGemmaForConditionalGeneration</a>. It is used to instantiate an
PaliGemmamodel according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the PaliGemma-2B.`,Pe,K,Se='e.g. <a href="https://huggingface.co/paligemma-hf/paligemma-2b" rel="nofollow">paligemma-hf/paligemma-2b</a>',we,ee,Ne=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Me,z,he,S,ue,T,N,ke,te,Ee="Constructs a PaliGemma processor which wraps a PaliGemma image processor and a PaliGemma tokenizer into a single processor.",Ce,ne,Ye=`<a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaProcessor">PaliGemmaProcessor</a> offers all the functionalities of <a href="/docs/transformers/main/en/model_doc/siglip#transformers.SiglipImageProcessor">SiglipImageProcessor</a> and <a href="/docs/transformers/main/en/model_doc/llama#transformers.LlamaTokenizerFast">LlamaTokenizerFast</a>. See the
<code>__call__()</code> and <a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaProcessor.decode">decode()</a> for more information.`,xe,j,E,ze,oe,qe=`This method forwards all its arguments to GemmaTokenizerFast’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode">batch_decode()</a>. Please
refer to the docstring of this method for more information.`,je,U,Y,Ue,ae,Xe=`This method forwards all its arguments to GemmaTokenizerFast’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode">decode()</a>. Please refer to
the docstring of this method for more information.`,_e,q,be,w,X,Fe,se,Qe=`The PALIGEMMA model which consists of a vision backbone and a language model.
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.)`,Ze,re,Ae=`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.`,Je,C,Q,Ie,ie,De='The <a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaForConditionalGeneration">PaliGemmaForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',We,F,Be,Z,ve,A,ye,me,Ge;return g=new de({props:{title:"PaliGemma",local:"paligemma",headingTag:"h1"}}),y=new de({props:{title:"Overview",local:"overview",headingTag:"h2"}}),L=new de({props:{title:"PaliGemmaConfig",local:"transformers.PaliGemmaConfig",headingTag:"h2"}}),R=new le({props:{name:"class transformers.PaliGemmaConfig",anchor:"transformers.PaliGemmaConfig",parameters:[{name:"vision_config",val:" = None"},{name:"text_config",val:" = None"},{name:"ignore_index",val:" = -100"},{name:"image_token_index",val:" = 256000"},{name:"vocab_size",val:" = 257152"},{name:"projection_dim",val:" = 2048"},{name:"hidden_size",val:" = 2048"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.PaliGemmaConfig.vision_config",description:`<strong>vision_config</strong> (<code>PaliGemmaVisionConfig</code>,  <em>optional</em>) &#x2014;
Custom vision config or dict`,name:"vision_config"},{anchor:"transformers.PaliGemmaConfig.text_config",description:`<strong>text_config</strong> (<code>Union[AutoConfig, dict]</code>, <em>optional</em>) &#x2014;
The config object of the text backbone. Can be any of <code>LlamaConfig</code> or <code>MistralConfig</code>.`,name:"text_config"},{anchor:"transformers.PaliGemmaConfig.ignore_index",description:`<strong>ignore_index</strong> (<code>int</code>, <em>optional</em>, defaults to -100) &#x2014;
The ignore index for the loss function.`,name:"ignore_index"},{anchor:"transformers.PaliGemmaConfig.image_token_index",description:`<strong>image_token_index</strong> (<code>int</code>, <em>optional</em>, defaults to 256000) &#x2014;
The image token index to encode the image prompt.`,name:"image_token_index"},{anchor:"transformers.PaliGemmaConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 257152) &#x2014;
Vocabulary size of the PaliGemmamodel. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaForConditionalGeneration">~PaliGemmaForConditionalGeneration</a>`,name:"vocab_size"},{anchor:"transformers.PaliGemmaConfig.projection_dim",description:`<strong>projection_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimension of the multimodal projection space.`,name:"projection_dim"},{anchor:"transformers.PaliGemmaConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimension of the hidden layer of the Language model.`,name:"hidden_size"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/paligemma/configuration_paligemma.py#L24"}}),z=new Oe({props:{anchor:"transformers.PaliGemmaConfig.example",$$slots:{default:[it]},$$scope:{ctx:x}}}),S=new de({props:{title:"PaliGemmaProcessor",local:"transformers.PaliGemmaProcessor",headingTag:"h2"}}),N=new le({props:{name:"class transformers.PaliGemmaProcessor",anchor:"transformers.PaliGemmaProcessor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"}],parametersDescription:[{anchor:"transformers.PaliGemmaProcessor.image_processor",description:`<strong>image_processor</strong> (<a href="/docs/transformers/main/en/model_doc/siglip#transformers.SiglipImageProcessor">SiglipImageProcessor</a>, <em>optional</em>) &#x2014;
The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.PaliGemmaProcessor.tokenizer",description:`<strong>tokenizer</strong> (<a href="/docs/transformers/main/en/model_doc/llama#transformers.LlamaTokenizerFast">LlamaTokenizerFast</a>, <em>optional</em>) &#x2014;
The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/paligemma/processing_paligemma.py#L76"}}),E=new le({props:{name:"batch_decode",anchor:"transformers.PaliGemmaProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/paligemma/processing_paligemma.py#L283"}}),Y=new le({props:{name:"decode",anchor:"transformers.PaliGemmaProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/paligemma/processing_paligemma.py#L291"}}),q=new de({props:{title:"PaliGemmaForConditionalGeneration",local:"transformers.PaliGemmaForConditionalGeneration",headingTag:"h2"}}),X=new le({props:{name:"class transformers.PaliGemmaForConditionalGeneration",anchor:"transformers.PaliGemmaForConditionalGeneration",parameters:[{name:"config",val:": PaliGemmaConfig"}],parametersDescription:[{anchor:"transformers.PaliGemmaForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaConfig">PaliGemmaConfig</a> or <code>PaliGemmaVisionConfig</code>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/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/paligemma/modeling_paligemma.py#L227"}}),Q=new le({props:{name:"forward",anchor:"transformers.PaliGemmaForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"pixel_values",val:": FloatTensor = None"},{name:"attention_mask",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"past_key_values",val:": Union = None"},{name:"token_type_ids",val:": Optional = None"},{name:"cache_position",val:": Optional = None"},{name:"inputs_embeds",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.PaliGemmaForConditionalGeneration.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.PaliGemmaForConditionalGeneration.forward.pixel_values",description:'<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)) -- The tensors corresponding to the input images. Pixel values can be obtained using [AutoImageProcessor](/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor). See [SiglipImageProcessor.__call__()](/docs/transformers/main/en/model_doc/imagegpt#transformers.ImageGPTFeatureExtractor.__call__) for details ([]</code>PaliGemmaProcessor`] uses\n<a href="/docs/transformers/main/en/model_doc/siglip#transformers.SiglipImageProcessor">SiglipImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.PaliGemmaForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
<p>Indices can be obtained using <a href="/docs/transformers/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>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"attention_mask"},{anchor:"transformers.PaliGemmaForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. <a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.PaliGemmaForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.PaliGemmaForConditionalGeneration.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.PaliGemmaForConditionalGeneration.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.PaliGemmaForConditionalGeneration.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.PaliGemmaForConditionalGeneration.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.PaliGemmaForConditionalGeneration.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.</p>
<p>Args &#x2014;
labels (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>):
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (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:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/paligemma/modeling_paligemma.py#L352",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.paligemma.modeling_paligemma.PaliGemmaCausalLMOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/paligemma#transformers.PaliGemmaConfig"
>PaliGemmaConfig</a>) 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>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>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</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_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the image embeddings, <code>(batch_size, num_images, sequence_length, hidden_size)</code>.</p>
<p>image_hidden_states of the model produced by the vision encoder, and optionally by the perceiver</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.paligemma.modeling_paligemma.PaliGemmaCausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),F=new st({props:{$$slots:{default:[lt]},$$scope:{ctx:x}}}),Z=new Oe({props:{anchor:"transformers.PaliGemmaForConditionalGeneration.forward.example",$$slots:{default:[mt]},$$scope:{ctx:x}}}),A=new rt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/paligemma.md"}}),{c(){a=m("meta"),P=s(),p=m("p"),c=s(),f(g.$$.fragment),o=s(),f(y.$$.fragment),ce=s(),H=m("p"),H.textContent=Ve,pe=s(),V=m("p"),V.innerHTML=Le,ge=s(),f(L.$$.fragment),fe=s(),G=m("div"),f(R.$$.fragment),$e=s(),O=m("p"),O.innerHTML=Re,Pe=s(),K=m("p"),K.innerHTML=Se,we=s(),ee=m("p"),ee.innerHTML=Ne,Me=s(),f(z.$$.fragment),he=s(),f(S.$$.fragment),ue=s(),T=m("div"),f(N.$$.fragment),ke=s(),te=m("p"),te.textContent=Ee,Ce=s(),ne=m("p"),ne.innerHTML=Ye,xe=s(),j=m("div"),f(E.$$.fragment),ze=s(),oe=m("p"),oe.innerHTML=qe,je=s(),U=m("div"),f(Y.$$.fragment),Ue=s(),ae=m("p"),ae.innerHTML=Xe,_e=s(),f(q.$$.fragment),be=s(),w=m("div"),f(X.$$.fragment),Fe=s(),se=m("p"),se.innerHTML=Qe,Ze=s(),re=m("p"),re.innerHTML=Ae,Je=s(),C=m("div"),f(Q.$$.fragment),Ie=s(),ie=m("p"),ie.innerHTML=De,We=s(),f(F.$$.fragment),Be=s(),f(Z.$$.fragment),ve=s(),f(A.$$.fragment),ye=s(),me=m("p"),this.h()},l(e){const t=at("svelte-u9bgzb",document.head);a=d(t,"META",{name:!0,content:!0}),t.forEach(n),P=r(e),p=d(e,"P",{}),W(p).forEach(n),c=r(e),h(g.$$.fragment,e),o=r(e),h(y.$$.fragment,e),ce=r(e),H=d(e,"P",{"data-svelte-h":!0}),$(H)!=="svelte-1p6irtt"&&(H.textContent=Ve),pe=r(e),V=d(e,"P",{"data-svelte-h":!0}),$(V)!=="svelte-1t8caf5"&&(V.innerHTML=Le),ge=r(e),h(L.$$.fragment,e),fe=r(e),G=d(e,"DIV",{class:!0});var M=W(G);h(R.$$.fragment,M),$e=r(M),O=d(M,"P",{"data-svelte-h":!0}),$(O)!=="svelte-1622r4j"&&(O.innerHTML=Re),Pe=r(M),K=d(M,"P",{"data-svelte-h":!0}),$(K)!=="svelte-4qnv67"&&(K.innerHTML=Se),we=r(M),ee=d(M,"P",{"data-svelte-h":!0}),$(ee)!=="svelte-o55m63"&&(ee.innerHTML=Ne),Me=r(M),h(z.$$.fragment,M),M.forEach(n),he=r(e),h(S.$$.fragment,e),ue=r(e),T=d(e,"DIV",{class:!0});var k=W(T);h(N.$$.fragment,k),ke=r(k),te=d(k,"P",{"data-svelte-h":!0}),$(te)!=="svelte-8qftvs"&&(te.textContent=Ee),Ce=r(k),ne=d(k,"P",{"data-svelte-h":!0}),$(ne)!=="svelte-1u63b6m"&&(ne.innerHTML=Ye),xe=r(k),j=d(k,"DIV",{class:!0});var D=W(j);h(E.$$.fragment,D),ze=r(D),oe=d(D,"P",{"data-svelte-h":!0}),$(oe)!=="svelte-4dbgxy"&&(oe.innerHTML=qe),D.forEach(n),je=r(k),U=d(k,"DIV",{class:!0});var Te=W(U);h(Y.$$.fragment,Te),Ue=r(Te),ae=d(Te,"P",{"data-svelte-h":!0}),$(ae)!=="svelte-1ha4zc4"&&(ae.innerHTML=Xe),Te.forEach(n),k.forEach(n),_e=r(e),h(q.$$.fragment,e),be=r(e),w=d(e,"DIV",{class:!0});var J=W(w);h(X.$$.fragment,J),Fe=r(J),se=d(J,"P",{"data-svelte-h":!0}),$(se)!=="svelte-1u2i5mm"&&(se.innerHTML=Qe),Ze=r(J),re=d(J,"P",{"data-svelte-h":!0}),$(re)!=="svelte-hswkmf"&&(re.innerHTML=Ae),Je=r(J),C=d(J,"DIV",{class:!0});var I=W(C);h(Q.$$.fragment,I),Ie=r(I),ie=d(I,"P",{"data-svelte-h":!0}),$(ie)!=="svelte-1q4duri"&&(ie.innerHTML=De),We=r(I),h(F.$$.fragment,I),Be=r(I),h(Z.$$.fragment,I),I.forEach(n),J.forEach(n),ve=r(e),h(A.$$.fragment,e),ye=r(e),me=d(e,"P",{}),W(me).forEach(n),this.h()},h(){B(a,"name","hf:doc:metadata"),B(a,"content",ct),B(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(w,"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,a),l(e,P,t),l(e,p,t),l(e,c,t),u(g,e,t),l(e,o,t),u(y,e,t),l(e,ce,t),l(e,H,t),l(e,pe,t),l(e,V,t),l(e,ge,t),u(L,e,t),l(e,fe,t),l(e,G,t),u(R,G,null),i(G,$e),i(G,O),i(G,Pe),i(G,K),i(G,we),i(G,ee),i(G,Me),u(z,G,null),l(e,he,t),u(S,e,t),l(e,ue,t),l(e,T,t),u(N,T,null),i(T,ke),i(T,te),i(T,Ce),i(T,ne),i(T,xe),i(T,j),u(E,j,null),i(j,ze),i(j,oe),i(T,je),i(T,U),u(Y,U,null),i(U,Ue),i(U,ae),l(e,_e,t),u(q,e,t),l(e,be,t),l(e,w,t),u(X,w,null),i(w,Fe),i(w,se),i(w,Ze),i(w,re),i(w,Je),i(w,C),u(Q,C,null),i(C,Ie),i(C,ie),i(C,We),u(F,C,null),i(C,Be),u(Z,C,null),l(e,ve,t),u(A,e,t),l(e,ye,t),l(e,me,t),Ge=!0},p(e,[t]){const M={};t&2&&(M.$$scope={dirty:t,ctx:e}),z.$set(M);const k={};t&2&&(k.$$scope={dirty:t,ctx:e}),F.$set(k);const D={};t&2&&(D.$$scope={dirty:t,ctx:e}),Z.$set(D)},i(e){Ge||(_(g.$$.fragment,e),_(y.$$.fragment,e),_(L.$$.fragment,e),_(R.$$.fragment,e),_(z.$$.fragment,e),_(S.$$.fragment,e),_(N.$$.fragment,e),_(E.$$.fragment,e),_(Y.$$.fragment,e),_(q.$$.fragment,e),_(X.$$.fragment,e),_(Q.$$.fragment,e),_(F.$$.fragment,e),_(Z.$$.fragment,e),_(A.$$.fragment,e),Ge=!0)},o(e){b(g.$$.fragment,e),b(y.$$.fragment,e),b(L.$$.fragment,e),b(R.$$.fragment,e),b(z.$$.fragment,e),b(S.$$.fragment,e),b(N.$$.fragment,e),b(E.$$.fragment,e),b(Y.$$.fragment,e),b(q.$$.fragment,e),b(X.$$.fragment,e),b(Q.$$.fragment,e),b(F.$$.fragment,e),b(Z.$$.fragment,e),b(A.$$.fragment,e),Ge=!1},d(e){e&&(n(P),n(p),n(c),n(o),n(ce),n(H),n(pe),n(V),n(ge),n(fe),n(G),n(he),n(ue),n(T),n(_e),n(be),n(w),n(ve),n(ye),n(me)),n(a),v(g,e),v(y,e),v(L,e),v(R),v(z),v(S,e),v(N),v(E),v(Y),v(q,e),v(X),v(Q),v(F),v(Z),v(A,e)}}}const ct='{"title":"PaliGemma","local":"paligemma","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"PaliGemmaConfig","local":"transformers.PaliGemmaConfig","sections":[],"depth":2},{"title":"PaliGemmaProcessor","local":"transformers.PaliGemmaProcessor","sections":[],"depth":2},{"title":"PaliGemmaForConditionalGeneration","local":"transformers.PaliGemmaForConditionalGeneration","sections":[],"depth":2}],"depth":1}';function pt(x){return tt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yt extends nt{constructor(a){super(),ot(this,a,pt,dt,et,{})}}export{yt as component};
