Buckets:
| import"../chunks/DsnmJJEf.js";import{i as I,h as Z,C as W,H as t,D as d,a as M,E as L,s as R}from"../chunks/D6eQvJIN.js";import{p as V,o as B,s as e,f as C,a as s,b as q,c,d as r,n as H,r as m}from"../chunks/D9TCMYxZ.js";import{T as S}from"../chunks/eoUhp3Ag.js";import{E as G}from"../chunks/D8azpo8f.js";const X='{"title":"FalconH1","local":"falconh1","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Contributors","local":"contributors","sections":[],"depth":2},{"title":"Notes","local":"notes","sections":[],"depth":2},{"title":"FalconH1Config","local":"transformers.FalconH1Config","sections":[],"depth":2},{"title":"FalconH1ForCausalLM","local":"transformers.FalconH1ForCausalLM","sections":[],"depth":2}],"depth":1}';var E=r('<meta name="hf:doc:metadata"/>'),P=r(`<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>`),D=r("<p>Example:</p> <!>",1),Q=r(`<p></p> <p><em>This model was contributed to Hugging Face Transformers on 2025-05-21.</em></p> <!> <!> <!> <p>The <a href="https://huggingface.co/blog/tiiuae/falcon-h1" rel="nofollow">FalconH1</a> model was developed by the TII Pretraining team. A comprehensive research paper covering the architecture, pretraining dynamics, experimental results, and conclusions is forthcoming. You can read more about this series in <a href="https://github.com/tiiuae/Falcon-H1" rel="nofollow">this website</a>.</p> <!> <p>This model was contributed by <a href="https://huggingface.co/DhiyaEddine" rel="nofollow">DhiyaEddine</a>, <a href="https://huggingface.co/ybelkada" rel="nofollow">ybelkada</a>, <a href="https://huggingface.co/JingweiZuo" rel="nofollow">JingweiZuo</a>, <a href="https://huggingface.co/IChahed" rel="nofollow">IlyasChahed</a>, and <a href="https://huggingface.co/yellowvm" rel="nofollow">MaksimVelikanov</a>. | |
| The original code can be found <a href="https://github.com/tiiuae/Falcon-H1" rel="nofollow">here</a>.</p> <!> <ul><li>Use left padding for batched generation. See <a href="../llm_tutorial#padding-side">Padding side</a>.</li></ul> <!> <table><thead><tr><th>Model</th><th>Depth</th><th>Dim</th><th>Attn Heads</th><th>KV</th><th>Mamba Heads</th><th>d_head</th><th>d_state</th><th>Ctx Len</th></tr></thead><tbody><tr><td>H1 0.5B</td><td>36</td><td>1024</td><td>8</td><td>2</td><td>24</td><td>64 / 64</td><td>128</td><td>4K, 16K-SFT</td></tr><tr><td>H1 1.5B</td><td>24</td><td>2048</td><td>8</td><td>2</td><td>48</td><td>128 / 64</td><td>256</td><td>128K</td></tr><tr><td>H1 1.5B-d</td><td>66</td><td>1280</td><td>6</td><td>2</td><td>24</td><td>128 / 64</td><td>256</td><td>128K</td></tr><tr><td>H1 3B</td><td>32</td><td>2560</td><td>10</td><td>2</td><td>32</td><td>128 / 128</td><td>256</td><td>128K</td></tr><tr><td>H1 7B</td><td>44</td><td>3072</td><td>12</td><td>2</td><td>24</td><td>128 / 128</td><td>256</td><td>256K</td></tr><tr><td>H1 34B</td><td>72</td><td>5120</td><td>20</td><td>4</td><td>32</td><td>128 / 128</td><td>256</td><td>256K</td></tr></tbody></table> <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 FalconH1Model. It is used to instantiate a Falcon H1 | |
| 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/tiiuae/Falcon-H1-1.5B-Deep-Instruct" rel="nofollow">tiiuae/Falcon-H1-1.5B-Deep-Instruct</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_49551/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_49551/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 Falcon H1 Model for causal language modeling.</p> <p>This model inherits from <a href="/docs/transformers/pr_49551/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_49551/en/model_doc/falcon_h1#transformers.FalconH1ForCausalLM">FalconH1ForCausalLM</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>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_49551/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> <p>This HF implementation is contributed by <a href="https://github.com/younesbelkada" rel="nofollow">younesbelkada</a> and <a href="https://github.com/dhiaEddineRhaiem" rel="nofollow">DhiaEddineRhaiem</a>.</p> <!> <p></p>`,1);function ee(x,N){V(N,!1),B(()=>{new URLSearchParams(window.location.search).get("fw")}),I();var p=Q();Z("12xqqut",o=>{var n=E();R(n,"content",X),s(o,n)});var h=e(C(p),4);W(h,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var u=e(h,2);t(u,{title:"FalconH1",local:"falconh1",headingTag:"h1"});var f=e(u,2);t(f,{title:"Overview",local:"overview",headingTag:"h2"});var _=e(f,4);t(_,{title:"Contributors",local:"contributors",headingTag:"h2"});var g=e(_,4);t(g,{title:"Notes",local:"notes",headingTag:"h2"});var b=e(g,4);t(b,{title:"FalconH1Config",local:"transformers.FalconH1Config",headingTag:"h2"});var i=e(b,4),z=c(i);d(z,{name:"class transformers.FalconH1Config",anchor:"transformers.FalconH1Config",source:"https://github.com/huggingface/transformers/blob/vr_49551/src/transformers/models/falcon_h1/configuration_falcon_h1.py#L25",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 = 128000"},{name:"tie_word_embeddings",val:": bool = False"},{name:"hidden_size",val:": int = 4096"},{name:"intermediate_size",val:": int = 14336"},{name:"num_hidden_layers",val:": int = 32"},{name:"num_attention_heads",val:": int = 32"},{name:"num_key_value_heads",val:": int | None = 8"},{name:"hidden_act",val:": str = 'silu'"},{name:"initializer_range",val:": float = 0.02"},{name:"rms_norm_eps",val:": float = 1e-05"},{name:"use_cache",val:": bool | None = True"},{name:"num_logits_to_keep",val:": int | None = 1"},{name:"pad_token_id",val:": int | None = 0"},{name:"bos_token_id",val:": int | None = 1"},{name:"eos_token_id",val:": int | list[int] | None = 2"},{name:"max_position_embeddings",val:": int = 8192"},{name:"attention_dropout",val:": float | int | None = 0.0"},{name:"mamba_d_ssm",val:": int | None = 1024"},{name:"mamba_n_heads",val:": int | None = 128"},{name:"mamba_d_head",val:": str | int | None = 'auto'"},{name:"mamba_n_groups",val:": int | None = 1"},{name:"mamba_d_state",val:": int | None = 256"},{name:"mamba_d_conv",val:": int | None = 4"},{name:"mamba_expand",val:": int | None = 2"},{name:"mamba_chunk_size",val:": int | None = 256"},{name:"mamba_conv_bias",val:": bool | None = True"},{name:"mamba_proj_bias",val:": bool | None = False"},{name:"mamba_norm_before_gate",val:": bool | None = True"},{name:"mamba_rms_norm",val:": bool | None = False"},{name:"time_step_limit",val:": list[float, float] | tuple[float, float] | None = (0.0, inf)"},{name:"projectors_bias",val:": bool | None = False"},{name:"rope_parameters",val:": transformers.modeling_rope_utils.RopeParameters | dict | None = None"},{name:"lm_head_multiplier",val:": float | None = 1.0"},{name:"embedding_multiplier",val:": float | None = 1.0"},{name:"mlp_multipliers",val:": list[float] | None = None"},{name:"key_multiplier",val:": float | None = 1.0"},{name:"attention_out_multiplier",val:": float | None = 1.0"},{name:"attention_in_multiplier",val:": float | None = 1.0"},{name:"ssm_multipliers",val:": list[float] | None = None"},{name:"ssm_in_multiplier",val:": float | None = 1.0"},{name:"ssm_out_multiplier",val:": float | None = 1.0"},{name:"attention_bias",val:": bool = False"},{name:"mlp_bias",val:": bool = False"}],parametersDescription:[{anchor:"transformers.FalconH1Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>128000</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.FalconH1Config.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.FalconH1Config.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.FalconH1Config.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>14336</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.FalconH1Config.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.FalconH1Config.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.FalconH1Config.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8</code>) — | |
| 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.FalconH1Config.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.FalconH1Config.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.FalconH1Config.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-05</code>) — | |
| The epsilon used by the rms normalization layers.`,name:"rms_norm_eps"},{anchor:"transformers.FalconH1Config.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.FalconH1Config.num_logits_to_keep",description:`<strong>num_logits_to_keep</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to 1) — | |
| Number of prompt logits to calculate during generation. If <code>None</code>, all logits will be calculated. If an | |
| integer value, only last <code>num_logits_to_keep</code> logits will be calculated. Default is 1 because only the | |
| logits of the last prompt token are needed for generation. For long sequences, the logits for the entire | |
| sequence may use a lot of memory so, setting <code>num_logits_to_keep=1</code> will reduce memory footprint | |
| significantly.`,name:"num_logits_to_keep"},{anchor:"transformers.FalconH1Config.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.FalconH1Config.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.FalconH1Config.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.FalconH1Config.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8192</code>) — | |
| The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.FalconH1Config.attention_dropout",description:`<strong>attention_dropout</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.FalconH1Config.mamba_d_ssm",description:`<strong>mamba_d_ssm</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1024</code>) — | |
| Inner state size of the SSM (state-space model) in the Mamba layers of FalconH1.`,name:"mamba_d_ssm"},{anchor:"transformers.FalconH1Config.mamba_n_heads",description:`<strong>mamba_n_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>128</code>) — | |
| The number of mamba heads used in the v2 implementation.`,name:"mamba_n_heads"},{anchor:"transformers.FalconH1Config.mamba_d_head",description:`<strong>mamba_d_head</strong> (<code>Union[str, int]</code>, <em>optional</em>, defaults to <code>auto</code>) — | |
| Head embedding dimension size`,name:"mamba_d_head"},{anchor:"transformers.FalconH1Config.mamba_n_groups",description:`<strong>mamba_n_groups</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| The number of the mamba groups used in the v2 implementation.`,name:"mamba_n_groups"},{anchor:"transformers.FalconH1Config.mamba_d_state",description:`<strong>mamba_d_state</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) — | |
| Size of the SSM state (latent state dimension) in the Mamba layers.`,name:"mamba_d_state"},{anchor:"transformers.FalconH1Config.mamba_d_conv",description:`<strong>mamba_d_conv</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4</code>) — | |
| The size of the mamba convolution kernel`,name:"mamba_d_conv"},{anchor:"transformers.FalconH1Config.mamba_expand",description:`<strong>mamba_expand</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| Expanding factor (relative to hidden_size) used to determine the mamba intermediate size`,name:"mamba_expand"},{anchor:"transformers.FalconH1Config.mamba_chunk_size",description:`<strong>mamba_chunk_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) — | |
| The chunks in which to break the sequence when doing prefill/training`,name:"mamba_chunk_size"},{anchor:"transformers.FalconH1Config.mamba_conv_bias",description:`<strong>mamba_conv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Flag indicating whether or not to use bias in the convolution layer of the mamba mixer block.`,name:"mamba_conv_bias"},{anchor:"transformers.FalconH1Config.mamba_proj_bias",description:`<strong>mamba_proj_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Flag indicating whether or not to use bias in the input and output projections ([“in_proj”, “out_proj”]) of the mamba mixer block`,name:"mamba_proj_bias"},{anchor:"transformers.FalconH1Config.mamba_norm_before_gate",description:`<strong>mamba_norm_before_gate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to apply normalization before the gating mechanism in the Mamba mixer.`,name:"mamba_norm_before_gate"},{anchor:"transformers.FalconH1Config.mamba_rms_norm",description:`<strong>mamba_rms_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use RMS normalization in the Mamba layers (as opposed to standard LayerNorm).`,name:"mamba_rms_norm"},{anchor:"transformers.FalconH1Config.time_step_limit",description:`<strong>time_step_limit</strong> (<code>Union[list[float, float], tuple[float, float]]</code>, <em>optional</em>, defaults to <code>(0.0, inf)</code>) — | |
| Accepted range of time step values for clamping.`,name:"time_step_limit"},{anchor:"transformers.FalconH1Config.projectors_bias",description:`<strong>projectors_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Flag indicating whether or not to use bias in the input and output projections ([“in_proj”, “out_proj”]) of the attention block`,name:"projectors_bias"},{anchor:"transformers.FalconH1Config.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.FalconH1Config.lm_head_multiplier",description:`<strong>lm_head_multiplier</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) — | |
| The multiplier for the LM head. This is used to scale the output of the LM head.`,name:"lm_head_multiplier"},{anchor:"transformers.FalconH1Config.embedding_multiplier",description:`<strong>embedding_multiplier</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) — | |
| The multiplier for the embedding layer. This is used to scale the output of the embedding layer.`,name:"embedding_multiplier"},{anchor:"transformers.FalconH1Config.mlp_multipliers",description:`<strong>mlp_multipliers</strong> (<code>list[float]</code>, <em>optional</em>) — | |
| The multipliers for the MLP layers. This is used to scale the output of the MLP layers. The first value is | |
| the multiplier of gate layer, the second value is the multiplier of the down_proj layer.`,name:"mlp_multipliers"},{anchor:"transformers.FalconH1Config.key_multiplier",description:`<strong>key_multiplier</strong> (<code>float</code>, <em>optional</em>) — | |
| The multiplier for the key layer. This is used to scale the output of the key layer.`,name:"key_multiplier"},{anchor:"transformers.FalconH1Config.attention_out_multiplier",description:`<strong>attention_out_multiplier</strong> (<code>float</code>, <em>optional</em>) — | |
| The multiplier for the attention output layer. This is used to scale the output of the attention output`,name:"attention_out_multiplier"},{anchor:"transformers.FalconH1Config.attention_in_multiplier",description:`<strong>attention_in_multiplier</strong> (<code>float</code>, <em>optional</em>) — | |
| The multiplier for the attention input layer. This is used to scale the output of the attention input layer.`,name:"attention_in_multiplier"},{anchor:"transformers.FalconH1Config.ssm_multipliers",description:`<strong>ssm_multipliers</strong> (<code>list[float]</code>, <em>optional</em>) — | |
| The multipliers for the SSM layers. This is used to scale the output of the SSM layers.`,name:"ssm_multipliers"},{anchor:"transformers.FalconH1Config.ssm_in_multiplier",description:`<strong>ssm_in_multiplier</strong> (<code>float</code>, <em>optional</em>) — | |
| The multiplier for the SSM input layer. This is used to scale the output of the SSM input layer.`,name:"ssm_in_multiplier"},{anchor:"transformers.FalconH1Config.ssm_out_multiplier",description:`<strong>ssm_out_multiplier</strong> (<code>float</code>, <em>optional</em>) — | |
| The multiplier for the SSM output layer. This is used to scale the output of the SSM output layer.`,name:"ssm_out_multiplier"},{anchor:"transformers.FalconH1Config.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.FalconH1Config.mlp_bias",description:`<strong>mlp_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.`,name:"mlp_bias"}]}),H(4),m(i);var y=e(i,2);t(y,{title:"FalconH1ForCausalLM",local:"transformers.FalconH1ForCausalLM",headingTag:"h2"});var v=e(y,2);M(v,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnRpaXVhZSUyRkZhbGNvbi1IMS03Qi1JbnN0cnVjdCUyMiUyQyUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnRpaXVhZSUyRkZhbGNvbi1IMS03Qi1JbnN0cnVjdCUyMiklMEElMEFtZXNzYWdlJTIwJTNEJTIwJTVCJTIyTWFtYmElMjBpcyUyMGElMjBzbmFrZSUyMHdpdGglMjBmb2xsb3dpbmclMjBwcm9wZXJ0aWVzJTIwJTIwJTIyJTVEJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKG1lc3NhZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCdwdCclMkMlMjByZXR1cm5fdG9rZW5fdHlwZV9pZHMlM0RGYWxzZSkudG8obW9kZWwuZGV2aWNlKSUwQXJlc3BvbnNlJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDY0KSUwQXByaW50KHRva2VuaXplci5iYXRjaF9kZWNvZGUocmVzcG9uc2UlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"tiiuae/Falcon-H1-7B-Instruct"</span>, device_map=<span class="hljs-string">"auto"</span>) | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"tiiuae/Falcon-H1-7B-Instruct"</span>) | |
| message = [<span class="hljs-string">"Mamba is a snake with following properties "</span>] | |
| inputs = tokenizer(message, return_tensors=<span class="hljs-string">'pt'</span>, return_token_type_ids=<span class="hljs-literal">False</span>).to(model.device) | |
| response = model.generate(**inputs, max_new_tokens=<span class="hljs-number">64</span>) | |
| <span class="hljs-built_in">print</span>(tokenizer.batch_decode(response, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>])`,lang:"python",wrap:!1});var l=e(v,2),T=c(l);d(T,{name:"class transformers.FalconH1ForCausalLM",anchor:"transformers.FalconH1ForCausalLM",source:"https://github.com/huggingface/transformers/blob/vr_49551/src/transformers/models/falcon_h1/modeling_falcon_h1.py#L1111",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.FalconH1ForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_49551/en/model_doc/falcon_h1#transformers.FalconH1ForCausalLM">FalconH1ForCausalLM</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_49551/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var k=e(T,8),F=c(k);d(F,{name:"forward",anchor:"transformers.FalconH1ForCausalLM.forward",source:"https://github.com/huggingface/transformers/blob/vr_49551/src/transformers/models/falcon_h1/modeling_falcon_h1.py#L1126",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:"logits_to_keep",val:": typing.Union[int, torch.Tensor] = 0"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FalconH1ForCausalLM.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_49551/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_49551/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_49551/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.FalconH1ForCausalLM.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.FalconH1ForCausalLM.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.FalconH1ForCausalLM.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_49551/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_49551/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.FalconH1ForCausalLM.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.FalconH1ForCausalLM.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.FalconH1ForCausalLM.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.FalconH1ForCausalLM.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 <a | |
| href="/docs/transformers/pr_49551/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast" | |
| >CausalLMOutputWithPast</a> or a tuple of | |
| <code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_49551/en/model_doc/falcon_h1#transformers.FalconH1Config" | |
| >FalconH1Config</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_49551/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast" | |
| >CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `});var w=e(F,4);S(w,{children:(o,n)=>{var a=P();s(o,a)},$$slots:{default:!0}});var j=e(w,4);G(j,{anchor:"transformers.FalconH1ForCausalLM.forward.example",children:(o,n)=>{var a=D(),U=e(C(a),2);M(U,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGYWxjb25IMUZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBGYWxjb25IMUZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjIuLi4lMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyLi4uJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkhleSUyQyUyMGFyZSUyMHlvdSUyMGNvbnNjaW91cyUzRiUyMENhbiUyMHlvdSUyMHRhbGslMjB0byUyMG1lJTNGJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMuaW5wdXRfaWRzJTJDJTIwbWF4X2xlbmd0aCUzRDMwKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjBjbGVhbl91cF90b2tlbml6YXRpb25fc3BhY2VzJTNERmFsc2UpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FalconH1ForCausalLM | |
| <span class="hljs-meta">>>> </span>model = FalconH1ForCausalLM.from_pretrained(<span class="hljs-string">"..."</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"..."</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 conscious, but I can talk to you."</span>`,lang:"python",wrap:!1}),s(o,a)},$$slots:{default:!0}}),m(k),m(l);var J=e(l,4);L(J,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/falcon_h1.md"}),H(2),s(x,p),q()}export{ee as component}; | |
Xet Storage Details
- Size:
- 37.5 kB
- Xet hash:
- 24387426afb3f6e80542bfc5e0aa70ac1f95005abd52eee9bb3708d54569f4c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.