Buckets:
| import{s as wt,o as Jt,n as Ee}from"../chunks/scheduler.25b97de1.js";import{S as xt,i as Ut,g as d,s,r as m,A as vt,h as c,f as n,c as a,j as se,u as h,x as M,k as ae,y as i,a as r,v as f,d as g,t as b,w as y}from"../chunks/index.d9030fc9.js";import{T as _t}from"../chunks/Tip.baa67368.js";import{D as ye}from"../chunks/Docstring.ffac8efa.js";import{C as Me}from"../chunks/CodeBlock.e6cd0d95.js";import{E as Tt}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as ge,E as kt}from"../chunks/EditOnGithub.91d95064.js";function jt($){let o,T="Example:",p,u,_;return u=new Me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERicnhDb25maWclMkMlMjBEYnJ4TW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwRGJyeCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwRGJyeENvbmZpZyhuX2xheWVycyUzRDIlMkMlMjBkX21vZGVsJTNEMjU2JTJDJTIwbl9oZWFkcyUzRDglMkMlMjB2b2NhYl9zaXplJTNEMTI4KSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwRGJyeE1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DbrxConfig, DbrxModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a Dbrx configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = DbrxConfig(n_layers=<span class="hljs-number">2</span>, d_model=<span class="hljs-number">256</span>, n_heads=<span class="hljs-number">8</span>, vocab_size=<span class="hljs-number">128</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span> | |
| <span class="hljs-meta">>>> </span>model = DbrxModel(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,wrap:!1}}),{c(){o=d("p"),o.textContent=T,p=s(),m(u.$$.fragment)},l(l){o=c(l,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=T),p=a(l),h(u.$$.fragment,l)},m(l,w){r(l,o,w),r(l,p,w),f(u,l,w),_=!0},p:Ee,i(l){_||(g(u.$$.fragment,l),_=!0)},o(l){b(u.$$.fragment,l),_=!1},d(l){l&&(n(o),n(p)),y(u,l)}}}function Ct($){let o,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(){o=d("p"),o.innerHTML=T},l(p){o=c(p,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=T)},m(p,u){r(p,o,u)},p:Ee,d(p){p&&n(o)}}}function $t($){let o,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(){o=d("p"),o.innerHTML=T},l(p){o=c(p,"P",{"data-svelte-h":!0}),M(o)!=="svelte-fincs2"&&(o.innerHTML=T)},m(p,u){r(p,o,u)},p:Ee,d(p){p&&n(o)}}}function It($){let o,T="Example:",p,u,_;return u=new Me({props:{code:"JTNFJTNFJTIwZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBEYnJ4Rm9yQ2F1c2FsTE0lMEElMEElM0UlM0UlMjBtb2RlbCUyMCUzRCUyMERicnhGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGF0YWJyaWNrcyUyRmRicngtaW5zdHJ1Y3QlMjIpJTBBJTNFJTNFJTIwdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGF0YWJyaWNrcyUyRmRicngtaW5zdHJ1Y3QlMjIpJTBBJTBBJTNFJTNFJTIwcHJvbXB0JTIwJTNEJTIwJTIySGV5JTJDJTIwYXJlJTIweW91JTIwY29uc2Npb3VzJTNGJTIwQ2FuJTIweW91JTIwdGFsayUyMHRvJTIwbWUlM0YlMjIlMEElM0UlM0UlMjBpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElM0UlM0UlMjAlMjMlMjBHZW5lcmF0ZSUwQSUzRSUzRSUyMGdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cy5pbnB1dF9pZHMlMkMlMjBtYXhfbGVuZ3RoJTNEMzApJTBBJTNFJTNFJTIwdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZV9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMGNsZWFuX3VwX3Rva2VuaXphdGlvbl9zcGFjZXMlM0RGYWxzZSklNUIwJTVEJTBBJTIySGV5JTJDJTIwYXJlJTIweW91JTIwY29uc2Npb3VzJTNGJTIwQ2FuJTIweW91JTIwdGFsayUyMHRvJTIwbWUlM0YlNUNuSSdtJTIwbm90JTIwY29uc2Npb3VzJTJDJTIwYnV0JTIwSSUyMGNhbiUyMHRhbGslMjB0byUyMHlvdS4lMjI=",highlighted:`>> <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, DbrxForCausalLM | |
| >> model = DbrxForCausalLM.from_pretrained(<span class="hljs-string">"databricks/dbrx-instruct"</span>) | |
| >> tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"databricks/dbrx-instruct"</span>) | |
| >> prompt = <span class="hljs-string">"Hey, are you conscious? Can you talk to me?"</span> | |
| >> inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">"pt"</span>) | |
| >> <span class="hljs-comment"># Generate</span> | |
| >> generate_ids = model.generate(inputs.input_ids, max_length=<span class="hljs-number">30</span>) | |
| >> tokenizer.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>] | |
| <span class="hljs-string">"Hey, are you conscious? Can you talk to me?\\nI'm not conscious, but I can talk to you."</span>`,wrap:!1}}),{c(){o=d("p"),o.textContent=T,p=s(),m(u.$$.fragment)},l(l){o=c(l,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=T),p=a(l),h(u.$$.fragment,l)},m(l,w){r(l,o,w),r(l,p,w),f(u,l,w),_=!0},p:Ee,i(l){_||(g(u.$$.fragment,l),_=!0)},o(l){b(u.$$.fragment,l),_=!1},d(l){l&&(n(o),n(p)),y(u,l)}}}function Rt($){let o,T,p,u,_,l,w,_e,z,ot=`DBRX is a <a href="https://www.isattentionallyouneed.com/" rel="nofollow">transformer-based</a> decoder-only large language model (LLM) that was trained using next-token prediction. | |
| It uses a <em>fine-grained</em> mixture-of-experts (MoE) architecture with 132B total parameters of which 36B parameters are active on any input. | |
| It was pre-trained on 12T tokens of text and code data. | |
| Compared to other open MoE models like Mixtral-8x7B and Grok-1, DBRX is fine-grained, meaning it uses a larger number of smaller experts. DBRX has 16 experts and chooses 4, while Mixtral-8x7B and Grok-1 have 8 experts and choose 2. | |
| This provides 65x more possible combinations of experts and we found that this improves model quality. | |
| DBRX uses rotary position encodings (RoPE), gated linear units (GLU), and grouped query attention (GQA). | |
| It is a BPE based model and uses the GPT-4 tokenizer as described in the <a href="https://github.com/openai/tiktoken" rel="nofollow">tiktoken</a> repository. | |
| We made these choices based on exhaustive evaluation and scaling experiments.`,Te,N,st=`DBRX was pretrained on 12T tokens of carefully curated data and a maximum context length of 32K tokens. | |
| We estimate that this data is at least 2x better token-for-token than the data we used to pretrain the MPT family of models. | |
| This new dataset was developed using the full suite of Databricks tools, including Apache Spark™ and Databricks notebooks for data processing, and Unity Catalog for data management and governance. | |
| We used curriculum learning for pretraining, changing the data mix during training in ways we found to substantially improve model quality.`,we,E,at='More detailed information about DBRX Instruct and DBRX Base can be found in our <a href="https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm" rel="nofollow">technical blog post</a>.',Je,W,rt='This model was contributed by <a href="https://huggingface.co/eitanturok" rel="nofollow">eitan-turok</a> and <a href="https://huggingface.co/abhi-db" rel="nofollow">abhi-db</a>. The original code can be found <a href="https://github.com/databricks/dbrx-instruct" rel="nofollow">here</a>, though this may not be up to date.',xe,V,Ue,B,lt="The <code>generate()</code> method can be used to generate text using DBRX. You can generate using the standard attention implementation, flash-attention, and the PyTorch scaled dot product attention. The last two attention implementations give speed ups.",ve,q,ke,H,it='If you have flash-attention installed (<code>pip install flash-attn</code>), it is possible to generate faster. (The HuggingFace documentation for flash-attention can be found <a href="https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-2" rel="nofollow">here</a>.)',je,Q,Ce,L,dt='You can also generate faster using the PyTorch scaled dot product attention. (The HuggingFace documentation for scaled dot product attention can be found <a href="https://huggingface.co/docs/transformers/perf_infer_gpu_one#pytorch-scaled-dot-product-attention" rel="nofollow">here</a>.)',$e,Y,Ie,S,Re,U,P,We,re,ct=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxModel">DbrxModel</a>. It is used to instantiate a Dbrx model according to the | |
| specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a different configuration to that of the <a href="https://huggingface.co/databricks/dbrx-instruct" rel="nofollow">databricks/dbrx-instruct</a> architecture.`,Ve,le,pt=`Configuration objects inherit from <a href="/docs/transformers/pr_35674/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_35674/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Be,G,Ze,A,Ge,J,O,qe,ie,ut=`The bare DBRX Model outputting raw hidden-states without any specific head on top. | |
| This model inherits from <a href="/docs/transformers/pr_35674/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.)`,He,de,mt=`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.`,Qe,ce,ht="Transformer decoder consisting of <em>config.num_hidden_layers</em>. Each layer is a <code>DbrxBlock</code> layer.",Le,I,K,Ye,pe,ft='The <a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxModel">DbrxModel</a> forward method, overrides the <code>__call__</code> special method.',Se,X,Xe,ee,Fe,v,te,Pe,ue,gt=`The DBRX Model transformer for causal language modeling. | |
| This model inherits from <a href="/docs/transformers/pr_35674/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.)`,Ae,me,bt=`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.`,Oe,x,ne,Ke,he,yt='The <a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxForCausalLM">DbrxForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',et,F,tt,fe,Mt="Forward function for causal language modeling.",nt,D,De,oe,ze,be,Ne;return _=new ge({props:{title:"DBRX",local:"dbrx",headingTag:"h1"}}),w=new ge({props:{title:"Overview",local:"overview",headingTag:"h2"}}),V=new ge({props:{title:"Usage Examples",local:"usage-examples",headingTag:"h2"}}),q=new Me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERicnhGb3JDYXVzYWxMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRhdGFicmlja3MlMkZkYnJ4LWluc3RydWN0JTIyJTJDJTIwdG9rZW4lM0QlMjJZT1VSX0hGX1RPS0VOJTIyKSUwQW1vZGVsJTIwJTNEJTIwRGJyeEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkYXRhYnJpY2tzJTJGZGJyeC1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuJTNEJTIyWU9VUl9IRl9UT0tFTiUyMiUyQyUwQSUyMCUyMCUyMCUyMCklMEElMEFpbnB1dF90ZXh0JTIwJTNEJTIwJTIyV2hhdCUyMGRvZXMlMjBpdCUyMHRha2UlMjB0byUyMGJ1aWxkJTIwYSUyMGdyZWF0JTIwTExNJTNGJTIyJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjBpbnB1dF90ZXh0JTdEJTVEJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X2NoYXRfdGVtcGxhdGUobWVzc2FnZXMlMkMlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMjB0b2tlbml6ZSUzRFRydWUlMkMlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oJTIyY3VkYSUyMiklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dF9pZHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwMCklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKG91dHB1dHMlNUIwJTVEKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DbrxForCausalLM, AutoTokenizer | |
| <span class="hljs-keyword">import</span> torch | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"databricks/dbrx-instruct"</span>, token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>) | |
| model = DbrxForCausalLM.from_pretrained( | |
| <span class="hljs-string">"databricks/dbrx-instruct"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| torch_dtype=torch.bfloat16, | |
| token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>, | |
| ) | |
| input_text = <span class="hljs-string">"What does it take to build a great LLM?"</span> | |
| messages = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: input_text}] | |
| input_ids = tokenizer.apply_chat_template(messages, return_dict=<span class="hljs-literal">True</span>, tokenize=<span class="hljs-literal">True</span>, add_generation_prompt=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(<span class="hljs-string">"cuda"</span>) | |
| outputs = model.generate(**input_ids, max_new_tokens=<span class="hljs-number">200</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(outputs[<span class="hljs-number">0</span>]))`,wrap:!1}}),Q=new Me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERicnhGb3JDYXVzYWxMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRhdGFicmlja3MlMkZkYnJ4LWluc3RydWN0JTIyJTJDJTIwdG9rZW4lM0QlMjJZT1VSX0hGX1RPS0VOJTIyKSUwQW1vZGVsJTIwJTNEJTIwRGJyeEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkYXRhYnJpY2tzJTJGZGJyeC1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuJTNEJTIyWU9VUl9IRl9UT0tFTiUyMiUyQyUwQSUyMCUyMCUyMCUyMGF0dG5faW1wbGVtZW50YXRpb24lM0QlMjJmbGFzaF9hdHRlbnRpb25fMiUyMiUyQyUwQSUyMCUyMCUyMCUyMCklMEElMEFpbnB1dF90ZXh0JTIwJTNEJTIwJTIyV2hhdCUyMGRvZXMlMjBpdCUyMHRha2UlMjB0byUyMGJ1aWxkJTIwYSUyMGdyZWF0JTIwTExNJTNGJTIyJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjBpbnB1dF90ZXh0JTdEJTVEJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X2NoYXRfdGVtcGxhdGUobWVzc2FnZXMlMkMlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMjB0b2tlbml6ZSUzRFRydWUlMkMlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oJTIyY3VkYSUyMiklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dF9pZHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwMCklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKG91dHB1dHMlNUIwJTVEKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DbrxForCausalLM, AutoTokenizer | |
| <span class="hljs-keyword">import</span> torch | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"databricks/dbrx-instruct"</span>, token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>) | |
| model = DbrxForCausalLM.from_pretrained( | |
| <span class="hljs-string">"databricks/dbrx-instruct"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| torch_dtype=torch.bfloat16, | |
| token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>, | |
| attn_implementation=<span class="hljs-string">"flash_attention_2"</span>, | |
| ) | |
| input_text = <span class="hljs-string">"What does it take to build a great LLM?"</span> | |
| messages = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: input_text}] | |
| input_ids = tokenizer.apply_chat_template(messages, return_dict=<span class="hljs-literal">True</span>, tokenize=<span class="hljs-literal">True</span>, add_generation_prompt=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(<span class="hljs-string">"cuda"</span>) | |
| outputs = model.generate(**input_ids, max_new_tokens=<span class="hljs-number">200</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(outputs[<span class="hljs-number">0</span>]))`,wrap:!1}}),Y=new Me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERicnhGb3JDYXVzYWxMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRhdGFicmlja3MlMkZkYnJ4LWluc3RydWN0JTIyJTJDJTIwdG9rZW4lM0QlMjJZT1VSX0hGX1RPS0VOJTIyKSUwQW1vZGVsJTIwJTNEJTIwRGJyeEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkYXRhYnJpY2tzJTJGZGJyeC1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuJTNEJTIyWU9VUl9IRl9UT0tFTiUyMiUyQyUwQSUyMCUyMCUyMCUyMGF0dG5faW1wbGVtZW50YXRpb24lM0QlMjJzZHBhJTIyJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQWlucHV0X3RleHQlMjAlM0QlMjAlMjJXaGF0JTIwZG9lcyUyMGl0JTIwdGFrZSUyMHRvJTIwYnVpbGQlMjBhJTIwZ3JlYXQlMjBMTE0lM0YlMjIlMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMGlucHV0X3RleHQlN0QlNUQlMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIuYXBwbHlfY2hhdF90ZW1wbGF0ZShtZXNzYWdlcyUyQyUyMHJldHVybl9kaWN0JTNEVHJ1ZSUyQyUyMHRva2VuaXplJTNEVHJ1ZSUyQyUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byglMjJjdWRhJTIyKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0X2lkcyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMjAwKSUwQXByaW50KHRva2VuaXplci5kZWNvZGUob3V0cHV0cyU1QjAlNUQpKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DbrxForCausalLM, AutoTokenizer | |
| <span class="hljs-keyword">import</span> torch | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"databricks/dbrx-instruct"</span>, token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>) | |
| model = DbrxForCausalLM.from_pretrained( | |
| <span class="hljs-string">"databricks/dbrx-instruct"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| torch_dtype=torch.bfloat16, | |
| token=<span class="hljs-string">"YOUR_HF_TOKEN"</span>, | |
| attn_implementation=<span class="hljs-string">"sdpa"</span>, | |
| ) | |
| input_text = <span class="hljs-string">"What does it take to build a great LLM?"</span> | |
| messages = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: input_text}] | |
| input_ids = tokenizer.apply_chat_template(messages, return_dict=<span class="hljs-literal">True</span>, tokenize=<span class="hljs-literal">True</span>, add_generation_prompt=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(<span class="hljs-string">"cuda"</span>) | |
| outputs = model.generate(**input_ids, max_new_tokens=<span class="hljs-number">200</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(outputs[<span class="hljs-number">0</span>]))`,wrap:!1}}),S=new ge({props:{title:"DbrxConfig",local:"transformers.DbrxConfig",headingTag:"h2"}}),P=new ye({props:{name:"class transformers.DbrxConfig",anchor:"transformers.DbrxConfig",parameters:[{name:"d_model",val:": int = 2048"},{name:"n_heads",val:": int = 16"},{name:"n_layers",val:": int = 24"},{name:"max_seq_len",val:": int = 2048"},{name:"vocab_size",val:": int = 32000"},{name:"resid_pdrop",val:": float = 0.0"},{name:"emb_pdrop",val:": float = 0.0"},{name:"attn_config",val:": typing.Optional[transformers.models.dbrx.configuration_dbrx.DbrxAttentionConfig] = None"},{name:"ffn_config",val:": typing.Optional[transformers.models.dbrx.configuration_dbrx.DbrxFFNConfig] = None"},{name:"use_cache",val:": bool = True"},{name:"initializer_range",val:": float = 0.02"},{name:"output_router_logits",val:": bool = False"},{name:"**kwargs",val:": typing.Any"}],parametersDescription:[{anchor:"transformers.DbrxConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) — | |
| Dimensionality of the embeddings and hidden states.`,name:"d_model"},{anchor:"transformers.DbrxConfig.n_heads",description:`<strong>n_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) — | |
| Number of attention heads for each attention layer in the Transformer encoder.`,name:"n_heads"},{anchor:"transformers.DbrxConfig.n_layers",description:`<strong>n_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 24) — | |
| Number of hidden layers in the Transformer encoder.`,name:"n_layers"},{anchor:"transformers.DbrxConfig.max_seq_len",description:`<strong>max_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) — | |
| The maximum sequence length of the model.`,name:"max_seq_len"},{anchor:"transformers.DbrxConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32000) — | |
| Vocabulary size of the Dbrx model. Defines the maximum number of different tokens that can be represented by | |
| the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxModel">DbrxModel</a>.`,name:"vocab_size"},{anchor:"transformers.DbrxConfig.resid_pdrop",description:`<strong>resid_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) — | |
| The dropout probability applied to the attention output before combining with residual.`,name:"resid_pdrop"},{anchor:"transformers.DbrxConfig.emb_pdrop",description:`<strong>emb_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) — | |
| The dropout probability for the embedding layer.`,name:"emb_pdrop"},{anchor:"transformers.DbrxConfig.attn_config",description:`<strong>attn_config</strong> (<code>dict</code>, <em>optional</em>) — | |
| A dictionary used to configure the model’s attention module.`,name:"attn_config"},{anchor:"transformers.DbrxConfig.ffn_config",description:`<strong>ffn_config</strong> (<code>dict</code>, <em>optional</em>) — | |
| A dictionary used to configure the model’s FFN module.`,name:"ffn_config"},{anchor:"transformers.DbrxConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.DbrxConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DbrxConfig.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the router logits should be returned by the model. Enabling this will also | |
| allow the model to output the auxiliary loss. See <a href>here</a> for more details.`,name:"output_router_logits"}],source:"https://github.com/huggingface/transformers/blob/vr_35674/src/transformers/models/dbrx/configuration_dbrx.py#L119"}}),G=new Tt({props:{anchor:"transformers.DbrxConfig.example",$$slots:{default:[jt]},$$scope:{ctx:$}}}),A=new ge({props:{title:"DbrxModel",local:"transformers.DbrxModel",headingTag:"h2"}}),O=new ye({props:{name:"class transformers.DbrxModel",anchor:"transformers.DbrxModel",parameters:[{name:"config",val:": DbrxConfig"}],parametersDescription:[{anchor:"transformers.DbrxModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxConfig">DbrxConfig</a>) — | |
| 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_35674/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.DbrxModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxConfig">DbrxConfig</a>) — Model configuration class with all 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_35674/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_35674/src/transformers/models/dbrx/modeling_dbrx.py#L933"}}),K=new ye({props:{name:"forward",anchor:"transformers.DbrxModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[transformers.cache_utils.Cache] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.DbrxModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide | |
| it.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_35674/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_35674/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_35674/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.DbrxModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>1 for tokens that are <strong>not masked</strong>,</li> | |
| <li>0 for tokens that are <strong>masked</strong>.</li> | |
| </ul> | |
| <p><a href="../glossary#attention-mask">What are attention masks?</a></p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_35674/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_35674/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_35674/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see | |
| <code>past_key_values</code>).</p> | |
| <p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code> | |
| and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more | |
| information on the default strategy.</p> | |
| <ul> | |
| <li>1 indicates the head is <strong>not masked</strong>,</li> | |
| <li>0 indicates the head is <strong>masked</strong>.</li> | |
| </ul>`,name:"attention_mask"},{anchor:"transformers.DbrxModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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.DbrxModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Cache</code> or <code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>) — | |
| 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>Two formats are allowed:</p> | |
| <ul> | |
| <li>a <a href="/docs/transformers/pr_35674/en/internal/generation_utils#transformers.Cache">Cache</a> instance, see our | |
| <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>;</li> | |
| <li>Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of | |
| shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>). This is also known as the legacy | |
| cache format.</li> | |
| </ul> | |
| <p>The model will output the same cache format that is fed as input. If no <code>past_key_values</code> are passed, the | |
| legacy cache format will be returned.</p> | |
| <p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.DbrxModel.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>) — | |
| 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’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.DbrxModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.DbrxModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned | |
| tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.DbrxModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.DbrxModel.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the logits of all the routers. They are useful for computing the router loss, and | |
| should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.DbrxModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_35674/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.DbrxModel.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) — | |
| 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/vr_35674/src/transformers/models/dbrx/modeling_dbrx.py#L966"}}),X=new _t({props:{$$slots:{default:[Ct]},$$scope:{ctx:$}}}),ee=new ge({props:{title:"DbrxForCausalLM",local:"transformers.DbrxForCausalLM",headingTag:"h2"}}),te=new ye({props:{name:"class transformers.DbrxForCausalLM",anchor:"transformers.DbrxForCausalLM",parameters:[{name:"config",val:": DbrxConfig"}],parametersDescription:[{anchor:"transformers.DbrxForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_35674/en/model_doc/dbrx#transformers.DbrxConfig">DbrxConfig</a>) — | |
| 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_35674/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_35674/src/transformers/models/dbrx/modeling_dbrx.py#L1228"}}),ne=new ye({props:{name:"forward",anchor:"transformers.DbrxForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[transformers.cache_utils.Cache] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"},{name:"num_logits_to_keep",val:": int = 0"}],parametersDescription:[{anchor:"transformers.DbrxForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide | |
| it.`,name:"input_ids"}],source:"https://github.com/huggingface/transformers/blob/vr_35674/src/transformers/models/dbrx/modeling_dbrx.py#L1260",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <code>transformers.modeling_outputs.MoeCausalLMOutputWithPast</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/pr_35674/en/model_doc/dbrx#transformers.DbrxConfig" | |
| >DbrxConfig</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>aux_loss</strong> (<code>torch.FloatTensor</code>, <em>optional</em>, returned when <code>labels</code> is provided) — aux_loss for the sparse modules.</p> | |
| </li> | |
| <li> | |
| <p><strong>router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_probs=True</code> and <code>config.add_router_probs=True</code> is passed or when <code>config.output_router_probs=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p> | |
| <p>Raw router logtis (post-softmax) that are computed by MoE routers, these terms are used to compute the auxiliary | |
| loss for Mixture of Experts models.</p> | |
| </li> | |
| <li> | |
| <p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape | |
| <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>)</p> | |
| <p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see | |
| <code>past_key_values</code> input) to speed up sequential decoding.</p> | |
| </li> | |
| <li> | |
| <p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> | |
| <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p> | |
| </li> | |
| <li> | |
| <p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> | |
| <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>transformers.modeling_outputs.MoeCausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),F=new _t({props:{$$slots:{default:[$t]},$$scope:{ctx:$}}}),D=new Tt({props:{anchor:"transformers.DbrxForCausalLM.forward.example",$$slots:{default:[It]},$$scope:{ctx:$}}}),oe=new kt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/dbrx.md"}}),{c(){o=d("meta"),T=s(),p=d("p"),u=s(),m(_.$$.fragment),l=s(),m(w.$$.fragment),_e=s(),z=d("p"),z.innerHTML=ot,Te=s(),N=d("p"),N.textContent=st,we=s(),E=d("p"),E.innerHTML=at,Je=s(),W=d("p"),W.innerHTML=rt,xe=s(),m(V.$$.fragment),Ue=s(),B=d("p"),B.innerHTML=lt,ve=s(),m(q.$$.fragment),ke=s(),H=d("p"),H.innerHTML=it,je=s(),m(Q.$$.fragment),Ce=s(),L=d("p"),L.innerHTML=dt,$e=s(),m(Y.$$.fragment),Ie=s(),m(S.$$.fragment),Re=s(),U=d("div"),m(P.$$.fragment),We=s(),re=d("p"),re.innerHTML=ct,Ve=s(),le=d("p"),le.innerHTML=pt,Be=s(),m(G.$$.fragment),Ze=s(),m(A.$$.fragment),Ge=s(),J=d("div"),m(O.$$.fragment),qe=s(),ie=d("p"),ie.innerHTML=ut,He=s(),de=d("p"),de.innerHTML=mt,Qe=s(),ce=d("p"),ce.innerHTML=ht,Le=s(),I=d("div"),m(K.$$.fragment),Ye=s(),pe=d("p"),pe.innerHTML=ft,Se=s(),m(X.$$.fragment),Xe=s(),m(ee.$$.fragment),Fe=s(),v=d("div"),m(te.$$.fragment),Pe=s(),ue=d("p"),ue.innerHTML=gt,Ae=s(),me=d("p"),me.innerHTML=bt,Oe=s(),x=d("div"),m(ne.$$.fragment),Ke=s(),he=d("p"),he.innerHTML=yt,et=s(),m(F.$$.fragment),tt=s(),fe=d("p"),fe.textContent=Mt,nt=s(),m(D.$$.fragment),De=s(),m(oe.$$.fragment),ze=s(),be=d("p"),this.h()},l(e){const t=vt("svelte-u9bgzb",document.head);o=c(t,"META",{name:!0,content:!0}),t.forEach(n),T=a(e),p=c(e,"P",{}),se(p).forEach(n),u=a(e),h(_.$$.fragment,e),l=a(e),h(w.$$.fragment,e),_e=a(e),z=c(e,"P",{"data-svelte-h":!0}),M(z)!=="svelte-14fqb4b"&&(z.innerHTML=ot),Te=a(e),N=c(e,"P",{"data-svelte-h":!0}),M(N)!=="svelte-6tnpsh"&&(N.textContent=st),we=a(e),E=c(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-p78060"&&(E.innerHTML=at),Je=a(e),W=c(e,"P",{"data-svelte-h":!0}),M(W)!=="svelte-1y0gtxp"&&(W.innerHTML=rt),xe=a(e),h(V.$$.fragment,e),Ue=a(e),B=c(e,"P",{"data-svelte-h":!0}),M(B)!=="svelte-1n2ymew"&&(B.innerHTML=lt),ve=a(e),h(q.$$.fragment,e),ke=a(e),H=c(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-45m1hv"&&(H.innerHTML=it),je=a(e),h(Q.$$.fragment,e),Ce=a(e),L=c(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-1cyfh2c"&&(L.innerHTML=dt),$e=a(e),h(Y.$$.fragment,e),Ie=a(e),h(S.$$.fragment,e),Re=a(e),U=c(e,"DIV",{class:!0});var j=se(U);h(P.$$.fragment,j),We=a(j),re=c(j,"P",{"data-svelte-h":!0}),M(re)!=="svelte-1qgormc"&&(re.innerHTML=ct),Ve=a(j),le=c(j,"P",{"data-svelte-h":!0}),M(le)!=="svelte-f39fgb"&&(le.innerHTML=pt),Be=a(j),h(G.$$.fragment,j),j.forEach(n),Ze=a(e),h(A.$$.fragment,e),Ge=a(e),J=c(e,"DIV",{class:!0});var k=se(J);h(O.$$.fragment,k),qe=a(k),ie=c(k,"P",{"data-svelte-h":!0}),M(ie)!=="svelte-1sb225x"&&(ie.innerHTML=ut),He=a(k),de=c(k,"P",{"data-svelte-h":!0}),M(de)!=="svelte-hswkmf"&&(de.innerHTML=mt),Qe=a(k),ce=c(k,"P",{"data-svelte-h":!0}),M(ce)!=="svelte-hglq5y"&&(ce.innerHTML=ht),Le=a(k),I=c(k,"DIV",{class:!0});var Z=se(I);h(K.$$.fragment,Z),Ye=a(Z),pe=c(Z,"P",{"data-svelte-h":!0}),M(pe)!=="svelte-1cz1lx8"&&(pe.innerHTML=ft),Se=a(Z),h(X.$$.fragment,Z),Z.forEach(n),k.forEach(n),Xe=a(e),h(ee.$$.fragment,e),Fe=a(e),v=c(e,"DIV",{class:!0});var C=se(v);h(te.$$.fragment,C),Pe=a(C),ue=c(C,"P",{"data-svelte-h":!0}),M(ue)!=="svelte-3v0qvj"&&(ue.innerHTML=gt),Ae=a(C),me=c(C,"P",{"data-svelte-h":!0}),M(me)!=="svelte-hswkmf"&&(me.innerHTML=bt),Oe=a(C),x=c(C,"DIV",{class:!0});var R=se(x);h(ne.$$.fragment,R),Ke=a(R),he=c(R,"P",{"data-svelte-h":!0}),M(he)!=="svelte-1usfsg8"&&(he.innerHTML=yt),et=a(R),h(F.$$.fragment,R),tt=a(R),fe=c(R,"P",{"data-svelte-h":!0}),M(fe)!=="svelte-9dp5h6"&&(fe.textContent=Mt),nt=a(R),h(D.$$.fragment,R),R.forEach(n),C.forEach(n),De=a(e),h(oe.$$.fragment,e),ze=a(e),be=c(e,"P",{}),se(be).forEach(n),this.h()},h(){ae(o,"name","hf:doc:metadata"),ae(o,"content",Zt),ae(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ae(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ae(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ae(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ae(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(e,t){i(document.head,o),r(e,T,t),r(e,p,t),r(e,u,t),f(_,e,t),r(e,l,t),f(w,e,t),r(e,_e,t),r(e,z,t),r(e,Te,t),r(e,N,t),r(e,we,t),r(e,E,t),r(e,Je,t),r(e,W,t),r(e,xe,t),f(V,e,t),r(e,Ue,t),r(e,B,t),r(e,ve,t),f(q,e,t),r(e,ke,t),r(e,H,t),r(e,je,t),f(Q,e,t),r(e,Ce,t),r(e,L,t),r(e,$e,t),f(Y,e,t),r(e,Ie,t),f(S,e,t),r(e,Re,t),r(e,U,t),f(P,U,null),i(U,We),i(U,re),i(U,Ve),i(U,le),i(U,Be),f(G,U,null),r(e,Ze,t),f(A,e,t),r(e,Ge,t),r(e,J,t),f(O,J,null),i(J,qe),i(J,ie),i(J,He),i(J,de),i(J,Qe),i(J,ce),i(J,Le),i(J,I),f(K,I,null),i(I,Ye),i(I,pe),i(I,Se),f(X,I,null),r(e,Xe,t),f(ee,e,t),r(e,Fe,t),r(e,v,t),f(te,v,null),i(v,Pe),i(v,ue),i(v,Ae),i(v,me),i(v,Oe),i(v,x),f(ne,x,null),i(x,Ke),i(x,he),i(x,et),f(F,x,null),i(x,tt),i(x,fe),i(x,nt),f(D,x,null),r(e,De,t),f(oe,e,t),r(e,ze,t),r(e,be,t),Ne=!0},p(e,[t]){const j={};t&2&&(j.$$scope={dirty:t,ctx:e}),G.$set(j);const k={};t&2&&(k.$$scope={dirty:t,ctx:e}),X.$set(k);const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),F.$set(Z);const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),D.$set(C)},i(e){Ne||(g(_.$$.fragment,e),g(w.$$.fragment,e),g(V.$$.fragment,e),g(q.$$.fragment,e),g(Q.$$.fragment,e),g(Y.$$.fragment,e),g(S.$$.fragment,e),g(P.$$.fragment,e),g(G.$$.fragment,e),g(A.$$.fragment,e),g(O.$$.fragment,e),g(K.$$.fragment,e),g(X.$$.fragment,e),g(ee.$$.fragment,e),g(te.$$.fragment,e),g(ne.$$.fragment,e),g(F.$$.fragment,e),g(D.$$.fragment,e),g(oe.$$.fragment,e),Ne=!0)},o(e){b(_.$$.fragment,e),b(w.$$.fragment,e),b(V.$$.fragment,e),b(q.$$.fragment,e),b(Q.$$.fragment,e),b(Y.$$.fragment,e),b(S.$$.fragment,e),b(P.$$.fragment,e),b(G.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(K.$$.fragment,e),b(X.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(ne.$$.fragment,e),b(F.$$.fragment,e),b(D.$$.fragment,e),b(oe.$$.fragment,e),Ne=!1},d(e){e&&(n(T),n(p),n(u),n(l),n(_e),n(z),n(Te),n(N),n(we),n(E),n(Je),n(W),n(xe),n(Ue),n(B),n(ve),n(ke),n(H),n(je),n(Ce),n(L),n($e),n(Ie),n(Re),n(U),n(Ze),n(Ge),n(J),n(Xe),n(Fe),n(v),n(De),n(ze),n(be)),n(o),y(_,e),y(w,e),y(V,e),y(q,e),y(Q,e),y(Y,e),y(S,e),y(P),y(G),y(A,e),y(O),y(K),y(X),y(ee,e),y(te),y(ne),y(F),y(D),y(oe,e)}}}const Zt='{"title":"DBRX","local":"dbrx","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage Examples","local":"usage-examples","sections":[],"depth":2},{"title":"DbrxConfig","local":"transformers.DbrxConfig","sections":[],"depth":2},{"title":"DbrxModel","local":"transformers.DbrxModel","sections":[],"depth":2},{"title":"DbrxForCausalLM","local":"transformers.DbrxForCausalLM","sections":[],"depth":2}],"depth":1}';function Gt($){return Jt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vt extends xt{constructor(o){super(),Ut(this,o,Gt,Rt,wt,{})}}export{Vt as component}; | |
Xet Storage Details
- Size:
- 47.5 kB
- Xet hash:
- 32043e48e537f4395ed5b8033c6c9c6da07b6b5d67ba1a4a3d05edf05bb85c57
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.