Buckets:

HuggingFaceDocBuilder's picture
download
raw
111 kB
import{s as ds,b as ms,o as ps,n as at}from"../chunks/scheduler.31fdf58d.js";import{S as hs,i as gs,e as l,s as o,c as d,h as us,a as i,d as n,b as s,f as v,j as _,g as m,k as M,l as r,m as a,n as p,t as h,o as g,p as u}from"../chunks/index.2f76fdf0.js";import{T as Bn}from"../chunks/Tip.8d349121.js";import{C as fs}from"../chunks/CopyLLMTxtMenu.9cbc081e.js";import{D as U}from"../chunks/Docstring.7c34ae2a.js";import{C as st}from"../chunks/CodeBlock.e52df5d6.js";import{E as wo}from"../chunks/ExampleCodeBlock.de295a13.js";import{H as J,E as _s}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.945f6700.js";function bs($){let c,T='bitsandbytes is being refactored to support multiple backends beyond CUDA. Currently, ROCm (AMD GPU) and Intel CPU implementations are mature, with Intel XPU in progress and Apple Silicon support expected by Q4/Q1. For installation instructions and the latest backend updates, visit <a href="https://huggingface.co/docs/bitsandbytes/main/en/installation#multi-backend" rel="nofollow">this link</a>.',f,y,w='We value your feedback to help identify bugs before the full release! Check out <a href="https://huggingface.co/docs/bitsandbytes/main/en/non_cuda_backends" rel="nofollow">these docs</a> for more details and feedback links.';return{c(){c=l("p"),c.innerHTML=T,f=o(),y=l("p"),y.innerHTML=w},l(b){c=i(b,"P",{"data-svelte-h":!0}),_(c)!=="svelte-nz63kd"&&(c.innerHTML=T),f=s(b),y=i(b,"P",{"data-svelte-h":!0}),_(y)!=="svelte-aze40l"&&(y.innerHTML=w)},m(b,I){a(b,c,I),a(b,f,I),a(b,y,I)},p:at,d(b){b&&(n(c),n(f),n(y))}}}function ys($){let c,T;return c=new st({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENoYW1lbGVvbk1vZGVsJTJDJTIwQ2hhbWVsZW9uQ29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMGNoYW1lbGVvbiUyMGNoYW1lbGVvbi03YiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBDaGFtZWxlb25Db25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjaGFtZWxlb24tN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMENoYW1lbGVvbk1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ChameleonModel, ChameleonConfig
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a chameleon chameleon-7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = ChameleonConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the chameleon-7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ChameleonModel(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`,lang:"python",wrap:!1}}),{c(){d(c.$$.fragment)},l(f){m(c.$$.fragment,f)},m(f,y){p(c,f,y),T=!0},p:at,i(f){T||(h(c.$$.fragment,f),T=!0)},o(f){g(c.$$.fragment,f),T=!1},d(f){u(c,f)}}}function Ts($){let c,T=`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
registered hooks while the latter silently ignores them.`;return{c(){c=l("p"),c.innerHTML=T},l(f){c=i(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-rqqap8"&&(c.innerHTML=T)},m(f,y){a(f,c,y)},p:at,d(f){f&&n(c)}}}function Ms($){let c,T=`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(){c=l("p"),c.innerHTML=T},l(f){c=i(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-fincs2"&&(c.innerHTML=T)},m(f,y){a(f,c,y)},p:at,d(f){f&&n(c)}}}function ws($){let c,T=`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(){c=l("p"),c.innerHTML=T},l(f){c=i(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-fincs2"&&(c.innerHTML=T)},m(f,y){a(f,c,y)},p:at,d(f){f&&n(c)}}}function vs($){let c,T="Example:",f,y,w;return y=new st({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENoYW1lbGVvblByb2Nlc3NvciUyQyUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBaW1wb3J0JTIwaHR0cHglMEFmcm9tJTIwaW8lMjBpbXBvcnQlMjBCeXRlc0lPJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBbW9kZWwlMjAlM0QlMjBDaGFtZWxlb25Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGY2hhbWVsZW9uLTdiJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiklMEFwcm9jZXNzb3IlMjAlM0QlMjBDaGFtZWxlb25Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGY2hhbWVsZW9uLTdiJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkklMjB1c2VkJTIwdG8lMjBrbm93JTIwYSUyMGxvdCUyMGFib3V0JTIwY29uc3RlbGxhdGlvbnMlMjB3aGVuJTIwSSUyMHdhcyUyMHlvdW5nZXIlMkMlMjBidXQlMjBhcyUyMEklMjBncmV3JTIwb2xkZXIlMkMlMjBJJTIwZm9yZ290JTIwbW9zdCUyMG9mJTIwd2hhdCUyMEklMjBrbmV3LiUyMFRoZXNlJTIwYXJlJTIwdGhlJTIwb25seSUyMHR3byUyMGNvbnN0ZWxsYXRpb25zJTIwdGhhdCUyMEklMjByZWFsbHklMjByZW1lbWJlciUyMG5vdy4lM0NpbWFnZSUzRSUzQ2ltYWdlJTNFSSUyMHdvdWxkJTIwbGlrZSUyMGZvciUyMHlvdSUyMHRvJTIwdGVsbCUyMG1lJTIwYWJvdXQlMjAzJTIwbW9yZSUyMGNvbnN0ZWxsYXRpb25zJTIwYW5kJTIwZ2l2ZSUyMG1lJTIwYSUyMGxpdHRsZSUyMGJpdCUyMG9mJTIwaGlzdG9yeSUyMGFib3V0JTIwdGhlJTIwY29uc3RlbGxhdGlvbi4lMjIlMEF1cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRm5pbmVwbGFuZXRzLm9yZyUyRndwLWNvbnRlbnQlMkZ1cGxvYWRzJTJGMjAyMCUyRjEyJTJGdGhlLWJpZy1kaXBwZXItMS5qcGclMjIlMEF3aXRoJTIwaHR0cHguc3RyZWFtKCUyMkdFVCUyMiUyQyUyMHVybCklMjBhcyUyMHJlc3BvbnNlJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2UxJTIwJTNEJTIwSW1hZ2Uub3BlbihCeXRlc0lPKHJlc3BvbnNlLnJlYWQoKSkpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ3d3cua3hhbi5jb20lMkZ3cC1jb250ZW50JTJGdXBsb2FkcyUyRnNpdGVzJTJGNDAlMkYyMDIwJTJGMTAlMkZPUklPTi5qcGclMjIlMEF3aXRoJTIwaHR0cHguc3RyZWFtKCUyMkdFVCUyMiUyQyUyMHVybCklMjBhcyUyMHJlc3BvbnNlJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2UyJTIwJTNEJTIwSW1hZ2Uub3BlbihCeXRlc0lPKHJlc3BvbnNlLnJlYWQoKSkpJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRCU1QmltYWdlMSUyQyUyMGltYWdlMiU1RCUyQyUyMHRleHQlM0Rwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhtb2RlbC5kZXZpY2UlMkMlMjB0b3JjaC5iZmxvYXQxNiklMEElMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDEwMCUyQyUyMGRvX3NhbXBsZSUzREZhbHNlKSUwQXByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ChameleonProcessor, ChameleonForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> httpx
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<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>model = ChameleonForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>, dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = ChameleonProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;I used to know a lot about constellations when I was younger, but as I grew older, I forgot most of what I knew. These are the only two constellations that I really remember now.&lt;image&gt;&lt;image&gt;I would like for you to tell me about 3 more constellations and give me a little bit of history about the constellation.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://nineplanets.org/wp-content/uploads/2020/12/the-big-dipper-1.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> httpx.stream(<span class="hljs-string">&quot;GET&quot;</span>, url) <span class="hljs-keyword">as</span> response:
<span class="hljs-meta">... </span> image1 = Image.<span class="hljs-built_in">open</span>(BytesIO(response.read()))
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://www.kxan.com/wp-content/uploads/sites/40/2020/10/ORION.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> httpx.stream(<span class="hljs-string">&quot;GET&quot;</span>, url) <span class="hljs-keyword">as</span> response:
<span class="hljs-meta">... </span> image2 = Image.<span class="hljs-built_in">open</span>(BytesIO(response.read()))
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=[image1, image2], text=prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(model.device, torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1}}),{c(){c=l("p"),c.textContent=T,f=o(),d(y.$$.fragment)},l(b){c=i(b,"P",{"data-svelte-h":!0}),_(c)!=="svelte-11lpom8"&&(c.textContent=T),f=s(b),m(y.$$.fragment,b)},m(b,I){a(b,c,I),a(b,f,I),p(y,b,I),w=!0},p:at,i(b){w||(h(y.$$.fragment,b),w=!0)},o(b){g(y.$$.fragment,b),w=!1},d(b){b&&(n(c),n(f)),u(y,b)}}}function Cs($){let c,T="Example:",f,y,w;return y=new st({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBDaGFtZWxlb25Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZjaGFtZWxlb24tN2IlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZjaGFtZWxlb24tN2IlMjIpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJ0eXBlJTIyJTNBJTIwJTIyaW1hZ2UlMjIlMkMlMjAlMjJ1cmwlMjIlM0ElMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZwaXBlbGluZS1jYXQtY2hvbmsuanBlZyUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoZXJlJTIwaXMlMjB0aGUlMjBjYXQlMjBzdGFuZGluZyUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSU1RCUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvci5hcHBseV9jaGF0X3RlbXBsYXRlKCUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMEEpJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQ=",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">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, ChameleonForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ChameleonForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [
<span class="hljs-meta">... </span> {
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>},
<span class="hljs-meta">... </span> {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Where is the cat standing?&quot;</span>},
<span class="hljs-meta">... </span> ]
<span class="hljs-meta">... </span> },
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor.apply_chat_template(
<span class="hljs-meta">... </span> messages,
<span class="hljs-meta">... </span> tokenize=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span> return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span> add_generation_prompt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </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)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1}}),{c(){c=l("p"),c.textContent=T,f=o(),d(y.$$.fragment)},l(b){c=i(b,"P",{"data-svelte-h":!0}),_(c)!=="svelte-11lpom8"&&(c.textContent=T),f=s(b),m(y.$$.fragment,b)},m(b,I){a(b,c,I),a(b,f,I),p(y,b,I),w=!0},p:at,i(b){w||(h(y.$$.fragment,b),w=!0)},o(b){g(y.$$.fragment,b),w=!1},d(b){b&&(n(c),n(f)),u(y,b)}}}function ks($){let c,T,f,y,w,b="<em>This model was released on 2024-05-16 and added to Hugging Face Transformers on 2024-07-17.</em>",I,ie,Pt,ce,Rt,S,vo='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/> <img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',Ht,de,qt,me,Co='The Chameleon model was proposed in <a href="https://huggingface.co/papers/2405.09818" rel="nofollow">Chameleon: Mixed-Modal Early-Fusion Foundation Models</a> by META AI Chameleon Team. Chameleon is a Vision-Language Model that use vector quantization to tokenize images which enables the model to generate multimodal output. The model takes images and texts as input, including an interleaved format, and generates textual response. Image generation module is not released yet.',Et,pe,ko="The abstract from the paper is the following:",Xt,he,Jo=`<em>We present Chameleon, a family of early-fusion token-based mixed-modal models capable of understanding and generating images and text in any arbitrary sequence. We outline a stable training
approach from inception, an alignment recipe, and an architectural parameterization tailored for the
early-fusion, token-based, mixed-modal setting. The models are evaluated on a comprehensive range
of tasks, including visual question answering, image captioning, text generation, image generation, and
long-form mixed modal generation. Chameleon demonstrates broad and general capabilities, including
state-of-the-art performance in image captioning tasks, outperforms Llama-2 in text-only tasks while
being competitive with models such as Mixtral 8x7B and Gemini-Pro, and performs non-trivial image
generation, all in a single model. It also matches or exceeds the performance of much larger models,
including Gemini Pro and GPT-4V, according to human judgments on a new long-form mixed-modal
generation evaluation, where either the prompt or outputs contain mixed sequences of both images and
text. Chameleon marks a significant step forward in unified modeling of full multimodal documents</em>`,Yt,D,$o,Qt,ge,Io='Chameleon incorporates a vector quantizer module to transform images into discrete tokens. That also enables image generation using an auto-regressive transformer. Taken from the <a href="https://huggingface.co/papers/2405.09818">original paper.</a>',Lt,ue,Uo=`This model was contributed by <a href="https://huggingface.co/joaogante" rel="nofollow">joaogante</a> and <a href="https://huggingface.co/RaushanTurganbay" rel="nofollow">RaushanTurganbay</a>.
The original code can be found <a href="https://github.com/facebookresearch/chameleon" rel="nofollow">here</a>.`,At,fe,St,_e,jo="<li><p>We advise users to use <code>padding_side=&quot;left&quot;</code> when computing batched generation as it leads to more accurate results. Simply make sure to set <code>processor.tokenizer.padding_side = &quot;left&quot;</code> before generating.</p></li> <li><p>Note that Chameleon was tuned for safety alignment. If the model is refusing to answer, consider asking a more concrete question, instead of an open question.</p></li> <li><p>Chameleon generates in chat format which means that the generated text will always be the “assistant’s turn”. You can enable a text completion generation by passing <code>return_for_text_completion=True</code> when calling the processor.</p></li>",Dt,K,xo="<p>Chameleon implementation in Transformers uses a special image token to indicate where to merge image embeddings. For special image token we didn’t add a new one but used one of the reserved tokens: <code>&lt;reserved08707&gt;</code>. You have to add <code>&lt;image&gt;</code> to your prompt in the place where the image should be embedded for correct generation.</p>",Kt,be,Ot,ye,en,Te,Wo=`Chameleon is a gated model so make sure to have access and login to Hugging Face Hub using a token.
Here’s how to load the model and perform inference in half-precision (<code>torch.bfloat16</code>):`,tn,Me,nn,we,on,ve,Zo="Chameleon can perform inference with multiple images as input, where images either belong to the same prompt or different prompts (in batched inference). Here is how you can do it:",sn,Ce,an,ke,rn,Je,ln,$e,Bo="The model can be loaded in 8 or 4 bits, greatly reducing the memory requirements while maintaining the performance of the original model. First make sure to install bitsandbytes, <code>pip install bitsandbytes</code> and to have access to a GPU/accelerator that is supported by the library.",cn,O,dn,Ie,zo="Simply change the snippet above with:",mn,Ue,pn,je,hn,xe,Go='The models supports both, Flash-Attention 2 and PyTorch’s <a href="https://pytorch.org/docs/master/generated/torch.nn.functional.scaled_dot_product_attention.html" rel="nofollow"><code>torch.nn.functional.scaled_dot_product_attention</code></a> which can be enables for optimization. SDPA is the default options when you load the model, If you want to switch for Flash Attention 2, first make sure to install flash-attn. Refer to the <a href="https://github.com/Dao-AILab/flash-attention" rel="nofollow">original repository</a> regarding that package installation. Simply change the snippet above with:',gn,We,un,Ze,fn,W,Be,zn,rt,Fo=`This is the configuration class to store the configuration of a ChameleonModel. It is used to instantiate a Chameleon
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 <a href="https://huggingface.co/facebook/chameleon-7b" rel="nofollow">facebook/chameleon-7b</a>`,Gn,lt,Vo=`Configuration objects inherit from <a href="/docs/transformers/pr_36895/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/pr_36895/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.`,Fn,ee,_n,ze,bn,V,Ge,Vn,it,No=`This is the configuration class to store the configuration of a ChameleonModel. It is used to instantiate a Chameleon
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 <a href="https://huggingface.co/facebook/chameleon-7b" rel="nofollow">facebook/chameleon-7b</a>`,Nn,ct,Po=`Configuration objects inherit from <a href="/docs/transformers/pr_36895/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/pr_36895/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.`,yn,Fe,Tn,Z,Ve,Pn,dt,Ro="Constructs a ChameleonProcessor which wraps a image processor and a tokenizer into a single processor.",Rn,mt,Ho=`<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonProcessor">ChameleonProcessor</a> offers all the functionalities of <a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a> and <a href="/docs/transformers/pr_36895/en/main_classes/tokenizer#transformers.TokenizersBackend">TokenizersBackend</a>. See the
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">~ChameleonImageProcessor</a> and <a href="/docs/transformers/pr_36895/en/main_classes/tokenizer#transformers.TokenizersBackend">~TokenizersBackend</a> for more information.`,Hn,pt,Ne,Mn,Pe,wn,N,Re,qn,ht,qo="Constructs a ChameleonImageProcessor image processor.",En,gt,He,vn,qe,Cn,P,Ee,Xn,ut,Eo="Constructs a ChameleonImageProcessor image processor.",Yn,ft,Xe,kn,Ye,Jn,j,Qe,Qn,_t,Xo=`The VQ-VAE model used in Chameleon for encoding/decoding images into discrete tokens.
This model follows the “Make-a-scene: Scene-based text-to-image generation with human priors” paper from
<a href="https://huggingface.co/papers/2203.13131" rel="nofollow">Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv
Taigman</a>.`,Ln,bt,Yo=`This model inherits from <a href="/docs/transformers/pr_36895/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.)`,An,yt,Qo=`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.`,Sn,B,Le,Dn,Tt,Lo="Define the computation performed at every call.",Kn,Mt,Ao="Should be overridden by all subclasses.",On,te,$n,Ae,In,C,Se,eo,wt,So="The bare Chameleon Model outputting raw hidden-states without any specific head on top.",to,vt,Do=`This model inherits from <a href="/docs/transformers/pr_36895/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.)`,no,Ct,Ko=`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.`,oo,z,De,so,kt,Oo='The <a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonModel">ChameleonModel</a> forward method, overrides the <code>__call__</code> special method.',ao,ne,ro,Jt,es=`<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> <p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p></li> <li><p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</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> <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>`,lo,q,Ke,io,$t,ts="Tokenizes images into discrete tokens with VQGAN module and embeds them with text embeddings layer.",co,It,ns=`<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>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</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>`,Un,Oe,jn,k,et,mo,Ut,os="Chameleon Model with a head on top used for outputting logits for next token prediction.",po,jt,ss=`This model inherits from <a href="/docs/transformers/pr_36895/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.)`,ho,xt,as=`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.`,go,x,tt,uo,Wt,rs='The <a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonForConditionalGeneration">ChameleonForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',fo,oe,_o,Zt,ls=`<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>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</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>`,bo,se,yo,E,nt,To,Bt,is=`<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>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</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>`,Mo,ae,xn,ot,Wn,Ft,Zn;return ie=new fs({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),ce=new J({props:{title:"Chameleon",local:"chameleon",headingTag:"h1"}}),de=new J({props:{title:"Overview",local:"overview",headingTag:"h2"}}),fe=new J({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),be=new J({props:{title:"Usage example",local:"usage-example",headingTag:"h2"}}),ye=new J({props:{title:"Single image inference",local:"single-image-inference",headingTag:"h3"}}),Me=new st({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ2hhbWVsZW9uRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTIwQ2hhbWVsZW9uUHJvY2Vzc29yJTBBJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwQ2hhbWVsZW9uUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmNoYW1lbGVvbi03YiUyMiklMEFtb2RlbCUyMCUzRCUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZjaGFtZWxlb24tN2IlMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiklMEElMEElMjMlMjBwcmVwYXJlJTIwaW1hZ2UlMjBhbmQlMjB0ZXh0JTIwcHJvbXB0JTBBdXJsJTIwJTNEJTIwJ2h0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGcnJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBcHJvbXB0JTIwJTNEJTIwJTIyV2hhdCUyMGRvJTIweW91JTIwc2VlJTIwaW4lMjB0aGlzJTIwaW1hZ2UlM0YlM0NpbWFnZSUzRSUyMiUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHRleHQlM0Rwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhtb2RlbC5kZXZpY2UpJTBBJTBBJTIzJTIwYXV0b3JlZ3Jlc3NpdmVseSUyMGNvbXBsZXRlJTIwcHJvbXB0JTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDUwKSUwQXByaW50KHByb2Nlc3Nvci5kZWNvZGUob3V0cHV0JTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ChameleonForConditionalGeneration, ChameleonProcessor
processor = ChameleonProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>)
model = ChameleonForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
<span class="hljs-comment"># prepare image and text prompt</span>
url = <span class="hljs-string">&#x27;http://images.cocodataset.org/val2017/000000039769.jpg&#x27;</span>
image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
prompt = <span class="hljs-string">&quot;What do you see in this image?&lt;image&gt;&quot;</span>
inputs = processor(images=image, text=prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(model.device)
<span class="hljs-comment"># autoregressively complete prompt</span>
output = model.generate(**inputs, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-built_in">print</span>(processor.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1}}),we=new J({props:{title:"Multi image inference",local:"multi-image-inference",headingTag:"h3"}}),Ce=new st({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ2hhbWVsZW9uRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTIwQ2hhbWVsZW9uUHJvY2Vzc29yJTBBJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwQ2hhbWVsZW9uUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmNoYW1lbGVvbi03YiUyMiklMEElMEFtb2RlbCUyMCUzRCUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZjaGFtZWxlb24tN2IlMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiklMEElMEElMjMlMjBHZXQlMjB0aHJlZSUyMGRpZmZlcmVudCUyMGltYWdlcyUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGd3d3LmlsYW5rZWxtYW4ub3JnJTJGc3RvcHNpZ25zJTJGYXVzdHJhbGlhLmpwZyUyMiUwQWltYWdlX3N0b3AlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlX2NhdHMlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRm1pY3Jvc29mdCUyRmtvc21vcy0yLXBhdGNoMTQtMjI0JTJGcmVzb2x2ZSUyRm1haW4lMkZzbm93bWFuLmpwZyUyMiUwQWltYWdlX3Nub3dtYW4lMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBJTIzJTIwUHJlcGFyZSUyMGElMjBiYXRjaGVkJTIwcHJvbXB0JTJDJTIwd2hlcmUlMjB0aGUlMjBmaXJzdCUyMG9uZSUyMGlzJTIwYSUyMG11bHRpLWltYWdlJTIwcHJvbXB0JTIwYW5kJTIwdGhlJTIwc2Vjb25kJTIwaXMlMjBub3QlMEFwcm9tcHRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyV2hhdCUyMGRvJTIwdGhlc2UlMjBpbWFnZXMlMjBoYXZlJTIwaW4lMjBjb21tb24lM0YlM0NpbWFnZSUzRSUzQ2ltYWdlJTNFJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyJTNDaW1hZ2UlM0VXaGF0JTIwaXMlMjBzaG93biUyMGluJTIwdGhpcyUyMGltYWdlJTNGJTIyJTBBJTVEJTBBJTBBJTIzJTIwV2UlMjBjYW4lMjBzaW1wbHklMjBmZWVkJTIwaW1hZ2VzJTIwaW4lMjB0aGUlMjBvcmRlciUyMHRoZXklMjBoYXZlJTIwdG8lMjBiZSUyMHVzZWQlMjBpbiUyMHRoZSUyMHRleHQlMjBwcm9tcHQlMEElMjMlMjBFYWNoJTIwJTIyJTNDaW1hZ2UlM0UlMjIlMjB0b2tlbiUyMHVzZXMlMjBvbmUlMjBpbWFnZSUyMGxlYXZpbmclMjB0aGUlMjBuZXh0JTIwZm9yJTIwdGhlJTIwc3Vic2VxdWVudCUyMCUyMiUzQ2ltYWdlJTNFJTIyJTIwdG9rZW5zJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRCU1QmltYWdlX3N0b3AlMkMlMjBpbWFnZV9jYXRzJTJDJTIwaW1hZ2Vfc25vd21hbiU1RCUyQyUyMHRleHQlM0Rwcm9tcHRzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhkZXZpY2UlM0Rtb2RlbC5kZXZpY2UpJTBBJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENTApJTBBcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZV9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSk=",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ChameleonForConditionalGeneration, ChameleonProcessor
processor = ChameleonProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>)
model = ChameleonForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
<span class="hljs-comment"># Get three different images</span>
url = <span class="hljs-string">&quot;https://www.ilankelman.org/stopsigns/australia.jpg&quot;</span>
image_stop = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
image_cats = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
url = <span class="hljs-string">&quot;https://huggingface.co/microsoft/kosmos-2-patch14-224/resolve/main/snowman.jpg&quot;</span>
image_snowman = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-comment"># Prepare a batched prompt, where the first one is a multi-image prompt and the second is not</span>
prompts = [
<span class="hljs-string">&quot;What do these images have in common?&lt;image&gt;&lt;image&gt;&quot;</span>,
<span class="hljs-string">&quot;&lt;image&gt;What is shown in this image?&quot;</span>
]
<span class="hljs-comment"># We can simply feed images in the order they have to be used in the text prompt</span>
<span class="hljs-comment"># Each &quot;&lt;image&gt;&quot; token uses one image leaving the next for the subsequent &quot;&lt;image&gt;&quot; tokens</span>
inputs = processor(images=[image_stop, image_cats, image_snowman], text=prompts, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device=model.device)
<span class="hljs-comment"># Generate</span>
generate_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">50</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>)`,lang:"python",wrap:!1}}),ke=new J({props:{title:"Model optimization",local:"model-optimization",headingTag:"h2"}}),Je=new J({props:{title:"Quantization using Bitsandbytes",local:"quantization-using-bitsandbytes",headingTag:"h3"}}),O=new Bn({props:{$$slots:{default:[bs]},$$scope:{ctx:$}}}),Ue=new st({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJpdHNBbmRCeXRlc0NvbmZpZyUyQyUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQSUwQSUyMyUyMHNwZWNpZnklMjBob3clMjB0byUyMHF1YW50aXplJTIwdGhlJTIwbW9kZWwlMEFxdWFudGl6YXRpb25fY29uZmlnJTIwJTNEJTIwQml0c0FuZEJ5dGVzQ29uZmlnKCUwQSUyMCUyMCUyMCUyMGxvYWRfaW5fNGJpdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBibmJfNGJpdF9xdWFudF90eXBlJTNEJTIybmY0JTIyJTJDJTBBJTIwJTIwJTIwJTIwYm5iXzRiaXRfY29tcHV0ZV9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTBBKSUwQSUwQW1vZGVsJTIwJTNEJTIwQ2hhbWVsZW9uRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmNoYW1lbGVvbi03YiUyMiUyQyUyMHF1YW50aXphdGlvbl9jb25maWclM0RxdWFudGl6YXRpb25fY29uZmlnJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BitsAndBytesConfig, ChameleonForConditionalGeneration
<span class="hljs-comment"># specify how to quantize the model</span>
quantization_config = BitsAndBytesConfig(
load_in_4bit=<span class="hljs-literal">True</span>,
bnb_4bit_quant_type=<span class="hljs-string">&quot;nf4&quot;</span>,
bnb_4bit_compute_dtype=torch.bfloat16,
)
model = ChameleonForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>, quantization_config=quantization_config, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`,lang:"python",wrap:!1}}),je=new J({props:{title:"Use Flash-Attention 2 and SDPA to further speed-up generation",local:"use-flash-attention-2-and-sdpa-to-further-speed-up-generation",headingTag:"h3"}}),We=new st({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyZmFjZWJvb2slMkZjaGFtZWxlb24tN2IlMjIlMEFtb2RlbCUyMCUzRCUyMENoYW1lbGVvbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlMkMlMEElMjAlMjAlMjAlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyZmxhc2hfYXR0ZW50aW9uXzIlMjIlMEEpLnRvKDAlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ChameleonForConditionalGeneration
model_id = <span class="hljs-string">&quot;facebook/chameleon-7b&quot;</span>
model = ChameleonForConditionalGeneration.from_pretrained(
model_id,
attn_implementation=<span class="hljs-string">&quot;flash_attention_2&quot;</span>
).to(<span class="hljs-number">0</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`,lang:"python",wrap:!1}}),Ze=new J({props:{title:"ChameleonConfig",local:"transformers.ChameleonConfig",headingTag:"h2"}}),Be=new U({props:{name:"class transformers.ChameleonConfig",anchor:"transformers.ChameleonConfig",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None"},{name:"vocab_size",val:": int = 65536"},{name:"hidden_size",val:": int = 4096"},{name:"intermediate_size",val:": int = 11008"},{name:"num_hidden_layers",val:": int = 32"},{name:"num_attention_heads",val:": int = 32"},{name:"num_key_value_heads",val:": int | None = 32"},{name:"hidden_act",val:": str = 'silu'"},{name:"max_position_embeddings",val:": int = 4096"},{name:"initializer_range",val:": float = 0.02"},{name:"rms_norm_eps",val:": float = 1e-05"},{name:"use_cache",val:": bool = True"},{name:"pad_token_id",val:": int | None = None"},{name:"bos_token_id",val:": int | None = 1"},{name:"eos_token_id",val:": int | list[int] | None = 2"},{name:"tie_word_embeddings",val:": bool = False"},{name:"rope_parameters",val:": transformers.modeling_rope_utils.RopeParameters | dict | None = None"},{name:"attention_bias",val:": bool | None = False"},{name:"attention_dropout",val:": float | int | None = 0.0"},{name:"model_parallel_size",val:": int | None = 1"},{name:"swin_norm",val:": bool | None = False"},{name:"vq_config",val:": dict | transformers.configuration_utils.PreTrainedConfig | None = None"},{name:"vocabulary_map",val:": dict | None = None"},{name:"mlp_bias",val:": bool = False"}],parametersDescription:[{anchor:"transformers.ChameleonConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>65536</code>) &#x2014;
Vocabulary size of the model. Defines the number of different tokens that can be represented by the <code>input_ids</code>.`,name:"vocab_size"},{anchor:"transformers.ChameleonConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4096</code>) &#x2014;
Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.ChameleonConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>11008</code>) &#x2014;
Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.ChameleonConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) &#x2014;
Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.ChameleonConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.ChameleonConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) &#x2014;
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
<code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if
<code>num_key_value_heads=1</code> the model will use Multi Query Attention (MQA) otherwise GQA is used. When
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
by meanpooling all the original heads within that group. For more details, check out <a href="https://huggingface.co/papers/2305.13245" rel="nofollow">this
paper</a>. If it is not specified, will default to
<code>num_attention_heads</code>.`,name:"num_key_value_heads"},{anchor:"transformers.ChameleonConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>silu</code>) &#x2014;
The non-linear activation function (function or string) in the decoder. For example, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;silu&quot;</code>, etc.`,name:"hidden_act"},{anchor:"transformers.ChameleonConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4096</code>) &#x2014;
The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.ChameleonConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.ChameleonConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-05</code>) &#x2014;
The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.ChameleonConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code> or when the model is a decoder-only generative model.`,name:"use_cache"},{anchor:"transformers.ChameleonConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.ChameleonConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.ChameleonConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>, defaults to <code>2</code>) &#x2014;
Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.ChameleonConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to tie weight embeddings according to model&#x2019;s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"},{anchor:"transformers.ChameleonConfig.rope_parameters",description:`<strong>rope_parameters</strong> (<code>Union[~modeling_rope_utils.RopeParameters, dict]</code>, <em>optional</em>) &#x2014;
Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
a value for <code>rope_theta</code> and optionally parameters used for scaling in case you want to use RoPE
with longer <code>max_position_embeddings</code>.`,name:"rope_parameters"},{anchor:"transformers.ChameleonConfig.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use a bias in the query, key, value and output projection layers during self-attention.`,name:"attention_bias"},{anchor:"transformers.ChameleonConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.ChameleonConfig.model_parallel_size",description:`<strong>model_parallel_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of shards used when training the model. This will be used in qk layernorm because the original Chameleon inference
doesn&#x2019;t do reduction in those layers and each rank has its own biases.`,name:"model_parallel_size"},{anchor:"transformers.ChameleonConfig.swin_norm",description:`<strong>swin_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use Swin Transformer normalization.`,name:"swin_norm"},{anchor:"transformers.ChameleonConfig.vq_config",description:`<strong>vq_config</strong> (<code>Union[dict, ~configuration_utils.PreTrainedConfig]</code>, <em>optional</em>) &#x2014;
Configuration dict of the vector quantize module.`,name:"vq_config"},{anchor:"transformers.ChameleonConfig.vocabulary_map",description:`<strong>vocabulary_map</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A dictionary containing the vocabulary map from the tokenizer. Used to obtain tokens from the image inputs.`,name:"vocabulary_map"},{anchor:"transformers.ChameleonConfig.mlp_bias",description:`<strong>mlp_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.`,name:"mlp_bias"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/configuration_chameleon.py#L66"}}),ee=new wo({props:{anchor:"transformers.ChameleonConfig.example",$$slots:{default:[ys]},$$scope:{ctx:$}}}),ze=new J({props:{title:"ChameleonVQVAEConfig",local:"transformers.ChameleonVQVAEConfig",headingTag:"h2"}}),Ge=new U({props:{name:"class transformers.ChameleonVQVAEConfig",anchor:"transformers.ChameleonVQVAEConfig",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None"},{name:"embed_dim",val:": int = 256"},{name:"num_embeddings",val:": int = 8192"},{name:"double_latent",val:": bool = False"},{name:"latent_channels",val:": int = 256"},{name:"resolution",val:": int = 512"},{name:"in_channels",val:": int = 3"},{name:"base_channels",val:": int = 128"},{name:"channel_multiplier",val:": list[int] | tuple[int, ...] = (1, 1, 2, 2, 4)"},{name:"num_res_blocks",val:": int = 2"},{name:"attn_resolutions",val:": list[int] | None = None"},{name:"dropout",val:": float | int = 0.0"},{name:"attn_type",val:": str = 'vanilla'"}],parametersDescription:[{anchor:"transformers.ChameleonVQVAEConfig.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) &#x2014;
Dimensionality of the embeddings and hidden states.`,name:"embed_dim"},{anchor:"transformers.ChameleonVQVAEConfig.num_embeddings",description:`<strong>num_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8192</code>) &#x2014;
Number of codebook embeddings.`,name:"num_embeddings"},{anchor:"transformers.ChameleonVQVAEConfig.double_latent",description:`<strong>double_latent</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use double z channels.`,name:"double_latent"},{anchor:"transformers.ChameleonVQVAEConfig.latent_channels",description:`<strong>latent_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) &#x2014;
Number of channels for the latent space.`,name:"latent_channels"},{anchor:"transformers.ChameleonVQVAEConfig.resolution",description:`<strong>resolution</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
Resolution of the input images.`,name:"resolution"},{anchor:"transformers.ChameleonVQVAEConfig.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>3</code>) &#x2014;
The number of input channels.`,name:"in_channels"},{anchor:"transformers.ChameleonVQVAEConfig.base_channels",description:`<strong>base_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Base channel count.`,name:"base_channels"},{anchor:"transformers.ChameleonVQVAEConfig.channel_multiplier",description:`<strong>channel_multiplier</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>[1, 1, 2, 2, 4]</code>) &#x2014;
Channel multipliers for each resolution.`,name:"channel_multiplier"},{anchor:"transformers.ChameleonVQVAEConfig.num_res_blocks",description:`<strong>num_res_blocks</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of residual blocks.`,name:"num_res_blocks"},{anchor:"transformers.ChameleonVQVAEConfig.attn_resolutions",description:`<strong>attn_resolutions</strong> (<code>list[int]</code>, <em>optional</em>) &#x2014;
Resolutions to apply attention.`,name:"attn_resolutions"},{anchor:"transformers.ChameleonVQVAEConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Dropout rate.`,name:"dropout"},{anchor:"transformers.ChameleonVQVAEConfig.attn_type",description:`<strong>attn_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;vanilla&quot;</code>) &#x2014;
Attention type used in VQ-GAN encoder. Can be &#x201C;vanilla&#x201D; or None`,name:"attn_type"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/configuration_chameleon.py#L28"}}),Fe=new J({props:{title:"ChameleonProcessor",local:"transformers.ChameleonProcessor",headingTag:"h2"}}),Ve=new U({props:{name:"class transformers.ChameleonProcessor",anchor:"transformers.ChameleonProcessor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:""},{name:"image_seq_length",val:": int = 1024"},{name:"image_token",val:": str = '<image>'"}],parametersDescription:[{anchor:"transformers.ChameleonProcessor.image_processor",description:`<strong>image_processor</strong> (<code>ChameleonImageProcessor</code>) &#x2014;
The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.ChameleonProcessor.tokenizer",description:`<strong>tokenizer</strong> (<code>TokenizersBackend</code>) &#x2014;
The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.ChameleonProcessor.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Sequence length of one image embedding.`,name:"image_seq_length"},{anchor:"transformers.ChameleonProcessor.image_token",description:`<strong>image_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;image&gt;&quot;</code>) &#x2014;
The special token used to indicate image in the text.`,name:"image_token"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/processing_chameleon.py#L57"}}),Ne=new U({props:{name:"__call__",anchor:"transformers.ChameleonProcessor.__call__",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor'], NoneType] = None"},{name:"text",val:": str | list[str] | list[list[str]] | None = None"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.models.chameleon.processing_chameleon.ChameleonProcessorKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonProcessor.__call__.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>, <em>optional</em>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.ChameleonProcessor.__call__.text",description:`<strong>text</strong> (<code>Union[str, list[str], list[list[str]]]</code>, <em>optional</em>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
(pretokenized string). If you pass a pretokenized input, set <code>is_split_into_words=True</code> to avoid ambiguity with batched inputs.`,name:"text"},{anchor:"transformers.ChameleonProcessor.__call__.return_for_text_completion",description:`<strong>return_for_text_completion</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the processed text is intended for text completion tasks. When <code>True</code>, the processor does not
append the separator token (<code>sep_token</code>) to the end of the prompt, which is typically used for chat
mode. When <code>False</code>, the separator token is appended for proper chat formatting.`,name:"return_for_text_completion"},{anchor:"transformers.ChameleonProcessor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_36895/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors of a particular framework. Acceptable values are:</p>
<ul>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return NumPy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.ChameleonProcessor.__call__.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_36895/en/main_classes/processors#transformers.ProcessingKwargs">ProcessingKwargs</a>, <em>optional</em>) &#x2014;
Additional processing options for each modality (text, images, videos, audio). Model-specific parameters
are listed above; see the TypedDict class for the complete list of supported arguments.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/processing_chameleon.py#L79",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <a
href="/docs/transformers/pr_36895/en/main_classes/feature_extractor#transformers.BatchFeature"
>BatchFeature</a> with the following fields:</p>
<ul>
<li><strong>input_ids</strong> — List of token ids to be fed to a model. Returned when <code>text</code> is not <code>None</code>.</li>
<li><strong>attention_mask</strong> — List of indices specifying which tokens should be attended to by the model (when
<code>return_attention_mask=True</code> or if <em>“attention_mask”</em> is in <code>self.model_input_names</code> and if <code>text</code> is not
<code>None</code>).</li>
<li><strong>pixel_values</strong> — Pixel values to be fed to a model. Returned when <code>images</code> is not <code>None</code>.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/transformers/pr_36895/en/main_classes/feature_extractor#transformers.BatchFeature"
>BatchFeature</a></p>
`}}),Pe=new J({props:{title:"ChameleonImageProcessor",local:"transformers.ChameleonImageProcessor",headingTag:"h2"}}),Re=new U({props:{name:"class transformers.ChameleonImageProcessor",anchor:"transformers.ChameleonImageProcessor",parameters:[{name:"**kwargs",val:": typing_extensions.Unpack[transformers.processing_utils.ImagesKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonImageProcessor.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_36895/en/main_classes/processors#transformers.ImagesKwargs">ImagesKwargs</a>, <em>optional</em>) &#x2014;
Additional image preprocessing options. Model-specific kwargs are listed above; see the TypedDict class
for the complete list of supported arguments.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/image_processing_chameleon.py#L35"}}),He=new U({props:{name:"preprocess",anchor:"transformers.ChameleonImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"*args",val:""},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.processing_utils.ImagesKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.ChameleonImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_36895/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
Returns stacked tensors if set to <code>&apos;pt&apos;</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.ChameleonImageProcessor.preprocess.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_36895/en/main_classes/processors#transformers.ImagesKwargs">ImagesKwargs</a>, <em>optional</em>) &#x2014;
Additional image preprocessing options. Model-specific kwargs are listed above; see the TypedDict class
for the complete list of supported arguments.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/image_processing_utils.py#L382",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<ul>
<li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li>
<li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at
initialization.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~image_processing_base.BatchFeature</code></p>
`}}),qe=new J({props:{title:"ChameleonImageProcessorPil",local:"transformers.ChameleonImageProcessorPil",headingTag:"h2"}}),Ee=new U({props:{name:"class transformers.ChameleonImageProcessorPil",anchor:"transformers.ChameleonImageProcessorPil",parameters:[{name:"**kwargs",val:": typing_extensions.Unpack[transformers.processing_utils.ImagesKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonImageProcessorPil.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_36895/en/main_classes/processors#transformers.ImagesKwargs">ImagesKwargs</a>, <em>optional</em>) &#x2014;
Additional image preprocessing options. Model-specific kwargs are listed above; see the TypedDict class
for the complete list of supported arguments.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/image_processing_pil_chameleon.py#L29"}}),Xe=new U({props:{name:"preprocess",anchor:"transformers.ChameleonImageProcessorPil.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"*args",val:""},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.processing_utils.ImagesKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonImageProcessorPil.preprocess.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.ChameleonImageProcessorPil.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_36895/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
Returns stacked tensors if set to <code>&apos;pt&apos;</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.ChameleonImageProcessorPil.preprocess.*kwargs",description:`*<strong>*kwargs</strong> (<a href="/docs/transformers/pr_36895/en/main_classes/processors#transformers.ImagesKwargs">ImagesKwargs</a>, <em>optional</em>) &#x2014;
Additional image preprocessing options. Model-specific kwargs are listed above; see the TypedDict class
for the complete list of supported arguments.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/image_processing_utils.py#L382",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<ul>
<li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li>
<li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at
initialization.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~image_processing_base.BatchFeature</code></p>
`}}),Ye=new J({props:{title:"ChameleonVQVAE",local:"transformers.ChameleonVQVAE",headingTag:"h2"}}),Qe=new U({props:{name:"class transformers.ChameleonVQVAE",anchor:"transformers.ChameleonVQVAE",parameters:[{name:"config",val:": ChameleonVQVAEConfig"}],parametersDescription:[{anchor:"transformers.ChameleonVQVAE.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonVQVAEConfig">ChameleonVQVAEConfig</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_36895/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_36895/src/transformers/models/chameleon/modeling_chameleon.py#L805"}}),Le=new U({props:{name:"_forward_unimplemented",anchor:"transformers.ChameleonVQVAE.forward",parameters:[{name:"*input",val:": typing.Any"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/torch/nn/modules/module.py#L392"}}),te=new Bn({props:{$$slots:{default:[Ts]},$$scope:{ctx:$}}}),Ae=new J({props:{title:"ChameleonModel",local:"transformers.ChameleonModel",headingTag:"h2"}}),Se=new U({props:{name:"class transformers.ChameleonModel",anchor:"transformers.ChameleonModel",parameters:[{name:"config",val:": ChameleonConfig"}],parametersDescription:[{anchor:"transformers.ChameleonModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonConfig">ChameleonConfig</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_36895/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_36895/src/transformers/models/chameleon/modeling_chameleon.py#L844"}}),De=new U({props:{name:"forward",anchor:"transformers.ChameleonModel.forward",parameters:[{name:"input_ids",val:": torch.LongTensor | None = None"},{name:"pixel_values",val:": torch.FloatTensor | None = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"position_ids",val:": torch.LongTensor | None = None"},{name:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": torch.FloatTensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.modeling_flash_attention_utils.FlashAttentionKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_36895/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36895/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_36895/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.ChameleonModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>, <em>optional</em>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a>. See <code>ChameleonImageProcessor.__call__()</code> for details (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonProcessor">ChameleonProcessor</a> uses
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.ChameleonModel.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.ChameleonModel.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>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.ChameleonModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) &#x2014;
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code>
returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p>
<p>Only <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.
If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p>
<p>The model will output the same cache format that is fed as input.</p>
<p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don&#x2019;t
have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code>
of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.ChameleonModel.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.ChameleonModel.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"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/modeling_chameleon.py#L921",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast"
>BaseModelOutputWithPast</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonConfig"
>ChameleonConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast"
>BaseModelOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ne=new Bn({props:{$$slots:{default:[Ms]},$$scope:{ctx:$}}}),Ke=new U({props:{name:"get_image_features",anchor:"transformers.ChameleonModel.get_image_features",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonModel.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input images.`,name:"pixel_values"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/modeling_chameleon.py#L880",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>BaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonConfig"
>ChameleonConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Oe=new J({props:{title:"ChameleonForConditionalGeneration",local:"transformers.ChameleonForConditionalGeneration",headingTag:"h2"}}),et=new U({props:{name:"class transformers.ChameleonForConditionalGeneration",anchor:"transformers.ChameleonForConditionalGeneration",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.ChameleonForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonForConditionalGeneration">ChameleonForConditionalGeneration</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_36895/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_36895/src/transformers/models/chameleon/modeling_chameleon.py#L996"}}),tt=new U({props:{name:"forward",anchor:"transformers.ChameleonForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": torch.LongTensor | None = None"},{name:"pixel_values",val:": torch.FloatTensor | None = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"position_ids",val:": torch.LongTensor | None = None"},{name:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": torch.FloatTensor | None = None"},{name:"labels",val:": torch.LongTensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"logits_to_keep",val:": int | torch.Tensor = 0"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_36895/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36895/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_36895/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.ChameleonForConditionalGeneration.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>, <em>optional</em>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a>. See <code>ChameleonImageProcessor.__call__()</code> for details (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonProcessor">ChameleonProcessor</a> uses
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.ChameleonForConditionalGeneration.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.ChameleonForConditionalGeneration.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>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.ChameleonForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) &#x2014;
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code>
returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p>
<p>Only <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.
If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_36895/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p>
<p>The model will output the same cache format that is fed as input.</p>
<p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don&#x2019;t
have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code>
of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.ChameleonForConditionalGeneration.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.ChameleonForConditionalGeneration.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 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:"labels"},{anchor:"transformers.ChameleonForConditionalGeneration.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.ChameleonForConditionalGeneration.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>Union[int, torch.Tensor]</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
If an <code>int</code>, compute logits for the last <code>logits_to_keep</code> tokens. If <code>0</code>, calculate logits for all
<code>input_ids</code> (special case). Only last token logits are needed for generation, and calculating them only for that
token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
If a <code>torch.Tensor</code>, must be 1D corresponding to the indices to keep in the sequence length dimension.
This is useful when using packed tensor format (single dimension for batch and sequence length).`,name:"logits_to_keep"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/modeling_chameleon.py#L1017",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast"
>CausalLMOutputWithPast</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonConfig"
>ChameleonConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast"
>CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),oe=new Bn({props:{$$slots:{default:[ws]},$$scope:{ctx:$}}}),se=new wo({props:{anchor:"transformers.ChameleonForConditionalGeneration.forward.example",$$slots:{default:[vs]},$$scope:{ctx:$}}}),nt=new U({props:{name:"get_image_features",anchor:"transformers.ChameleonForConditionalGeneration.get_image_features",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.ChameleonForConditionalGeneration.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a>. See <code>ChameleonImageProcessor.__call__()</code> for details (<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonProcessor">ChameleonProcessor</a> uses
<a href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonImageProcessor">ChameleonImageProcessor</a> for processing images).`,name:"pixel_values"}],source:"https://github.com/huggingface/transformers/blob/vr_36895/src/transformers/models/chameleon/modeling_chameleon.py#L1011",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>A <a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>BaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
href="/docs/transformers/pr_36895/en/model_doc/chameleon#transformers.ChameleonConfig"
>ChameleonConfig</a>) and inputs.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/transformers/pr_36895/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ae=new wo({props:{anchor:"transformers.ChameleonForConditionalGeneration.get_image_features.example",$$slots:{default:[Cs]},$$scope:{ctx:$}}}),ot=new _s({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/chameleon.md"}}),{c(){c=l("meta"),T=o(),f=l("p"),y=o(),w=l("p"),w.innerHTML=b,I=o(),d(ie.$$.fragment),Pt=o(),d(ce.$$.fragment),Rt=o(),S=l("div"),S.innerHTML=vo,Ht=o(),d(de.$$.fragment),qt=o(),me=l("p"),me.innerHTML=Co,Et=o(),pe=l("p"),pe.textContent=ko,Xt=o(),he=l("p"),he.innerHTML=Jo,Yt=o(),D=l("img"),Qt=o(),ge=l("small"),ge.innerHTML=Io,Lt=o(),ue=l("p"),ue.innerHTML=Uo,At=o(),d(fe.$$.fragment),St=o(),_e=l("ul"),_e.innerHTML=jo,Dt=o(),K=l("blockquote"),K.innerHTML=xo,Kt=o(),d(be.$$.fragment),Ot=o(),d(ye.$$.fragment),en=o(),Te=l("p"),Te.innerHTML=Wo,tn=o(),d(Me.$$.fragment),nn=o(),d(we.$$.fragment),on=o(),ve=l("p"),ve.textContent=Zo,sn=o(),d(Ce.$$.fragment),an=o(),d(ke.$$.fragment),rn=o(),d(Je.$$.fragment),ln=o(),$e=l("p"),$e.innerHTML=Bo,cn=o(),d(O.$$.fragment),dn=o(),Ie=l("p"),Ie.textContent=zo,mn=o(),d(Ue.$$.fragment),pn=o(),d(je.$$.fragment),hn=o(),xe=l("p"),xe.innerHTML=Go,gn=o(),d(We.$$.fragment),un=o(),d(Ze.$$.fragment),fn=o(),W=l("div"),d(Be.$$.fragment),zn=o(),rt=l("p"),rt.innerHTML=Fo,Gn=o(),lt=l("p"),lt.innerHTML=Vo,Fn=o(),d(ee.$$.fragment),_n=o(),d(ze.$$.fragment),bn=o(),V=l("div"),d(Ge.$$.fragment),Vn=o(),it=l("p"),it.innerHTML=No,Nn=o(),ct=l("p"),ct.innerHTML=Po,yn=o(),d(Fe.$$.fragment),Tn=o(),Z=l("div"),d(Ve.$$.fragment),Pn=o(),dt=l("p"),dt.textContent=Ro,Rn=o(),mt=l("p"),mt.innerHTML=Ho,Hn=o(),pt=l("div"),d(Ne.$$.fragment),Mn=o(),d(Pe.$$.fragment),wn=o(),N=l("div"),d(Re.$$.fragment),qn=o(),ht=l("p"),ht.textContent=qo,En=o(),gt=l("div"),d(He.$$.fragment),vn=o(),d(qe.$$.fragment),Cn=o(),P=l("div"),d(Ee.$$.fragment),Xn=o(),ut=l("p"),ut.textContent=Eo,Yn=o(),ft=l("div"),d(Xe.$$.fragment),kn=o(),d(Ye.$$.fragment),Jn=o(),j=l("div"),d(Qe.$$.fragment),Qn=o(),_t=l("p"),_t.innerHTML=Xo,Ln=o(),bt=l("p"),bt.innerHTML=Yo,An=o(),yt=l("p"),yt.innerHTML=Qo,Sn=o(),B=l("div"),d(Le.$$.fragment),Dn=o(),Tt=l("p"),Tt.textContent=Lo,Kn=o(),Mt=l("p"),Mt.textContent=Ao,On=o(),d(te.$$.fragment),$n=o(),d(Ae.$$.fragment),In=o(),C=l("div"),d(Se.$$.fragment),eo=o(),wt=l("p"),wt.textContent=So,to=o(),vt=l("p"),vt.innerHTML=Do,no=o(),Ct=l("p"),Ct.innerHTML=Ko,oo=o(),z=l("div"),d(De.$$.fragment),so=o(),kt=l("p"),kt.innerHTML=Oo,ao=o(),d(ne.$$.fragment),ro=o(),Jt=l("ul"),Jt.innerHTML=es,lo=o(),q=l("div"),d(Ke.$$.fragment),io=o(),$t=l("p"),$t.textContent=ts,co=o(),It=l("ul"),It.innerHTML=ns,Un=o(),d(Oe.$$.fragment),jn=o(),k=l("div"),d(et.$$.fragment),mo=o(),Ut=l("p"),Ut.textContent=os,po=o(),jt=l("p"),jt.innerHTML=ss,ho=o(),xt=l("p"),xt.innerHTML=as,go=o(),x=l("div"),d(tt.$$.fragment),uo=o(),Wt=l("p"),Wt.innerHTML=rs,fo=o(),d(oe.$$.fragment),_o=o(),Zt=l("ul"),Zt.innerHTML=ls,bo=o(),d(se.$$.fragment),yo=o(),E=l("div"),d(nt.$$.fragment),To=o(),Bt=l("ul"),Bt.innerHTML=is,Mo=o(),d(ae.$$.fragment),xn=o(),d(ot.$$.fragment),Wn=o(),Ft=l("p"),this.h()},l(e){const t=us("svelte-u9bgzb",document.head);c=i(t,"META",{name:!0,content:!0}),t.forEach(n),T=s(e),f=i(e,"P",{}),v(f).forEach(n),y=s(e),w=i(e,"P",{"data-svelte-h":!0}),_(w)!=="svelte-j7ivsx"&&(w.innerHTML=b),I=s(e),m(ie.$$.fragment,e),Pt=s(e),m(ce.$$.fragment,e),Rt=s(e),S=i(e,"DIV",{class:!0,"data-svelte-h":!0}),_(S)!=="svelte-b95w5j"&&(S.innerHTML=vo),Ht=s(e),m(de.$$.fragment,e),qt=s(e),me=i(e,"P",{"data-svelte-h":!0}),_(me)!=="svelte-1meohlx"&&(me.innerHTML=Co),Et=s(e),pe=i(e,"P",{"data-svelte-h":!0}),_(pe)!=="svelte-vfdo9a"&&(pe.textContent=ko),Xt=s(e),he=i(e,"P",{"data-svelte-h":!0}),_(he)!=="svelte-b403ub"&&(he.innerHTML=Jo),Yt=s(e),D=i(e,"IMG",{src:!0,alt:!0,width:!0}),Qt=s(e),ge=i(e,"SMALL",{"data-svelte-h":!0}),_(ge)!=="svelte-a7q6dv"&&(ge.innerHTML=Io),Lt=s(e),ue=i(e,"P",{"data-svelte-h":!0}),_(ue)!=="svelte-18is37e"&&(ue.innerHTML=Uo),At=s(e),m(fe.$$.fragment,e),St=s(e),_e=i(e,"UL",{"data-svelte-h":!0}),_(_e)!=="svelte-1xww0u5"&&(_e.innerHTML=jo),Dt=s(e),K=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),_(K)!=="svelte-1rhb5xn"&&(K.innerHTML=xo),Kt=s(e),m(be.$$.fragment,e),Ot=s(e),m(ye.$$.fragment,e),en=s(e),Te=i(e,"P",{"data-svelte-h":!0}),_(Te)!=="svelte-1mp252t"&&(Te.innerHTML=Wo),tn=s(e),m(Me.$$.fragment,e),nn=s(e),m(we.$$.fragment,e),on=s(e),ve=i(e,"P",{"data-svelte-h":!0}),_(ve)!=="svelte-55qtep"&&(ve.textContent=Zo),sn=s(e),m(Ce.$$.fragment,e),an=s(e),m(ke.$$.fragment,e),rn=s(e),m(Je.$$.fragment,e),ln=s(e),$e=i(e,"P",{"data-svelte-h":!0}),_($e)!=="svelte-1y3bqqy"&&($e.innerHTML=Bo),cn=s(e),m(O.$$.fragment,e),dn=s(e),Ie=i(e,"P",{"data-svelte-h":!0}),_(Ie)!=="svelte-gwf9h7"&&(Ie.textContent=zo),mn=s(e),m(Ue.$$.fragment,e),pn=s(e),m(je.$$.fragment,e),hn=s(e),xe=i(e,"P",{"data-svelte-h":!0}),_(xe)!=="svelte-131jlth"&&(xe.innerHTML=Go),gn=s(e),m(We.$$.fragment,e),un=s(e),m(Ze.$$.fragment,e),fn=s(e),W=i(e,"DIV",{class:!0});var R=v(W);m(Be.$$.fragment,R),zn=s(R),rt=i(R,"P",{"data-svelte-h":!0}),_(rt)!=="svelte-y1m7vq"&&(rt.innerHTML=Fo),Gn=s(R),lt=i(R,"P",{"data-svelte-h":!0}),_(lt)!=="svelte-1ipj94r"&&(lt.innerHTML=Vo),Fn=s(R),m(ee.$$.fragment,R),R.forEach(n),_n=s(e),m(ze.$$.fragment,e),bn=s(e),V=i(e,"DIV",{class:!0});var Q=v(V);m(Ge.$$.fragment,Q),Vn=s(Q),it=i(Q,"P",{"data-svelte-h":!0}),_(it)!=="svelte-y1m7vq"&&(it.innerHTML=No),Nn=s(Q),ct=i(Q,"P",{"data-svelte-h":!0}),_(ct)!=="svelte-1ipj94r"&&(ct.innerHTML=Po),Q.forEach(n),yn=s(e),m(Fe.$$.fragment,e),Tn=s(e),Z=i(e,"DIV",{class:!0});var H=v(Z);m(Ve.$$.fragment,H),Pn=s(H),dt=i(H,"P",{"data-svelte-h":!0}),_(dt)!=="svelte-13nlhvl"&&(dt.textContent=Ro),Rn=s(H),mt=i(H,"P",{"data-svelte-h":!0}),_(mt)!=="svelte-11ly0uh"&&(mt.innerHTML=Ho),Hn=s(H),pt=i(H,"DIV",{class:!0});var Vt=v(pt);m(Ne.$$.fragment,Vt),Vt.forEach(n),H.forEach(n),Mn=s(e),m(Pe.$$.fragment,e),wn=s(e),N=i(e,"DIV",{class:!0});var L=v(N);m(Re.$$.fragment,L),qn=s(L),ht=i(L,"P",{"data-svelte-h":!0}),_(ht)!=="svelte-r439kd"&&(ht.textContent=qo),En=s(L),gt=i(L,"DIV",{class:!0});var Nt=v(gt);m(He.$$.fragment,Nt),Nt.forEach(n),L.forEach(n),vn=s(e),m(qe.$$.fragment,e),Cn=s(e),P=i(e,"DIV",{class:!0});var A=v(P);m(Ee.$$.fragment,A),Xn=s(A),ut=i(A,"P",{"data-svelte-h":!0}),_(ut)!=="svelte-r439kd"&&(ut.textContent=Eo),Yn=s(A),ft=i(A,"DIV",{class:!0});var cs=v(ft);m(Xe.$$.fragment,cs),cs.forEach(n),A.forEach(n),kn=s(e),m(Ye.$$.fragment,e),Jn=s(e),j=i(e,"DIV",{class:!0});var X=v(j);m(Qe.$$.fragment,X),Qn=s(X),_t=i(X,"P",{"data-svelte-h":!0}),_(_t)!=="svelte-4p3w9k"&&(_t.innerHTML=Xo),Ln=s(X),bt=i(X,"P",{"data-svelte-h":!0}),_(bt)!=="svelte-ojd5c9"&&(bt.innerHTML=Yo),An=s(X),yt=i(X,"P",{"data-svelte-h":!0}),_(yt)!=="svelte-hswkmf"&&(yt.innerHTML=Qo),Sn=s(X),B=i(X,"DIV",{class:!0});var re=v(B);m(Le.$$.fragment,re),Dn=s(re),Tt=i(re,"P",{"data-svelte-h":!0}),_(Tt)!=="svelte-1q5ym45"&&(Tt.textContent=Lo),Kn=s(re),Mt=i(re,"P",{"data-svelte-h":!0}),_(Mt)!=="svelte-w8wo9i"&&(Mt.textContent=Ao),On=s(re),m(te.$$.fragment,re),re.forEach(n),X.forEach(n),$n=s(e),m(Ae.$$.fragment,e),In=s(e),C=i(e,"DIV",{class:!0});var G=v(C);m(Se.$$.fragment,G),eo=s(G),wt=i(G,"P",{"data-svelte-h":!0}),_(wt)!=="svelte-1l8bpto"&&(wt.textContent=So),to=s(G),vt=i(G,"P",{"data-svelte-h":!0}),_(vt)!=="svelte-ojd5c9"&&(vt.innerHTML=Do),no=s(G),Ct=i(G,"P",{"data-svelte-h":!0}),_(Ct)!=="svelte-hswkmf"&&(Ct.innerHTML=Ko),oo=s(G),z=i(G,"DIV",{class:!0});var le=v(z);m(De.$$.fragment,le),so=s(le),kt=i(le,"P",{"data-svelte-h":!0}),_(kt)!=="svelte-y3tfcc"&&(kt.innerHTML=Oo),ao=s(le),m(ne.$$.fragment,le),ro=s(le),Jt=i(le,"UL",{"data-svelte-h":!0}),_(Jt)!=="svelte-1rqiz6e"&&(Jt.innerHTML=es),le.forEach(n),lo=s(G),q=i(G,"DIV",{class:!0});var zt=v(q);m(Ke.$$.fragment,zt),io=s(zt),$t=i(zt,"P",{"data-svelte-h":!0}),_($t)!=="svelte-3ysxgn"&&($t.textContent=ts),co=s(zt),It=i(zt,"UL",{"data-svelte-h":!0}),_(It)!=="svelte-1vt4ztn"&&(It.innerHTML=ns),zt.forEach(n),G.forEach(n),Un=s(e),m(Oe.$$.fragment,e),jn=s(e),k=i(e,"DIV",{class:!0});var F=v(k);m(et.$$.fragment,F),mo=s(F),Ut=i(F,"P",{"data-svelte-h":!0}),_(Ut)!=="svelte-1t17c8v"&&(Ut.textContent=os),po=s(F),jt=i(F,"P",{"data-svelte-h":!0}),_(jt)!=="svelte-ojd5c9"&&(jt.innerHTML=ss),ho=s(F),xt=i(F,"P",{"data-svelte-h":!0}),_(xt)!=="svelte-hswkmf"&&(xt.innerHTML=as),go=s(F),x=i(F,"DIV",{class:!0});var Y=v(x);m(tt.$$.fragment,Y),uo=s(Y),Wt=i(Y,"P",{"data-svelte-h":!0}),_(Wt)!=="svelte-zf5mu"&&(Wt.innerHTML=rs),fo=s(Y),m(oe.$$.fragment,Y),_o=s(Y),Zt=i(Y,"UL",{"data-svelte-h":!0}),_(Zt)!=="svelte-ktcqcq"&&(Zt.innerHTML=ls),bo=s(Y),m(se.$$.fragment,Y),Y.forEach(n),yo=s(F),E=i(F,"DIV",{class:!0});var Gt=v(E);m(nt.$$.fragment,Gt),To=s(Gt),Bt=i(Gt,"UL",{"data-svelte-h":!0}),_(Bt)!=="svelte-1vt4ztn"&&(Bt.innerHTML=is),Mo=s(Gt),m(ae.$$.fragment,Gt),Gt.forEach(n),F.forEach(n),xn=s(e),m(ot.$$.fragment,e),Wn=s(e),Ft=i(e,"P",{}),v(Ft).forEach(n),this.h()},h(){M(c,"name","hf:doc:metadata"),M(c,"content",Js),M(S,"class","flex flex-wrap space-x-1"),ms(D.src,$o="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/chameleon_arch.png")||M(D,"src",$o),M(D,"alt","drawing"),M(D,"width","600"),M(K,"class","note"),M(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(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(pt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(ft,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(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(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(x,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(k,"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){r(document.head,c),a(e,T,t),a(e,f,t),a(e,y,t),a(e,w,t),a(e,I,t),p(ie,e,t),a(e,Pt,t),p(ce,e,t),a(e,Rt,t),a(e,S,t),a(e,Ht,t),p(de,e,t),a(e,qt,t),a(e,me,t),a(e,Et,t),a(e,pe,t),a(e,Xt,t),a(e,he,t),a(e,Yt,t),a(e,D,t),a(e,Qt,t),a(e,ge,t),a(e,Lt,t),a(e,ue,t),a(e,At,t),p(fe,e,t),a(e,St,t),a(e,_e,t),a(e,Dt,t),a(e,K,t),a(e,Kt,t),p(be,e,t),a(e,Ot,t),p(ye,e,t),a(e,en,t),a(e,Te,t),a(e,tn,t),p(Me,e,t),a(e,nn,t),p(we,e,t),a(e,on,t),a(e,ve,t),a(e,sn,t),p(Ce,e,t),a(e,an,t),p(ke,e,t),a(e,rn,t),p(Je,e,t),a(e,ln,t),a(e,$e,t),a(e,cn,t),p(O,e,t),a(e,dn,t),a(e,Ie,t),a(e,mn,t),p(Ue,e,t),a(e,pn,t),p(je,e,t),a(e,hn,t),a(e,xe,t),a(e,gn,t),p(We,e,t),a(e,un,t),p(Ze,e,t),a(e,fn,t),a(e,W,t),p(Be,W,null),r(W,zn),r(W,rt),r(W,Gn),r(W,lt),r(W,Fn),p(ee,W,null),a(e,_n,t),p(ze,e,t),a(e,bn,t),a(e,V,t),p(Ge,V,null),r(V,Vn),r(V,it),r(V,Nn),r(V,ct),a(e,yn,t),p(Fe,e,t),a(e,Tn,t),a(e,Z,t),p(Ve,Z,null),r(Z,Pn),r(Z,dt),r(Z,Rn),r(Z,mt),r(Z,Hn),r(Z,pt),p(Ne,pt,null),a(e,Mn,t),p(Pe,e,t),a(e,wn,t),a(e,N,t),p(Re,N,null),r(N,qn),r(N,ht),r(N,En),r(N,gt),p(He,gt,null),a(e,vn,t),p(qe,e,t),a(e,Cn,t),a(e,P,t),p(Ee,P,null),r(P,Xn),r(P,ut),r(P,Yn),r(P,ft),p(Xe,ft,null),a(e,kn,t),p(Ye,e,t),a(e,Jn,t),a(e,j,t),p(Qe,j,null),r(j,Qn),r(j,_t),r(j,Ln),r(j,bt),r(j,An),r(j,yt),r(j,Sn),r(j,B),p(Le,B,null),r(B,Dn),r(B,Tt),r(B,Kn),r(B,Mt),r(B,On),p(te,B,null),a(e,$n,t),p(Ae,e,t),a(e,In,t),a(e,C,t),p(Se,C,null),r(C,eo),r(C,wt),r(C,to),r(C,vt),r(C,no),r(C,Ct),r(C,oo),r(C,z),p(De,z,null),r(z,so),r(z,kt),r(z,ao),p(ne,z,null),r(z,ro),r(z,Jt),r(C,lo),r(C,q),p(Ke,q,null),r(q,io),r(q,$t),r(q,co),r(q,It),a(e,Un,t),p(Oe,e,t),a(e,jn,t),a(e,k,t),p(et,k,null),r(k,mo),r(k,Ut),r(k,po),r(k,jt),r(k,ho),r(k,xt),r(k,go),r(k,x),p(tt,x,null),r(x,uo),r(x,Wt),r(x,fo),p(oe,x,null),r(x,_o),r(x,Zt),r(x,bo),p(se,x,null),r(k,yo),r(k,E),p(nt,E,null),r(E,To),r(E,Bt),r(E,Mo),p(ae,E,null),a(e,xn,t),p(ot,e,t),a(e,Wn,t),a(e,Ft,t),Zn=!0},p(e,[t]){const R={};t&2&&(R.$$scope={dirty:t,ctx:e}),O.$set(R);const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),ee.$set(Q);const H={};t&2&&(H.$$scope={dirty:t,ctx:e}),te.$set(H);const Vt={};t&2&&(Vt.$$scope={dirty:t,ctx:e}),ne.$set(Vt);const L={};t&2&&(L.$$scope={dirty:t,ctx:e}),oe.$set(L);const Nt={};t&2&&(Nt.$$scope={dirty:t,ctx:e}),se.$set(Nt);const A={};t&2&&(A.$$scope={dirty:t,ctx:e}),ae.$set(A)},i(e){Zn||(h(ie.$$.fragment,e),h(ce.$$.fragment,e),h(de.$$.fragment,e),h(fe.$$.fragment,e),h(be.$$.fragment,e),h(ye.$$.fragment,e),h(Me.$$.fragment,e),h(we.$$.fragment,e),h(Ce.$$.fragment,e),h(ke.$$.fragment,e),h(Je.$$.fragment,e),h(O.$$.fragment,e),h(Ue.$$.fragment,e),h(je.$$.fragment,e),h(We.$$.fragment,e),h(Ze.$$.fragment,e),h(Be.$$.fragment,e),h(ee.$$.fragment,e),h(ze.$$.fragment,e),h(Ge.$$.fragment,e),h(Fe.$$.fragment,e),h(Ve.$$.fragment,e),h(Ne.$$.fragment,e),h(Pe.$$.fragment,e),h(Re.$$.fragment,e),h(He.$$.fragment,e),h(qe.$$.fragment,e),h(Ee.$$.fragment,e),h(Xe.$$.fragment,e),h(Ye.$$.fragment,e),h(Qe.$$.fragment,e),h(Le.$$.fragment,e),h(te.$$.fragment,e),h(Ae.$$.fragment,e),h(Se.$$.fragment,e),h(De.$$.fragment,e),h(ne.$$.fragment,e),h(Ke.$$.fragment,e),h(Oe.$$.fragment,e),h(et.$$.fragment,e),h(tt.$$.fragment,e),h(oe.$$.fragment,e),h(se.$$.fragment,e),h(nt.$$.fragment,e),h(ae.$$.fragment,e),h(ot.$$.fragment,e),Zn=!0)},o(e){g(ie.$$.fragment,e),g(ce.$$.fragment,e),g(de.$$.fragment,e),g(fe.$$.fragment,e),g(be.$$.fragment,e),g(ye.$$.fragment,e),g(Me.$$.fragment,e),g(we.$$.fragment,e),g(Ce.$$.fragment,e),g(ke.$$.fragment,e),g(Je.$$.fragment,e),g(O.$$.fragment,e),g(Ue.$$.fragment,e),g(je.$$.fragment,e),g(We.$$.fragment,e),g(Ze.$$.fragment,e),g(Be.$$.fragment,e),g(ee.$$.fragment,e),g(ze.$$.fragment,e),g(Ge.$$.fragment,e),g(Fe.$$.fragment,e),g(Ve.$$.fragment,e),g(Ne.$$.fragment,e),g(Pe.$$.fragment,e),g(Re.$$.fragment,e),g(He.$$.fragment,e),g(qe.$$.fragment,e),g(Ee.$$.fragment,e),g(Xe.$$.fragment,e),g(Ye.$$.fragment,e),g(Qe.$$.fragment,e),g(Le.$$.fragment,e),g(te.$$.fragment,e),g(Ae.$$.fragment,e),g(Se.$$.fragment,e),g(De.$$.fragment,e),g(ne.$$.fragment,e),g(Ke.$$.fragment,e),g(Oe.$$.fragment,e),g(et.$$.fragment,e),g(tt.$$.fragment,e),g(oe.$$.fragment,e),g(se.$$.fragment,e),g(nt.$$.fragment,e),g(ae.$$.fragment,e),g(ot.$$.fragment,e),Zn=!1},d(e){e&&(n(T),n(f),n(y),n(w),n(I),n(Pt),n(Rt),n(S),n(Ht),n(qt),n(me),n(Et),n(pe),n(Xt),n(he),n(Yt),n(D),n(Qt),n(ge),n(Lt),n(ue),n(At),n(St),n(_e),n(Dt),n(K),n(Kt),n(Ot),n(en),n(Te),n(tn),n(nn),n(on),n(ve),n(sn),n(an),n(rn),n(ln),n($e),n(cn),n(dn),n(Ie),n(mn),n(pn),n(hn),n(xe),n(gn),n(un),n(fn),n(W),n(_n),n(bn),n(V),n(yn),n(Tn),n(Z),n(Mn),n(wn),n(N),n(vn),n(Cn),n(P),n(kn),n(Jn),n(j),n($n),n(In),n(C),n(Un),n(jn),n(k),n(xn),n(Wn),n(Ft)),n(c),u(ie,e),u(ce,e),u(de,e),u(fe,e),u(be,e),u(ye,e),u(Me,e),u(we,e),u(Ce,e),u(ke,e),u(Je,e),u(O,e),u(Ue,e),u(je,e),u(We,e),u(Ze,e),u(Be),u(ee),u(ze,e),u(Ge),u(Fe,e),u(Ve),u(Ne),u(Pe,e),u(Re),u(He),u(qe,e),u(Ee),u(Xe),u(Ye,e),u(Qe),u(Le),u(te),u(Ae,e),u(Se),u(De),u(ne),u(Ke),u(Oe,e),u(et),u(tt),u(oe),u(se),u(nt),u(ae),u(ot,e)}}}const Js='{"title":"Chameleon","local":"chameleon","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Usage example","local":"usage-example","sections":[{"title":"Single image inference","local":"single-image-inference","sections":[],"depth":3},{"title":"Multi image inference","local":"multi-image-inference","sections":[],"depth":3}],"depth":2},{"title":"Model optimization","local":"model-optimization","sections":[{"title":"Quantization using Bitsandbytes","local":"quantization-using-bitsandbytes","sections":[],"depth":3},{"title":"Use Flash-Attention 2 and SDPA to further speed-up generation","local":"use-flash-attention-2-and-sdpa-to-further-speed-up-generation","sections":[],"depth":3}],"depth":2},{"title":"ChameleonConfig","local":"transformers.ChameleonConfig","sections":[],"depth":2},{"title":"ChameleonVQVAEConfig","local":"transformers.ChameleonVQVAEConfig","sections":[],"depth":2},{"title":"ChameleonProcessor","local":"transformers.ChameleonProcessor","sections":[],"depth":2},{"title":"ChameleonImageProcessor","local":"transformers.ChameleonImageProcessor","sections":[],"depth":2},{"title":"ChameleonImageProcessorPil","local":"transformers.ChameleonImageProcessorPil","sections":[],"depth":2},{"title":"ChameleonVQVAE","local":"transformers.ChameleonVQVAE","sections":[],"depth":2},{"title":"ChameleonModel","local":"transformers.ChameleonModel","sections":[],"depth":2},{"title":"ChameleonForConditionalGeneration","local":"transformers.ChameleonForConditionalGeneration","sections":[],"depth":2}],"depth":1}';function $s($){return ps(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gs extends hs{constructor(c){super(),gs(this,c,$s,ks,ds,{})}}export{Gs as component};

Xet Storage Details

Size:
111 kB
·
Xet hash:
cfaf8140e84ed405cd6fe6abfe449324b8a86ac1fd9c788b6e989ec5d51eb8e0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.