Buckets:
| import"../chunks/DsnmJJEf.js";import{i as $,h as K,C as ee,H as d,b as oe,a as c,D as s,E as te,s as ne}from"../chunks/D6eQvJIN.js";import{p as se,o as ae,s as e,f as p,a,b as re,c as r,d as m,r as l,n as b}from"../chunks/D9TCMYxZ.js";import{T as W}from"../chunks/eoUhp3Ag.js";import{E as q}from"../chunks/D8azpo8f.js";import{H as V}from"../chunks/DIDglxF-.js";const le='{"title":"FlexOlmo","local":"flexolmo","sections":[{"title":"FlexOlmoConfig","local":"transformers.FlexOlmoConfig","sections":[],"depth":2},{"title":"FlexOlmoForCausalLM","local":"transformers.FlexOlmoForCausalLM","sections":[],"depth":2},{"title":"FlexOlmoModel","local":"transformers.FlexOlmoModel","sections":[],"depth":2},{"title":"FlexOlmoPreTrainedModel","local":"transformers.FlexOlmoPreTrainedModel","sections":[],"depth":2}],"depth":1}';var ie=m('<meta name="hf:doc:metadata"/>'),de=m("<!> <!>",1),E=m("<p>Example:</p> <!>",1),R=m(`<p>Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.</p>`),ce=m(`<p></p> <p><em>This model was published in HF papers on 2025-07-09 and contributed to Hugging Face Transformers on 2025-09-18.</em></p> <!> <div style="float: right;"><div class="flex flex-wrap space-x-1"><img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"/></div></div> <!> <p><a href="https://huggingface.co/papers/2507.07024" rel="nofollow">FlexOlmo</a> is a new class of language models (LMs) that supports (1) distributed training without data sharing, where different model parameters are independently trained on closed datasets, and (2) data-flexible inference, where these parameters along with their associated data can be flexibly included or excluded from model inferences with no further training. FlexOlmo employs a mixture-of-experts (MoE) architecture where each expert is trained independently on closed datasets and later integrated through a new domain-informed routing without any joint training. FlexOlmo is trained on FlexMix, a corpus we curate comprising publicly available datasets alongside seven domain-specific sets, representing realistic approximations of closed sets.</p> <p>You can find all the original FlexOlmo checkpoints under the <a href="https://huggingface.co/collections/allenai/flexolmo-68471177a386b6e20a54c55f" rel="nofollow">FlexOlmo</a> collection.</p> <blockquote class="tip"><p>Click on the FlexOlmo models in the right sidebar for more examples of how to apply FlexOlmo to different language tasks.</p></blockquote> <p>The example below demonstrates how to generate text with <a href="/docs/transformers/pr_36708/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a>, <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoModel">AutoModel</a> and from the command line.</p> <!> <p>Quantization reduces the memory burden of large models by representing the weights in a lower precision. Refer to the <a href="../quantization/overview">Quantization</a> overview for more available quantization backends.</p> <p>The example below uses <a href="../quantization/torchao">torchao</a> to only quantize the weights to 4-bits.</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a FlexOlmoModel. It is used to instantiate a Flex Olmo | |
| model according to the specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a similar configuration to that of the <a href="https://huggingface.co/allenai/FlexOlmo-7x7B-1T" rel="nofollow">allenai/FlexOlmo-7x7B-1T</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_36708/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_36708/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p> <!></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The Flex Olmo Model for causal language modeling.</p> <p>This model inherits from <a href="/docs/transformers/pr_36708/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.)</p> <p>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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_36708/en/model_doc/flex_olmo#transformers.FlexOlmoForCausalLM">FlexOlmoForCausalLM</a> forward method, overrides the <code>__call__</code> special method.</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>output_router_logits=True</code> is passed or when <code>config.output_router_logits=True</code>, and the model trains its router with a load-balancing loss) — Load-balancing auxiliary loss for the sparse modules. Models that balance their experts with a router bias | |
| instead (DeepSeek-V3 and the architectures derived from it) return <code>None</code> here while still returning <code>router_logits</code>.</p></li> <li><p><strong>router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.output_router_logits=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each sparse layer) of shape <code>(batch_size * sequence_length, num_experts)</code>.</p> <p>Raw router logits computed by the MoE routers. They can be used to compute a load-balancing loss or to | |
| inspect how tokens are dispatched to experts.</p></li> <li><p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</p> <p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Flex Olmo Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_36708/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.)</p> <p>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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_36708/en/model_doc/flex_olmo#transformers.FlexOlmoModel">FlexOlmoModel</a> forward method, overrides the <code>__call__</code> special method.</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>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</p> <p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if <code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li> <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 logits (post-softmax) that are computed by MoE routers, these terms are used to compute the auxiliary | |
| loss for Mixture of Experts models.</p></li></ul></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This model inherits from <a href="/docs/transformers/pr_36708/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.)</p> <p>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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A mock value for a dotted path (e.g. <code>torch.float32</code>): attribute access chains, | |
| calls behave as pass-through decorators, <code>repr</code> is the dotted path, and using it | |
| as a base class substitutes a plain-<code>type</code> base (PEP 560 <code>__mro_entries__</code>), so | |
| real subclasses keep a normal metaclass and <code>inspect.signature</code> reads their real <code>__init__</code> instead of a mock’s.</p></div></div> <!> <p></p>`,1);function _e(X,P){se(P,!1),ae(()=>{new URLSearchParams(window.location.search).get("fw")}),$();var y=ce();K("1674nzn",o=>{var n=ie();ne(n,"content",le),a(o,n)});var M=e(p(y),4);ee(M,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var T=e(M,4);d(T,{title:"FlexOlmo",local:"flexolmo",headingTag:"h1"});var x=e(T,10);oe(x,{id:"usage",options:["Pipeline","AutoModel"],children:(o,n)=>{var t=de(),i=p(t);V(i,{id:"usage",option:"Pipeline",children:(_,D)=>{c(_,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHRhc2slM0QlMjJ0ZXh0LWdlbmVyYXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmFsbGVuYWklMkZGbGV4T2xtby03eDdCLTFUJTIyJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlJTNEMCUyQyUwQSklMEElMEFyZXN1bHQlMjAlM0QlMjBwaXBlKCUyMlBsYW50cyUyMGNyZWF0ZSUyMGVuZXJneSUyMHRocm91Z2glMjBhJTIwcHJvY2VzcyUyMGtub3duJTIwYXMlMjIpJTBBcHJpbnQocmVzdWx0KQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline | |
| pipe = pipeline( | |
| task=<span class="hljs-string">"text-generation"</span>, | |
| model=<span class="hljs-string">"allenai/FlexOlmo-7x7B-1T"</span>, | |
| device=<span class="hljs-number">0</span>, | |
| ) | |
| result = pipe(<span class="hljs-string">"Plants create energy through a process known as"</span>) | |
| <span class="hljs-built_in">print</span>(result)`,lang:"python",wrap:!1})},$$slots:{default:!0}});var Y=e(i,2);V(Y,{id:"usage",option:"AutoModel",children:(_,D)=>{c(_,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmFsbGVuYWklMkZGbGV4T2xtby03eDdCLTFUJTIyJTBBKSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmFsbGVuYWklMkZGbGV4T2xtby03eDdCLTFUJTIyJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyc2RwYSUyMiUwQSklMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyUGxhbnRzJTIwY3JlYXRlJTIwZW5lcmd5JTIwdGhyb3VnaCUyMGElMjBwcm9jZXNzJTIwa25vd24lMjBhcyUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKG1vZGVsLmRldmljZSklMEElMEFvdXRwdXQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0X2lkcyUyQyUyMG1heF9sZW5ndGglM0Q1MCUyQyUyMGNhY2hlX2ltcGxlbWVudGF0aW9uJTNEJTIyc3RhdGljJTIyKSUwQXByaW50KHRva2VuaXplci5kZWNvZGUob3V0cHV0JTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| <span class="hljs-string">"allenai/FlexOlmo-7x7B-1T"</span> | |
| ) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"allenai/FlexOlmo-7x7B-1T"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| attn_implementation=<span class="hljs-string">"sdpa"</span> | |
| ) | |
| input_ids = tokenizer(<span class="hljs-string">"Plants create energy through a process known as"</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| output = model.generate(**input_ids, max_length=<span class="hljs-number">50</span>, cache_implementation=<span class="hljs-string">"static"</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1})},$$slots:{default:!0}}),a(o,t)},$$slots:{default:!0}});var v=e(x,6);c(v,{code:"JTIzcGlwJTIwaW5zdGFsbCUyMHRvcmNoYW8lMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTJDJTIwVG9yY2hBb0NvbmZpZyUwQSUwQSUwQXRvcmNoYW9fY29uZmlnJTIwJTNEJTIwVG9yY2hBb0NvbmZpZyglMEElMjAlMjAlMjAlMjAlMjJpbnQ0X3dlaWdodF9vbmx5JTIyJTJDJTBBJTIwJTIwJTIwJTIwZ3JvdXBfc2l6ZSUzRDEyOCUwQSklMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJhbGxlbmFpJTJGRmxleE9sbW8tN3g3Qi0xVCUyMiUwQSklMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJhbGxlbmFpJTJGRmxleE9sbW8tN3g3Qi0xVCUyMiUyQyUwQSUyMCUyMCUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0R0b3JjaGFvX2NvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXR0bl9pbXBsZW1lbnRhdGlvbiUzRCUyMnNkcGElMjIlMEEpJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlBsYW50cyUyMGNyZWF0ZSUyMGVuZXJneSUyMHRocm91Z2glMjBhJTIwcHJvY2VzcyUyMGtub3duJTIwYXMlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhtb2RlbC5kZXZpY2UpJTBBJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dF9pZHMlMkMlMjBtYXhfbGVuZ3RoJTNENTAlMkMlMjBjYWNoZV9pbXBsZW1lbnRhdGlvbiUzRCUyMnN0YXRpYyUyMiklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKG91dHB1dCU1QjAlNUQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSkp",highlighted:`<span class="hljs-comment">#pip install torchao</span> | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, TorchAoConfig | |
| torchao_config = TorchAoConfig( | |
| <span class="hljs-string">"int4_weight_only"</span>, | |
| group_size=<span class="hljs-number">128</span> | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| <span class="hljs-string">"allenai/FlexOlmo-7x7B-1T"</span> | |
| ) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"allenai/FlexOlmo-7x7B-1T"</span>, | |
| quantization_config=torchao_config, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| attn_implementation=<span class="hljs-string">"sdpa"</span> | |
| ) | |
| input_ids = tokenizer(<span class="hljs-string">"Plants create energy through a process known as"</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| output = model.generate(**input_ids, max_length=<span class="hljs-number">50</span>, cache_implementation=<span class="hljs-string">"static"</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1});var w=e(v,2);d(w,{title:"FlexOlmoConfig",local:"transformers.FlexOlmoConfig",headingTag:"h2"});var h=e(w,2),k=r(h);s(k,{name:"class transformers.FlexOlmoConfig",anchor:"transformers.FlexOlmoConfig",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/configuration_flex_olmo.py#L31",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"vocab_size",val:": int = 100352"},{name:"hidden_size",val:": int = 4096"},{name:"intermediate_size",val:": int = 11008"},{name:"num_hidden_layers",val:": int = 32"},{name:"num_attention_heads",val:": int = 32"},{name:"num_key_value_heads",val:": int | None = None"},{name:"hidden_act",val:": str = 'silu'"},{name:"max_position_embeddings",val:": int = 4096"},{name:"initializer_range",val:": float = 0.02"},{name:"rms_norm_eps",val:": float = 1e-06"},{name:"use_cache",val:": bool = True"},{name:"pad_token_id",val:": int | None = 100277"},{name:"bos_token_id",val:": int | None = None"},{name:"eos_token_id",val:": int | list[int] | None = 100257"},{name:"tie_word_embeddings",val:": bool = False"},{name:"rope_parameters",val:": transformers.modeling_rope_utils.RopeParameters | dict | None = None"},{name:"attention_bias",val:": bool = False"},{name:"attention_dropout",val:": float | None = 0.0"},{name:"num_experts_per_tok",val:": int = 5"},{name:"num_experts",val:": int = 7"},{name:"output_router_logits",val:": bool = False"},{name:"router_aux_loss_coef",val:": float = 0.01"},{name:"norm_topk_prob",val:": bool = False"}],parametersDescription:[{anchor:"transformers.FlexOlmoConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>100352</code>) — | |
| Vocabulary size of the model. Defines the number of different tokens that can be represented by the <code>input_ids</code>.`,name:"vocab_size"},{anchor:"transformers.FlexOlmoConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4096</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.FlexOlmoConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>11008</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.FlexOlmoConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) — | |
| Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.FlexOlmoConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.FlexOlmoConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>) — | |
| This is the number of key_value heads that should be used to implement Grouped Query Attention. If | |
| <code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if | |
| <code>num_key_value_heads=1</code> the model will use Multi Query Attention (MQA) otherwise GQA is used. When | |
| converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed | |
| by meanpooling all the original heads within that group. For more details, check out <a href="https://huggingface.co/papers/2305.13245" rel="nofollow">this | |
| paper</a>. If it is not specified, will default to | |
| <code>num_attention_heads</code>.`,name:"num_key_value_heads"},{anchor:"transformers.FlexOlmoConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>silu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.FlexOlmoConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4096</code>) — | |
| The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.FlexOlmoConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.FlexOlmoConfig.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-06</code>) — | |
| The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.FlexOlmoConfig.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). Only | |
| relevant if <code>config.is_decoder=True</code> or when the model is a decoder-only generative model.`,name:"use_cache"},{anchor:"transformers.FlexOlmoConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>100277</code>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.FlexOlmoConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.FlexOlmoConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>, defaults to <code>100257</code>) — | |
| Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.FlexOlmoConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to tie weight embeddings according to model’s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"},{anchor:"transformers.FlexOlmoConfig.rope_parameters",description:`<strong>rope_parameters</strong> (<code>Union[~modeling_rope_utils.RopeParameters, dict]</code>, <em>optional</em>) — | |
| Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain | |
| a value for <code>rope_theta</code> and optionally parameters used for scaling in case you want to use RoPE | |
| with longer <code>max_position_embeddings</code>.`,name:"rope_parameters"},{anchor:"transformers.FlexOlmoConfig.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a bias in the query, key, value and output projection layers during self-attention.`,name:"attention_bias"},{anchor:"transformers.FlexOlmoConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.FlexOlmoConfig.num_experts_per_tok",description:`<strong>num_experts_per_tok</strong> (<code>int</code>, <em>optional</em>, defaults to <code>5</code>) — | |
| Number of experts to route each token to. This is the top-k value for the token-choice routing.`,name:"num_experts_per_tok"},{anchor:"transformers.FlexOlmoConfig.num_experts",description:`<strong>num_experts</strong> (<code>int</code>, <em>optional</em>, defaults to <code>7</code>) — | |
| Number of routed experts in MoE layers.`,name:"num_experts"},{anchor:"transformers.FlexOlmoConfig.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, including load balancing loss and router z-loss.`,name:"output_router_logits"},{anchor:"transformers.FlexOlmoConfig.router_aux_loss_coef",description:`<strong>router_aux_loss_coef</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.01</code>) — | |
| Auxiliary load balancing loss coefficient. Used to penalize uneven expert routing in MoE models.`,name:"router_aux_loss_coef"},{anchor:"transformers.FlexOlmoConfig.norm_topk_prob",description:`<strong>norm_topk_prob</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to normalize the weights of the routed experts.`,name:"norm_topk_prob"}]});var A=e(k,6);q(A,{anchor:"transformers.FlexOlmoConfig.example",children:(o,n)=>{var t=E(),i=e(p(t),2);c(i,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsZXhPbG1vTW9kZWwlMkMlMjBGbGV4T2xtb0NvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBGbGV4T2xtbyUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBGbGV4T2xtb0NvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwZnJvbSUyMHRoZSUyMEZsZXhPbG1vJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBGbGV4T2xtb01vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlexOlmoModel, FlexOlmoConfig | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a FlexOlmo style configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = FlexOlmoConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the FlexOlmo style configuration</span> | |
| <span class="hljs-meta">>>> </span>model = FlexOlmoModel(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,lang:"python",wrap:!1}),a(o,t)},$$slots:{default:!0}}),l(h);var F=e(h,2);d(F,{title:"FlexOlmoForCausalLM",local:"transformers.FlexOlmoForCausalLM",headingTag:"h2"});var u=e(F,2),C=r(u);s(C,{name:"class transformers.FlexOlmoForCausalLM",anchor:"transformers.FlexOlmoForCausalLM",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/modeling_flex_olmo.py#L567",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.FlexOlmoForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36708/en/model_doc/flex_olmo#transformers.FlexOlmoForCausalLM">FlexOlmoForCausalLM</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_36708/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var U=e(C,8),J=r(U);s(J,{name:"forward",anchor:"transformers.FlexOlmoForCausalLM.forward",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/modeling_flex_olmo.py#L585",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:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": bool | None = None"},{name:"output_router_logits",val:": bool | None = None"},{name:"logits_to_keep",val:": typing.Union[int, torch.Tensor] = 0"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.FlexOlmoForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36708/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36708/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.FlexOlmoForCausalLM.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>`,name:"attention_mask"},{anchor:"transformers.FlexOlmoForCausalLM.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.FlexOlmoForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</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>Only <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.FlexOlmoForCausalLM.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.FlexOlmoForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored | |
| (masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.FlexOlmoForCausalLM.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.FlexOlmoForCausalLM.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.FlexOlmoForCausalLM.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>Union[int, torch.Tensor]</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| If an <code>int</code>, compute logits for the last <code>logits_to_keep</code> tokens. If <code>0</code>, calculate logits for all | |
| <code>input_ids</code> (special case). Only last token logits are needed for generation, and calculating them only for that | |
| token can save memory, which becomes pretty significant for long sequences or large vocabulary size. | |
| If a <code>torch.Tensor</code>, must be 1D corresponding to the indices to keep in the sequence length dimension. | |
| This is useful when using packed tensor format (single dimension for batch and sequence length).`,name:"logits_to_keep"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <code>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_36708/en/model_doc/flex_olmo#transformers.FlexOlmoConfig" | |
| >FlexOlmoConfig</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>MoeCausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p> | |
| `});var j=e(J,4);W(j,{children:(o,n)=>{var t=R();a(o,t)},$$slots:{default:!0}});var Q=e(j,4);q(Q,{anchor:"transformers.FlexOlmoForCausalLM.forward.example",children:(o,n)=>{var t=E(),i=e(p(t),2);c(i,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGbGV4T2xtb0ZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBGbGV4T2xtb0ZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJhbGxlbmFpJTJGRmxleE9sbW8tMUItN0ItMDkyNCUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJhbGxlbmFpJTJGRmxleE9sbW8tMUItN0ItMDkyNCUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJIZXklMkMlMjBhcmUlMjB5b3UlMjBjb25zY2lvdXMlM0YlMjBDYW4lMjB5b3UlMjB0YWxrJTIwdG8lMjBtZSUzRiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQSUyMyUyMEdlbmVyYXRlJTBBZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzLmlucHV0X2lkcyUyQyUyMG1heF9sZW5ndGglM0QzMCklMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlJTJDJTIwY2xlYW5fdXBfdG9rZW5pemF0aW9uX3NwYWNlcyUzREZhbHNlKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FlexOlmoForCausalLM | |
| <span class="hljs-meta">>>> </span>model = FlexOlmoForCausalLM.from_pretrained(<span class="hljs-string">"allenai/FlexOlmo-1B-7B-0924"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"allenai/FlexOlmo-1B-7B-0924"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"Hey, are you conscious? Can you talk to me?"</span> | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Generate</span> | |
| <span class="hljs-meta">>>> </span>generate_ids = model.generate(inputs.input_ids, max_length=<span class="hljs-number">30</span>) | |
| <span class="hljs-meta">>>> </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 sure if you’re conscious of this, but I’m'</span>`,lang:"python",wrap:!1}),a(o,t)},$$slots:{default:!0}}),l(U),l(u);var z=e(u,2);d(z,{title:"FlexOlmoModel",local:"transformers.FlexOlmoModel",headingTag:"h2"});var g=e(z,2),O=r(g);s(O,{name:"class transformers.FlexOlmoModel",anchor:"transformers.FlexOlmoModel",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/modeling_flex_olmo.py#L421",parameters:[{name:"config",val:": FlexOlmoConfig"}],parametersDescription:[{anchor:"transformers.FlexOlmoModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36708/en/model_doc/flex_olmo#transformers.FlexOlmoConfig">FlexOlmoConfig</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_36708/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var Z=e(O,8),G=r(Z);s(G,{name:"forward",anchor:"transformers.FlexOlmoModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/modeling_flex_olmo.py#L438",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:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": bool | None = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.FlexOlmoModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_36708/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36708/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36708/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.FlexOlmoModel.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>`,name:"attention_mask"},{anchor:"transformers.FlexOlmoModel.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.FlexOlmoModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</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>Only <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_36708/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.FlexOlmoModel.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.FlexOlmoModel.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"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <code>MoeModelOutputWithPast</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_36708/en/model_doc/flex_olmo#transformers.FlexOlmoConfig" | |
| >FlexOlmoConfig</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>MoeModelOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p> | |
| `});var L=e(G,4);W(L,{children:(o,n)=>{var t=R();a(o,t)},$$slots:{default:!0}}),b(2),l(Z),l(g);var B=e(g,2);d(B,{title:"FlexOlmoPreTrainedModel",local:"transformers.FlexOlmoPreTrainedModel",headingTag:"h2"});var f=e(B,2),I=r(f);s(I,{name:"class transformers.FlexOlmoPreTrainedModel",anchor:"transformers.FlexOlmoPreTrainedModel",source:"https://github.com/huggingface/transformers/blob/vr_36708/src/transformers/models/flex_olmo/modeling_flex_olmo.py#L391",parameters:[{name:"config",val:": PreTrainedConfig"},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlexOlmoPreTrainedModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36708/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</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_36708/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var N=e(I,6),H=r(N);s(H,{name:"forward",anchor:"transformers.FlexOlmoPreTrainedModel.forward",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}),b(2),l(N),l(f);var S=e(f,2);te(S,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/flex_olmo.md"}),b(2),a(X,y),re()}export{_e as component}; | |
Xet Storage Details
- Size:
- 49.6 kB
- Xet hash:
- 81f68c3505e952dd8a82dacd682aaf35a18d4179c0574fcc749083b4a3f98139
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.