import{s as Ft,o as It,n as Ce}from"../chunks/scheduler.01eeda35.js";import{S as Zt,i as Wt,g as m,s as r,r as h,A as qt,h as c,f as a,c as i,j as me,u,x as _,k as R,y as p,a as s,v as f,d as g,t as b,w as M}from"../chunks/index.6dd51b66.js";import{T as zt}from"../chunks/Tip.de9bae2b.js";import{D as we}from"../chunks/Docstring.cb556860.js";import{C as ve}from"../chunks/CodeBlock.19ec9b8c.js";import{E as ct}from"../chunks/ExampleCodeBlock.69db56ad.js";import{H as E,E as Lt}from"../chunks/index.58fe8f9d.js";function Gt(k){let n,w="Example:",l,d,y;return d=new ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME1hbWJhQ29uZmlnJTJDJTIwTWFtYmFNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBNYW1iYSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwTWFtYmFDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwTWFtYmFNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MambaConfig, MambaModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Mamba configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = MambaConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MambaModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){n=m("p"),n.textContent=w,l=r(),h(d.$$.fragment)},l(o){n=c(o,"P",{"data-svelte-h":!0}),_(n)!=="svelte-11lpom8"&&(n.textContent=w),l=i(o),u(d.$$.fragment,o)},m(o,T){s(o,n,T),s(o,l,T),f(d,o,T),y=!0},p:Ce,i(o){y||(g(d.$$.fragment,o),y=!0)},o(o){b(d.$$.fragment,o),y=!1},d(o){o&&(a(n),a(l)),M(d,o)}}}function Rt(k){let n,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){n=m("p"),n.innerHTML=w},l(l){n=c(l,"P",{"data-svelte-h":!0}),_(n)!=="svelte-fincs2"&&(n.innerHTML=w)},m(l,d){s(l,n,d)},p:Ce,d(l){l&&a(n)}}}function Et(k){let n,w="Example:",l,d,y;return d=new ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNYW1iYU1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGF0ZS1zcGFjZXMlMkZtYW1iYS0xMzBtLWhmJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWFtYmFNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyc3RhdGUtc3BhY2VzJTJGbWFtYmEtMTMwbS1oZiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MambaModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MambaModel.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){n=m("p"),n.textContent=w,l=r(),h(d.$$.fragment)},l(o){n=c(o,"P",{"data-svelte-h":!0}),_(n)!=="svelte-11lpom8"&&(n.textContent=w),l=i(o),u(d.$$.fragment,o)},m(o,T){s(o,n,T),s(o,l,T),f(d,o,T),y=!0},p:Ce,i(o){y||(g(d.$$.fragment,o),y=!0)},o(o){b(d.$$.fragment,o),y=!1},d(o){o&&(a(n),a(l)),M(d,o)}}}function Ht(k){let n,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){n=m("p"),n.innerHTML=w},l(l){n=c(l,"P",{"data-svelte-h":!0}),_(n)!=="svelte-fincs2"&&(n.innerHTML=w)},m(l,d){s(l,n,d)},p:Ce,d(l){l&&a(n)}}}function Xt(k){let n,w="Example:",l,d,y;return d=new ve({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyME1hbWJhRm9yQ2F1c2FsTE0lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGF0ZS1zcGFjZXMlMkZtYW1iYS0xMzBtLWhmJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWFtYmFGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhdGUtc3BhY2VzJTJGbWFtYmEtMTMwbS1oZiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<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">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MambaForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MambaForCausalLM.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`,wrap:!1}}),{c(){n=m("p"),n.textContent=w,l=r(),h(d.$$.fragment)},l(o){n=c(o,"P",{"data-svelte-h":!0}),_(n)!=="svelte-11lpom8"&&(n.textContent=w),l=i(o),u(d.$$.fragment,o)},m(o,T){s(o,n,T),s(o,l,T),f(d,o,T),y=!0},p:Ce,i(o){y||(g(d.$$.fragment,o),y=!0)},o(o){b(d.$$.fragment,o),y=!1},d(o){o&&(a(n),a(l)),M(d,o)}}}function Bt(k){let n,w,l,d,y,o,T,pt='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',$e,H,Ue,X,ht='The Mamba model was proposed in <a href="https://arxiv.org/abs/2312.00752" rel="nofollow">Mamba: Linear-Time Sequence Modeling with Selective State Spaces</a> by Albert Gu and Tri Dao.',Je,B,ut='This model is a new paradigm architecture based on <code>state-space-models</code>. You can read more about the intuition behind these <a href="https://srush.github.io/annotated-s4/" rel="nofollow">here</a>.',ke,S,ft="The abstract from the paper is the following:",xe,V,gt="<em>Foundation models, now powering most of the exciting applications in deep learning, are almost universally based on the Transformer architecture and its core attention module. Many subquadratic-time architectures such as linear attention, gated convolution and recurrent models, and structured state space models (SSMs) have been developed to address Transformers’ computational inefficiency on long sequences, but they have not performed as well as attention on important modalities such as language. We identify that a key weakness of such models is their inability to perform content-based reasoning, and make several improvements. First, simply letting the SSM parameters be functions of the input addresses their weakness with discrete modalities, allowing the model to selectively propagate or forget information along the sequence length dimension depending on the current token. Second, even though this change prevents the use of efficient convolutions, we design a hardware-aware parallel algorithm in recurrent mode. We integrate these selective SSMs into a simplified end-to-end neural network architecture without attention or even MLP blocks (Mamba). Mamba enjoys fast inference (5× higher throughput than Transformers) and linear scaling in sequence length, and its performance improves on real data up to million-length sequences. As a general sequence model backbone, Mamba achieves state-of-the-art performance across several modalities such as language, audio, and genomics. On language modeling, our Mamba-3B model outperforms Transformers of the same size and matches Transformers twice its size, both in pretraining and downstream evaluation.</em>",je,N,bt="Tips:",ze,Q,Mt='<li>Mamba is a new <code>state space model</code> architecture that rivals the classic Transformers. It is based on the line of progress on structured state space models, with an efficient hardware-aware design and implementation in the spirit of <a href="https://github.com/Dao-AILab/flash-attention" rel="nofollow">FlashAttention</a>.</li> <li>Mamba stacks <code>mixer</code> layers, which are the equivalent of <code>Attention</code> layers. The core logic of <code>mamba</code> is held in the <code>MambaMixer</code> class.</li> <li>Two implementations cohabit: one is optimized and uses fast cuda kernels, while the other one is naive but can run on any device!</li> <li>The current implementation leverages the original cuda kernels: the equivalent of flash attention for Mamba are hosted in the <a href="https://github.com/state-spaces/mamba" rel="nofollow"><code>mamba-ssm</code></a> and the <a href="https://github.com/Dao-AILab/causal-conv1d" rel="nofollow"><code>causal_conv1d</code></a> repositories. Make sure to install them if your hardware supports them!</li> <li>Contributions to make the naive path faster are welcome 🤗</li>',Fe,A,_t=`This model was contributed by <a href="https://huggingface.co/ArthurZ" rel="nofollow">ArthurZ</a>.
The original code can be found <a href="https://github.com/state-spaces/mamba" rel="nofollow">here</a>.`,Ie,Y,Ze,P,We,D,qe,O,Le,K,yt="The slow version is not very stable for training, and the fast one needs <code>float32</code>!",Ge,ee,Re,te,Ee,$,ae,Ae,ce,Tt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaModel">MambaModel</a>. It is used to instantiate a MAMBA
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 MAMBA
<a href="https://huggingface.co/state-spaces/mamba-2.8b" rel="nofollow">state-spaces/mamba-2.8b</a> architecture.`,Ye,pe,wt=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Pe,Z,He,ne,Xe,v,oe,De,he,vt="The bare MAMBA Model transformer outputting raw hidden-states without any specific head on top.",Oe,ue,Ct=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Ke,fe,$t=`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.`,et,x,se,tt,ge,Ut='The <a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaModel">MambaModel</a> forward method, overrides the <code>__call__</code> special method.',at,W,nt,q,Be,re,Se,C,ie,ot,be,Jt=`The MAMBA Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`,st,Me,kt=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,rt,_e,xt=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,it,j,le,lt,ye,jt='The <a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaForCausalLM">MambaForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',dt,L,mt,G,Ve,de,Ne,Te,Qe;return y=new E({props:{title:"Mamba",local:"mamba",headingTag:"h1"}}),H=new E({props:{title:"Overview",local:"overview",headingTag:"h2"}}),Y=new E({props:{title:"Usage",local:"usage",headingTag:"h1"}}),P=new E({props:{title:"A simple generation example:",local:"a-simple-generation-example",headingTag:"h3"}}),D=new ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME1hbWJhQ29uZmlnJTJDJTIwTWFtYmFGb3JDYXVzYWxMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnN0YXRlLXNwYWNlcyUyRm1hbWJhLTEzMG0taGYlMjIpJTBBbW9kZWwlMjAlM0QlMjBNYW1iYUZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJzdGF0ZS1zcGFjZXMlMkZtYW1iYS0xMzBtLWhmJTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglMjJIZXklMjBob3clMjBhcmUlMjB5b3UlMjBkb2luZyUzRiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIwJTIycHQlMjIpJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBJTBBb3V0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMCklMEFwcmludCh0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dCkp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MambaConfig, MambaForCausalLM, AutoTokenizer
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)
model = MambaForCausalLM.from_pretrained(<span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>)
input_ids = tokenizer(<span class="hljs-string">&quot;Hey how are you doing?&quot;</span>, return_tensors= <span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]

out = model.generate(input_ids, max_new_tokens=<span class="hljs-number">10</span>)
<span class="hljs-built_in">print</span>(tokenizer.batch_decode(out))`,wrap:!1}}),O=new E({props:{title:"Peft finetuning",local:"peft-finetuning",headingTag:"h3"}}),ee=new ve({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBZnJvbSUyMHRybCUyMGltcG9ydCUyMFNGVFRyYWluZXIlMEFmcm9tJTIwcGVmdCUyMGltcG9ydCUyMExvcmFDb25maWclMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnN0YXRlLXNwYWNlcyUyRm1hbWJhLTEzMG0taGYlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMkFiaXJhdGUlMkZlbmdsaXNoX3F1b3RlcyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0QzJTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNENCUyQyUwQSUyMCUyMCUyMCUyMGxvZ2dpbmdfZGlyJTNEJy4lMkZsb2dzJyUyQyUwQSUyMCUyMCUyMCUyMGxvZ2dpbmdfc3RlcHMlM0QxMCUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0QyZS0zJTBBKSUwQWxvcmFfY29uZmlnJTIwJTNEJTIwJTIwTG9yYUNvbmZpZyglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByJTNEOCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRhcmdldF9tb2R1bGVzJTNEJTVCJTIyeF9wcm9qJTIyJTJDJTIwJTIyZW1iZWRkaW5ncyUyMiUyQyUyMCUyMmluX3Byb2olMjIlMkMlMjAlMjJvdXRfcHJvaiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRhc2tfdHlwZSUzRCUyMkNBVVNBTF9MTSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJpYXMlM0QlMjJub25lJTIyJTBBKSUwQXRyYWluZXIlMjAlM0QlMjBTRlRUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBwcm9jZXNzaW5nX2NsYXNzJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjBwZWZ0X2NvbmZpZyUzRGxvcmFfY29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRGRhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBkYXRhc2V0X3RleHRfZmllbGQlM0QlMjJxdW90ZSUyMiUyQyUwQSklMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> SFTTrainer
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM, TrainingArguments
model_id = <span class="hljs-string">&quot;state-spaces/mamba-130m-hf&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
dataset = load_dataset(<span class="hljs-string">&quot;Abirate/english_quotes&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
training_args = TrainingArguments(
    output_dir=<span class="hljs-string">&quot;./results&quot;</span>,
    num_train_epochs=<span class="hljs-number">3</span>,
    per_device_train_batch_size=<span class="hljs-number">4</span>,
    logging_dir=<span class="hljs-string">&#x27;./logs&#x27;</span>,
    logging_steps=<span class="hljs-number">10</span>,
    learning_rate=<span class="hljs-number">2e-3</span>
)
lora_config =  LoraConfig(
        r=<span class="hljs-number">8</span>,
        target_modules=[<span class="hljs-string">&quot;x_proj&quot;</span>, <span class="hljs-string">&quot;embeddings&quot;</span>, <span class="hljs-string">&quot;in_proj&quot;</span>, <span class="hljs-string">&quot;out_proj&quot;</span>],
        task_type=<span class="hljs-string">&quot;CAUSAL_LM&quot;</span>,
        bias=<span class="hljs-string">&quot;none&quot;</span>
)
trainer = SFTTrainer(
    model=model,
    processing_class=tokenizer,
    args=training_args,
    peft_config=lora_config,
    train_dataset=dataset,
    dataset_text_field=<span class="hljs-string">&quot;quote&quot;</span>,
)
trainer.train()`,wrap:!1}}),te=new E({props:{title:"MambaConfig",local:"transformers.MambaConfig",headingTag:"h2"}}),ae=new we({props:{name:"class transformers.MambaConfig",anchor:"transformers.MambaConfig",parameters:[{name:"vocab_size",val:" = 50280"},{name:"hidden_size",val:" = 768"},{name:"state_size",val:" = 16"},{name:"num_hidden_layers",val:" = 32"},{name:"layer_norm_epsilon",val:" = 1e-05"},{name:"pad_token_id",val:" = 0"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 0"},{name:"expand",val:" = 2"},{name:"conv_kernel",val:" = 4"},{name:"use_bias",val:" = False"},{name:"use_conv_bias",val:" = True"},{name:"hidden_act",val:" = 'silu'"},{name:"initializer_range",val:" = 0.1"},{name:"residual_in_fp32",val:" = True"},{name:"time_step_rank",val:" = 'auto'"},{name:"time_step_scale",val:" = 1.0"},{name:"time_step_min",val:" = 0.001"},{name:"time_step_max",val:" = 0.1"},{name:"time_step_init_scheme",val:" = 'random'"},{name:"time_step_floor",val:" = 0.0001"},{name:"rescale_prenorm_residual",val:" = False"},{name:"use_cache",val:" = True"},{name:"use_mambapy",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MambaConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50280) &#x2014;
Vocabulary size of the MAMBA model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaModel">MambaModel</a>.`,name:"vocab_size"},{anchor:"transformers.MambaConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the embeddings and hidden states.`,name:"hidden_size"},{anchor:"transformers.MambaConfig.state_size",description:"<strong>state_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014; shape of the state space latents.",name:"state_size"},{anchor:"transformers.MambaConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of hidden layers in the model.`,name:"num_hidden_layers"},{anchor:"transformers.MambaConfig.layer_norm_epsilon",description:`<strong>layer_norm_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-05) &#x2014;
The epsilon to use in the layer normalization layers.`,name:"layer_norm_epsilon"},{anchor:"transformers.MambaConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Padding token id.`,name:"pad_token_id"},{anchor:"transformers.MambaConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The id of the beginning of sentence token in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.MambaConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The id of the end of sentence token in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.MambaConfig.expand",description:"<strong>expand</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014; Expanding factor used to determine the intermediate size.",name:"expand"},{anchor:"transformers.MambaConfig.conv_kernel",description:"<strong>conv_kernel</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014; Size of the convolution kernel.",name:"conv_kernel"},{anchor:"transformers.MambaConfig.use_bias",description:`<strong>use_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use bias in [&#x201C;in_proj&#x201D;, &#x201C;out_proj&#x201D;] of the mixer block`,name:"use_bias"},{anchor:"transformers.MambaConfig.use_conv_bias",description:`<strong>use_conv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use bias in the convolution layer of the mixer block.`,name:"use_conv_bias"},{anchor:"transformers.MambaConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the decoder.`,name:"hidden_act"},{anchor:"transformers.MambaConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.MambaConfig.residual_in_fp32",description:`<strong>residual_in_fp32</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not residuals should be in <code>float32</code>. If set to <code>False</code> residuals will keep the same <code>dtype</code> as the rest of the model`,name:"residual_in_fp32"},{anchor:"transformers.MambaConfig.time_step_rank",description:`<strong>time_step_rank</strong> (<code>Union[int,str]</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
Rank of the discretization projection matrix. <code>&quot;auto&quot;</code> means that it will default to <code>math.ceil(self.hidden_size / 16)</code>`,name:"time_step_rank"},{anchor:"transformers.MambaConfig.time_step_scale",description:`<strong>time_step_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Scale used used to scale <code>dt_proj.bias</code>.`,name:"time_step_scale"},{anchor:"transformers.MambaConfig.time_step_min",description:`<strong>time_step_min</strong> (<code>float</code>, <em>optional</em>, defaults to 0.001) &#x2014;
Minimum <code>time_step</code> used to bound <code>dt_proj.bias</code>.`,name:"time_step_min"},{anchor:"transformers.MambaConfig.time_step_max",description:`<strong>time_step_max</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Maximum <code>time_step</code> used to bound <code>dt_proj.bias</code>.`,name:"time_step_max"},{anchor:"transformers.MambaConfig.time_step_init_scheme",description:`<strong>time_step_init_scheme</strong> (<code>float</code>, <em>optional</em>, defaults to <code>&quot;random&quot;</code>) &#x2014;
Init scheme used for <code>dt_proj.weight</code>. Should be one of <code>[&quot;random&quot;,&quot;uniform&quot;]</code>`,name:"time_step_init_scheme"},{anchor:"transformers.MambaConfig.time_step_floor",description:`<strong>time_step_floor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0001) &#x2014;
Minimum clamping value of the <code>dt_proj.bias</code> layer initialization.`,name:"time_step_floor"},{anchor:"transformers.MambaConfig.rescale_prenorm_residual",description:`<strong>rescale_prenorm_residual</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to rescale <code>out_proj</code> weights when initializing.`,name:"rescale_prenorm_residual"},{anchor:"transformers.MambaConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the cache should be used.`,name:"use_cache"},{anchor:"transformers.MambaConfig.use_mambapy",description:`<strong>use_mambapy</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Determines the fallback strategy during training if the CUDA-based official implementation of Mamba is not avaiable. If <code>True</code>, the mamba.py implementation is used. If <code>False</code>, the naive and slower implementation is used. Consider switching to the naive version if memory is limited.`,name:"use_mambapy"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/mamba/configuration_mamba.py#L26"}}),Z=new ct({props:{anchor:"transformers.MambaConfig.example",$$slots:{default:[Gt]},$$scope:{ctx:k}}}),ne=new E({props:{title:"MambaModel",local:"transformers.MambaModel",headingTag:"h2"}}),oe=new we({props:{name:"class transformers.MambaModel",anchor:"transformers.MambaModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MambaModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaConfig">MambaConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/mamba/modeling_mamba.py#L541"}}),se=new we({props:{name:"forward",anchor:"transformers.MambaModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.LongTensor] = None"},{name:"cache_params",val:": typing.Optional[transformers.cache_utils.MambaCache] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.MambaModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>cache_params.seqlen_offset&gt;0</code>, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MambaModel.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.MambaModel.forward.cache_params",description:`<strong>cache_params</strong> (<code>MambaCache</code>, <em>optional</em>) &#x2014;
If passed along, the model uses the previous state in all the blocks (which will give the output for the
<code>input_ids</code> provided as if the model add <code>state_input_ids + input_ids</code> as context).`,name:"cache_params"},{anchor:"transformers.MambaModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the <code>cache_params</code> is returned and can be used to quickly generate the next logits.`,name:"use_cache"},{anchor:"transformers.MambaModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.MambaModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MambaModel.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) &#x2014;
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to <code>position_ids</code>,
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
the complete sequence length.`,name:"cache_position"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/mamba/modeling_mamba.py#L570",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.mamba.modeling_mamba.MambaOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaConfig"
>MambaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>cache_params</strong> (<code>MambaCache</code>) — The state of the model at the last time step. Can be used in a forward method with the next <code>input_ids</code> to
avoid providing the old <code>input_ids</code>.</p>
<p>Includes both the State space model state matrices after the selective scan, and the Convolutional states</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>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.mamba.modeling_mamba.MambaOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),W=new zt({props:{$$slots:{default:[Rt]},$$scope:{ctx:k}}}),q=new ct({props:{anchor:"transformers.MambaModel.forward.example",$$slots:{default:[Et]},$$scope:{ctx:k}}}),re=new E({props:{title:"MambaLMHeadModel",local:"transformers.MambaForCausalLM",headingTag:"h2"}}),ie=new we({props:{name:"class transformers.MambaForCausalLM",anchor:"transformers.MambaForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MambaForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaConfig">MambaConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/mamba/modeling_mamba.py#L653"}}),le=new we({props:{name:"forward",anchor:"transformers.MambaForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"cache_params",val:": typing.Optional[transformers.cache_utils.MambaCache] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MambaForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>cache_params.seqlen_offset&gt;0</code>, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MambaForCausalLM.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.MambaForCausalLM.forward.cache_params",description:`<strong>cache_params</strong> (<code>MambaCache</code>, <em>optional</em>) &#x2014;
If passed along, the model uses the previous state in all the blocks (which will give the output for the
<code>input_ids</code> provided as if the model add <code>state_input_ids + input_ids</code> as context).`,name:"cache_params"},{anchor:"transformers.MambaForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the <code>cache_params</code> is returned and can be used to quickly generate the next logits.`,name:"use_cache"},{anchor:"transformers.MambaForCausalLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.MambaForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MambaForCausalLM.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) &#x2014;
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to <code>position_ids</code>,
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
the complete sequence length.`,name:"cache_position"},{anchor:"transformers.MambaForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size]</code> All labels set to <code>-100</code>
are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/mamba/modeling_mamba.py#L749",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.mamba.modeling_mamba.MambaCausalLMOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/mamba#transformers.MambaConfig"
>MambaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>cache_params</strong> (<code>MambaCache</code>) — The state of the model at the last time step. Can be used in a forward method with the next <code>input_ids</code> to
avoid providing the old <code>input_ids</code>.</p>
<p>Includes both the State space model state matrices after the selective scan, and the Convolutional states</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>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.mamba.modeling_mamba.MambaCausalLMOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),L=new zt({props:{$$slots:{default:[Ht]},$$scope:{ctx:k}}}),G=new ct({props:{anchor:"transformers.MambaForCausalLM.forward.example",$$slots:{default:[Xt]},$$scope:{ctx:k}}}),de=new Lt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/mamba.md"}}),{c(){n=m("meta"),w=r(),l=m("p"),d=r(),h(y.$$.fragment),o=r(),T=m("div"),T.innerHTML=pt,$e=r(),h(H.$$.fragment),Ue=r(),X=m("p"),X.innerHTML=ht,Je=r(),B=m("p"),B.innerHTML=ut,ke=r(),S=m("p"),S.textContent=ft,xe=r(),V=m("p"),V.innerHTML=gt,je=r(),N=m("p"),N.textContent=bt,ze=r(),Q=m("ul"),Q.innerHTML=Mt,Fe=r(),A=m("p"),A.innerHTML=_t,Ie=r(),h(Y.$$.fragment),Ze=r(),h(P.$$.fragment),We=r(),h(D.$$.fragment),qe=r(),h(O.$$.fragment),Le=r(),K=m("p"),K.innerHTML=yt,Ge=r(),h(ee.$$.fragment),Re=r(),h(te.$$.fragment),Ee=r(),$=m("div"),h(ae.$$.fragment),Ae=r(),ce=m("p"),ce.innerHTML=Tt,Ye=r(),pe=m("p"),pe.innerHTML=wt,Pe=r(),h(Z.$$.fragment),He=r(),h(ne.$$.fragment),Xe=r(),v=m("div"),h(oe.$$.fragment),De=r(),he=m("p"),he.textContent=vt,Oe=r(),ue=m("p"),ue.innerHTML=Ct,Ke=r(),fe=m("p"),fe.innerHTML=$t,et=r(),x=m("div"),h(se.$$.fragment),tt=r(),ge=m("p"),ge.innerHTML=Ut,at=r(),h(W.$$.fragment),nt=r(),h(q.$$.fragment),Be=r(),h(re.$$.fragment),Se=r(),C=m("div"),h(ie.$$.fragment),ot=r(),be=m("p"),be.textContent=Jt,st=r(),Me=m("p"),Me.innerHTML=kt,rt=r(),_e=m("p"),_e.innerHTML=xt,it=r(),j=m("div"),h(le.$$.fragment),lt=r(),ye=m("p"),ye.innerHTML=jt,dt=r(),h(L.$$.fragment),mt=r(),h(G.$$.fragment),Ve=r(),h(de.$$.fragment),Ne=r(),Te=m("p"),this.h()},l(e){const t=qt("svelte-u9bgzb",document.head);n=c(t,"META",{name:!0,content:!0}),t.forEach(a),w=i(e),l=c(e,"P",{}),me(l).forEach(a),d=i(e),u(y.$$.fragment,e),o=i(e),T=c(e,"DIV",{class:!0,"data-svelte-h":!0}),_(T)!=="svelte-13t8s2t"&&(T.innerHTML=pt),$e=i(e),u(H.$$.fragment,e),Ue=i(e),X=c(e,"P",{"data-svelte-h":!0}),_(X)!=="svelte-1d6srga"&&(X.innerHTML=ht),Je=i(e),B=c(e,"P",{"data-svelte-h":!0}),_(B)!=="svelte-1luq6q2"&&(B.innerHTML=ut),ke=i(e),S=c(e,"P",{"data-svelte-h":!0}),_(S)!=="svelte-vfdo9a"&&(S.textContent=ft),xe=i(e),V=c(e,"P",{"data-svelte-h":!0}),_(V)!=="svelte-1j9ofgw"&&(V.innerHTML=gt),je=i(e),N=c(e,"P",{"data-svelte-h":!0}),_(N)!=="svelte-axv494"&&(N.textContent=bt),ze=i(e),Q=c(e,"UL",{"data-svelte-h":!0}),_(Q)!=="svelte-k3qrrt"&&(Q.innerHTML=Mt),Fe=i(e),A=c(e,"P",{"data-svelte-h":!0}),_(A)!=="svelte-11rhxoo"&&(A.innerHTML=_t),Ie=i(e),u(Y.$$.fragment,e),Ze=i(e),u(P.$$.fragment,e),We=i(e),u(D.$$.fragment,e),qe=i(e),u(O.$$.fragment,e),Le=i(e),K=c(e,"P",{"data-svelte-h":!0}),_(K)!=="svelte-1b7b7tj"&&(K.innerHTML=yt),Ge=i(e),u(ee.$$.fragment,e),Re=i(e),u(te.$$.fragment,e),Ee=i(e),$=c(e,"DIV",{class:!0});var z=me($);u(ae.$$.fragment,z),Ae=i(z),ce=c(z,"P",{"data-svelte-h":!0}),_(ce)!=="svelte-3xnaor"&&(ce.innerHTML=Tt),Ye=i(z),pe=c(z,"P",{"data-svelte-h":!0}),_(pe)!=="svelte-o55m63"&&(pe.innerHTML=wt),Pe=i(z),u(Z.$$.fragment,z),z.forEach(a),He=i(e),u(ne.$$.fragment,e),Xe=i(e),v=c(e,"DIV",{class:!0});var U=me(v);u(oe.$$.fragment,U),De=i(U),he=c(U,"P",{"data-svelte-h":!0}),_(he)!=="svelte-1p0vlfb"&&(he.textContent=vt),Oe=i(U),ue=c(U,"P",{"data-svelte-h":!0}),_(ue)!=="svelte-6pahdo"&&(ue.innerHTML=Ct),Ke=i(U),fe=c(U,"P",{"data-svelte-h":!0}),_(fe)!=="svelte-hswkmf"&&(fe.innerHTML=$t),et=i(U),x=c(U,"DIV",{class:!0});var F=me(x);u(se.$$.fragment,F),tt=i(F),ge=c(F,"P",{"data-svelte-h":!0}),_(ge)!=="svelte-19tim6l"&&(ge.innerHTML=Ut),at=i(F),u(W.$$.fragment,F),nt=i(F),u(q.$$.fragment,F),F.forEach(a),U.forEach(a),Be=i(e),u(re.$$.fragment,e),Se=i(e),C=c(e,"DIV",{class:!0});var J=me(C);u(ie.$$.fragment,J),ot=i(J),be=c(J,"P",{"data-svelte-h":!0}),_(be)!=="svelte-xhqj3f"&&(be.textContent=Jt),st=i(J),Me=c(J,"P",{"data-svelte-h":!0}),_(Me)!=="svelte-6pahdo"&&(Me.innerHTML=kt),rt=i(J),_e=c(J,"P",{"data-svelte-h":!0}),_(_e)!=="svelte-hswkmf"&&(_e.innerHTML=xt),it=i(J),j=c(J,"DIV",{class:!0});var I=me(j);u(le.$$.fragment,I),lt=i(I),ye=c(I,"P",{"data-svelte-h":!0}),_(ye)!=="svelte-1c9df8h"&&(ye.innerHTML=jt),dt=i(I),u(L.$$.fragment,I),mt=i(I),u(G.$$.fragment,I),I.forEach(a),J.forEach(a),Ve=i(e),u(de.$$.fragment,e),Ne=i(e),Te=c(e,"P",{}),me(Te).forEach(a),this.h()},h(){R(n,"name","hf:doc:metadata"),R(n,"content",St),R(T,"class","flex flex-wrap space-x-1"),R($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(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(e,t){p(document.head,n),s(e,w,t),s(e,l,t),s(e,d,t),f(y,e,t),s(e,o,t),s(e,T,t),s(e,$e,t),f(H,e,t),s(e,Ue,t),s(e,X,t),s(e,Je,t),s(e,B,t),s(e,ke,t),s(e,S,t),s(e,xe,t),s(e,V,t),s(e,je,t),s(e,N,t),s(e,ze,t),s(e,Q,t),s(e,Fe,t),s(e,A,t),s(e,Ie,t),f(Y,e,t),s(e,Ze,t),f(P,e,t),s(e,We,t),f(D,e,t),s(e,qe,t),f(O,e,t),s(e,Le,t),s(e,K,t),s(e,Ge,t),f(ee,e,t),s(e,Re,t),f(te,e,t),s(e,Ee,t),s(e,$,t),f(ae,$,null),p($,Ae),p($,ce),p($,Ye),p($,pe),p($,Pe),f(Z,$,null),s(e,He,t),f(ne,e,t),s(e,Xe,t),s(e,v,t),f(oe,v,null),p(v,De),p(v,he),p(v,Oe),p(v,ue),p(v,Ke),p(v,fe),p(v,et),p(v,x),f(se,x,null),p(x,tt),p(x,ge),p(x,at),f(W,x,null),p(x,nt),f(q,x,null),s(e,Be,t),f(re,e,t),s(e,Se,t),s(e,C,t),f(ie,C,null),p(C,ot),p(C,be),p(C,st),p(C,Me),p(C,rt),p(C,_e),p(C,it),p(C,j),f(le,j,null),p(j,lt),p(j,ye),p(j,dt),f(L,j,null),p(j,mt),f(G,j,null),s(e,Ve,t),f(de,e,t),s(e,Ne,t),s(e,Te,t),Qe=!0},p(e,[t]){const z={};t&2&&(z.$$scope={dirty:t,ctx:e}),Z.$set(z);const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),W.$set(U);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),q.$set(F);const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),L.$set(J);const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),G.$set(I)},i(e){Qe||(g(y.$$.fragment,e),g(H.$$.fragment,e),g(Y.$$.fragment,e),g(P.$$.fragment,e),g(D.$$.fragment,e),g(O.$$.fragment,e),g(ee.$$.fragment,e),g(te.$$.fragment,e),g(ae.$$.fragment,e),g(Z.$$.fragment,e),g(ne.$$.fragment,e),g(oe.$$.fragment,e),g(se.$$.fragment,e),g(W.$$.fragment,e),g(q.$$.fragment,e),g(re.$$.fragment,e),g(ie.$$.fragment,e),g(le.$$.fragment,e),g(L.$$.fragment,e),g(G.$$.fragment,e),g(de.$$.fragment,e),Qe=!0)},o(e){b(y.$$.fragment,e),b(H.$$.fragment,e),b(Y.$$.fragment,e),b(P.$$.fragment,e),b(D.$$.fragment,e),b(O.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(ae.$$.fragment,e),b(Z.$$.fragment,e),b(ne.$$.fragment,e),b(oe.$$.fragment,e),b(se.$$.fragment,e),b(W.$$.fragment,e),b(q.$$.fragment,e),b(re.$$.fragment,e),b(ie.$$.fragment,e),b(le.$$.fragment,e),b(L.$$.fragment,e),b(G.$$.fragment,e),b(de.$$.fragment,e),Qe=!1},d(e){e&&(a(w),a(l),a(d),a(o),a(T),a($e),a(Ue),a(X),a(Je),a(B),a(ke),a(S),a(xe),a(V),a(je),a(N),a(ze),a(Q),a(Fe),a(A),a(Ie),a(Ze),a(We),a(qe),a(Le),a(K),a(Ge),a(Re),a(Ee),a($),a(He),a(Xe),a(v),a(Be),a(Se),a(C),a(Ve),a(Ne),a(Te)),a(n),M(y,e),M(H,e),M(Y,e),M(P,e),M(D,e),M(O,e),M(ee,e),M(te,e),M(ae),M(Z),M(ne,e),M(oe),M(se),M(W),M(q),M(re,e),M(ie),M(le),M(L),M(G),M(de,e)}}}const St='{"title":"Mamba","local":"mamba","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2}],"depth":1}';function Vt(k){return It(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Kt extends Zt{constructor(n){super(),Wt(this,n,Vt,Bt,Ft,{})}}export{Kt as component};
