Buckets:
| import"../chunks/DsnmJJEf.js";import{i as H,h as $,C as Q,H as s,D as a,E as Y,s as K,a as P}from"../chunks/CD2rhSaz.js";import{p as ee,o as oe,s as e,f,a as r,b as ne,c as i,d as c,r as d,n as U}from"../chunks/DmjbnfDo.js";import{T as g}from"../chunks/B2suExpn.js";import{E as R}from"../chunks/B5qO6y4i.js";const te='{"title":"DeepSeek-V2","local":"deepseek-v2","sections":[{"title":"Overview","local":"overview","sections":[{"title":"Usage tips","local":"usage-tips","sections":[],"depth":3}],"depth":2},{"title":"DeepseekV2Config","local":"transformers.DeepseekV2Config","sections":[],"depth":2},{"title":"DeepseekV2Model","local":"transformers.DeepseekV2Model","sections":[],"depth":2},{"title":"DeepseekV2ForCausalLM","local":"transformers.DeepseekV2ForCausalLM","sections":[],"depth":2},{"title":"DeepseekV2ForSequenceClassification","local":"transformers.DeepseekV2ForSequenceClassification","sections":[],"depth":2}],"depth":1}';var se=c('<meta name="hf:doc:metadata"/>'),Z=c("<p>Example:</p> <!>",1),_=c(`<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>`),ae=c(`<p></p> <p><em>This model was published in HF papers on 2024-05-07 and contributed to Hugging Face Transformers on 2025-07-09.</em></p> <!> <!> <!> <p>The DeepSeek-V2 model was proposed in <a href="https://huggingface.co/papers/2405.04434" rel="nofollow">DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model</a> by DeepSeek-AI Team.</p> <p>The abstract from the paper is the following: | |
| We present DeepSeek-V2, a strong Mixture-of-Experts (MoE) language model characterized by economical training and efficient inference. It comprises 236B total parameters, of which 21B are activated for each token, and supports a context length of 128K tokens. DeepSeek-V2 adopts innovative architectures including Multi-head Latent Attention (MLA) and DeepSeekMoE. MLA guarantees efficient inference through significantly compressing the Key-Value (KV) cache into a latent vector, while DeepSeekMoE enables training strong models at an economical cost through sparse computation. Compared with DeepSeek 67B, DeepSeek-V2 achieves significantly stronger performance, and meanwhile saves 42.5% of training costs, reduces the KV cache by 93.3%, and boosts the maximum generation throughput to 5.76 times. We pretrain DeepSeek-V2 on a high-quality and multi-source corpus consisting of 8.1T tokens, and further perform Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL) to fully unlock its potential. Evaluation results show that, even with only 21B activated parameters, DeepSeek-V2 and its chat versions still achieve top-tier performance among open-source models.</p> <p>This model was contributed by <a href="https://github.com/VladOS95-cyber" rel="nofollow">VladOS95-cyber</a>. | |
| The original code can be found <a href="https://huggingface.co/deepseek-ai/DeepSeek-V2" rel="nofollow">here</a>.</p> <!> <p>The model uses Multi-head Latent Attention (MLA) and DeepSeekMoE architectures for efficient inference and cost-effective training. It employs an auxiliary-loss-free strategy for load balancing and multi-token prediction training objective. The model can be used for various language tasks after being pre-trained on 14.8 trillion tokens and going through Supervised Fine-Tuning and Reinforcement Learning stages.</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 DeepseekV2Model. It is used to instantiate a Deepseek V2 | |
| 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/deepseek-ai/DeepSeek-V2-Lite" rel="nofollow">deepseek-ai/DeepSeek-V2-Lite</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_48314/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_48314/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 bare Deepseek V2 Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_48314/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_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2Model">DeepseekV2Model</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> <p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p></li> <li><p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_48314/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></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 Deepseek V2 Model for causal language modeling.</p> <p>This model inherits from <a href="/docs/transformers/pr_48314/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_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2ForCausalLM">DeepseekV2ForCausalLM</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_48314/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"><!> <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 <code>GenericForSequenceClassification</code> forward method, overrides the <code>__call__</code> special method.</p> <!></div></div> <!> <p></p>`,1);function pe(J,B){ee(B,!1),oe(()=>{new URLSearchParams(window.location.search).get("fw")}),H();var k=ae();$("exfver",o=>{var t=se();K(t,"content",te),r(o,t)});var b=e(f(k),4);Q(b,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var v=e(b,2);s(v,{title:"DeepSeek-V2",local:"deepseek-v2",headingTag:"h1"});var y=e(v,2);s(y,{title:"Overview",local:"overview",headingTag:"h2"});var T=e(y,8);s(T,{title:"Usage tips",local:"usage-tips",headingTag:"h3"});var w=e(T,4);s(w,{title:"DeepseekV2Config",local:"transformers.DeepseekV2Config",headingTag:"h2"});var l=e(w,2),V=i(l);a(V,{name:"class transformers.DeepseekV2Config",anchor:"transformers.DeepseekV2Config",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/configuration_deepseek_v2.py#L30",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None"},{name:"vocab_size",val:": int = 102400"},{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 = 2048"},{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 = None"},{name:"bos_token_id",val:": int | None = 1"},{name:"eos_token_id",val:": int | list[int] | None = 2"},{name:"pretraining_tp",val:": int | None = 1"},{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:"mlp_bias",val:": bool = False"},{name:"head_dim",val:": int | None = None"},{name:"first_k_dense_replace",val:": int = 0"},{name:"kv_lora_rank",val:": int = 512"},{name:"q_lora_rank",val:": int | None = 1536"},{name:"n_group",val:": int | None = None"},{name:"n_routed_experts",val:": int = 64"},{name:"n_shared_experts",val:": int = 2"},{name:"qk_nope_head_dim",val:": int = 128"},{name:"qk_rope_head_dim",val:": int = 64"},{name:"routed_scaling_factor",val:": float = 1.0"},{name:"topk_group",val:": int | None = None"},{name:"topk_method",val:": str | None = 'greedy'"},{name:"norm_topk_prob",val:": bool | None = False"},{name:"v_head_dim",val:": int = 128"},{name:"num_experts_per_tok",val:": int | None = None"},{name:"moe_intermediate_size",val:": int = 1407"}],parametersDescription:[{anchor:"transformers.DeepseekV2Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>102400</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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2048</code>) — | |
| The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.pretraining_tp",description:`<strong>pretraining_tp</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Experimental feature. Tensor parallelism rank used during pretraining. Please refer to <a href="https://huggingface.co/docs/transformers/main/perf_train_gpu_many#tensor-parallelism" rel="nofollow">this | |
| document</a> to | |
| understand more about it. This value is necessary to ensure exact reproducibility of the pretraining | |
| results. Please refer to <a href="https://github.com/pytorch/pytorch/issues/76232" rel="nofollow">this issue</a>.`,name:"pretraining_tp"},{anchor:"transformers.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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.DeepseekV2Config.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"},{anchor:"transformers.DeepseekV2Config.head_dim",description:`<strong>head_dim</strong> (<code>int</code>, <em>optional</em>) — | |
| The attention head dimension. If None, it will default to hidden_size // num_attention_heads`,name:"head_dim"},{anchor:"transformers.DeepseekV2Config.first_k_dense_replace",description:`<strong>first_k_dense_replace</strong> (<code>int</code>, <em>optional</em>, defaults to 0) — | |
| Number of dense layers in the shallow layers before switching to MoE layers.`,name:"first_k_dense_replace"},{anchor:"transformers.DeepseekV2Config.kv_lora_rank",description:`<strong>kv_lora_rank</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) — | |
| Rank of the LoRA matrices for key and value projections.`,name:"kv_lora_rank"},{anchor:"transformers.DeepseekV2Config.q_lora_rank",description:`<strong>q_lora_rank</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1536</code>) — | |
| Rank of the LoRA matrices for query projections.`,name:"q_lora_rank"},{anchor:"transformers.DeepseekV2Config.n_group",description:`<strong>n_group</strong> (<code>int</code>, <em>optional</em>) — | |
| Number of groups for routed experts.`,name:"n_group"},{anchor:"transformers.DeepseekV2Config.n_routed_experts",description:`<strong>n_routed_experts</strong> (<code>int</code>, <em>optional</em>, defaults to <code>64</code>) — | |
| Number of routed experts.`,name:"n_routed_experts"},{anchor:"transformers.DeepseekV2Config.n_shared_experts",description:`<strong>n_shared_experts</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| Number of shared experts.`,name:"n_shared_experts"},{anchor:"transformers.DeepseekV2Config.qk_nope_head_dim",description:`<strong>qk_nope_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>128</code>) — | |
| Dimension of the query/key heads that don’t use rotary position embeddings.`,name:"qk_nope_head_dim"},{anchor:"transformers.DeepseekV2Config.qk_rope_head_dim",description:`<strong>qk_rope_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>64</code>) — | |
| Dimension of the query/key heads that use rotary position embeddings.`,name:"qk_rope_head_dim"},{anchor:"transformers.DeepseekV2Config.routed_scaling_factor",description:`<strong>routed_scaling_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) — | |
| Scaling factor or routed experts.`,name:"routed_scaling_factor"},{anchor:"transformers.DeepseekV2Config.topk_group",description:`<strong>topk_group</strong> (<code>int</code>, <em>optional</em>) — | |
| Number of selected groups for each token (for each token, ensuring the selected experts is only within <code>topk_group</code> groups).`,name:"topk_group"},{anchor:"transformers.DeepseekV2Config.topk_method",description:`<strong>topk_method</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"greedy"</code>) — | |
| The method used for selecting top-k experts in the routed gate mechanism.`,name:"topk_method"},{anchor:"transformers.DeepseekV2Config.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"},{anchor:"transformers.DeepseekV2Config.v_head_dim",description:`<strong>v_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>128</code>) — | |
| Dimension of the value heads.`,name:"v_head_dim"},{anchor:"transformers.DeepseekV2Config.num_experts_per_tok",description:`<strong>num_experts_per_tok</strong> (<code>int</code>, <em>optional</em>) — | |
| 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.DeepseekV2Config.moe_intermediate_size",description:`<strong>moe_intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1407</code>) — | |
| Intermediate size of the routed expert MLPs.`,name:"moe_intermediate_size"}]});var E=e(V,6);R(E,{anchor:"transformers.DeepseekV2Config.example",children:(o,t)=>{var n=Z(),u=e(f(n),2);P(u,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZXBzZWVrVjJNb2RlbCUyQyUyMERlZXBzZWVrVjJDb25maWclMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwRGVlcFNlZWstVjIlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwRGVlcHNlZWtWMkNvbmZpZygpJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBEZWVwc2Vla1YyTW9kZWwoY29uZmlndXJhdGlvbiklMEFwcmludChtb2RlbC5jb25maWcp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DeepseekV2Model, DeepseekV2Config | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a DeepSeek-V2 style configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = DeepseekV2Config() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>model = DeepseekV2Model(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">print</span>(model.config)`,lang:"python",wrap:!1}),r(o,n)},$$slots:{default:!0}}),d(l);var D=e(l,2);s(D,{title:"DeepseekV2Model",local:"transformers.DeepseekV2Model",headingTag:"h2"});var p=e(D,2),M=i(p);a(M,{name:"class transformers.DeepseekV2Model",anchor:"transformers.DeepseekV2Model",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/modeling_deepseek_v2.py#L502",parameters:[{name:"config",val:": DeepseekV2Config"}],parametersDescription:[{anchor:"transformers.DeepseekV2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2Config">DeepseekV2Config</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_48314/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var C=e(M,8),x=i(C);a(x,{name:"forward",anchor:"transformers.DeepseekV2Model.forward",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/modeling_deepseek_v2.py#L519",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:": Unpack"}],parametersDescription:[{anchor:"transformers.DeepseekV2Model.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_48314/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_48314/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_48314/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.DeepseekV2Model.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.DeepseekV2Model.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.DeepseekV2Model.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_48314/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_48314/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.DeepseekV2Model.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.DeepseekV2Model.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 <a | |
| href="/docs/transformers/pr_48314/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</a> or a tuple of | |
| <code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2Config" | |
| >DeepseekV2Config</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_48314/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `});var A=e(x,4);g(A,{children:(o,t)=>{var n=_();r(o,n)},$$slots:{default:!0}}),U(2),d(C),d(p);var z=e(p,2);s(z,{title:"DeepseekV2ForCausalLM",local:"transformers.DeepseekV2ForCausalLM",headingTag:"h2"});var m=e(z,2),F=i(m);a(F,{name:"class transformers.DeepseekV2ForCausalLM",anchor:"transformers.DeepseekV2ForCausalLM",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/modeling_deepseek_v2.py#L576",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.DeepseekV2ForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2ForCausalLM">DeepseekV2ForCausalLM</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_48314/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var q=e(F,8),N=i(q);a(N,{name:"forward",anchor:"transformers.DeepseekV2ForCausalLM.forward",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/modeling_deepseek_v2.py#L591",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:": Unpack"}],parametersDescription:[{anchor:"transformers.DeepseekV2ForCausalLM.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_48314/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_48314/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_48314/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.DeepseekV2ForCausalLM.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.DeepseekV2ForCausalLM.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.DeepseekV2ForCausalLM.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_48314/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_48314/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.DeepseekV2ForCausalLM.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.DeepseekV2ForCausalLM.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.DeepseekV2ForCausalLM.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.DeepseekV2ForCausalLM.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_48314/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_48314/en/model_doc/deepseek_v2#transformers.DeepseekV2Config" | |
| >DeepseekV2Config</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_48314/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast" | |
| >CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `});var W=e(N,4);g(W,{children:(o,t)=>{var n=_();r(o,n)},$$slots:{default:!0}});var O=e(W,4);R(O,{anchor:"transformers.DeepseekV2ForCausalLM.forward.example",children:(o,t)=>{var n=Z(),u=e(f(n),2);P(u,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBEZWVwc2Vla1YyRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMERlZXBzZWVrVjJGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIybWV0YS1kZWVwc2Vla192MiUyRkRlZXBzZWVrVjItMi03Yi1oZiUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtZXRhLWRlZXBzZWVrX3YyJTJGRGVlcHNlZWtWMi0yLTdiLWhmJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkhleSUyQyUyMGFyZSUyMHlvdSUyMGNvbnNjaW91cyUzRiUyMENhbiUyMHlvdSUyMHRhbGslMjB0byUyMG1lJTNGJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwR2VuZXJhdGUlMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMuaW5wdXRfaWRzJTJDJTIwbWF4X2xlbmd0aCUzRDMwKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjBjbGVhbl91cF90b2tlbml6YXRpb25fc3BhY2VzJTNERmFsc2UpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, DeepseekV2ForCausalLM | |
| <span class="hljs-meta">>>> </span>model = DeepseekV2ForCausalLM.from_pretrained(<span class="hljs-string">"meta-deepseek_v2/DeepseekV2-2-7b-hf"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"meta-deepseek_v2/DeepseekV2-2-7b-hf"</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}),r(o,n)},$$slots:{default:!0}}),d(q),d(m);var L=e(m,2);s(L,{title:"DeepseekV2ForSequenceClassification",local:"transformers.DeepseekV2ForSequenceClassification",headingTag:"h2"});var h=e(L,2),j=i(h);a(j,{name:"class transformers.DeepseekV2ForSequenceClassification",anchor:"transformers.DeepseekV2ForSequenceClassification",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/models/deepseek_v2/modeling_deepseek_v2.py#L650",parameters:[{name:"config",val:""}]});var I=e(j,2),S=i(I);a(S,{name:"forward",anchor:"transformers.DeepseekV2ForSequenceClassification.forward",source:"https://github.com/huggingface/transformers/blob/vr_48314/src/transformers/modeling_layers.py#L131",parameters:[{name:"input_ids",val:": torch.LongTensor | None = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"position_ids",val:": torch.LongTensor | None = None"},{name:"past_key_values",val:": Cache | None = None"},{name:"inputs_embeds",val:": torch.FloatTensor | None = None"},{name:"labels",val:": torch.LongTensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"**kwargs",val:": Unpack[TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.DeepseekV2ForSequenceClassification.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_48314/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_48314/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_48314/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.DeepseekV2ForSequenceClassification.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.DeepseekV2ForSequenceClassification.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.DeepseekV2ForSequenceClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>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_48314/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_48314/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.DeepseekV2ForSequenceClassification.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.DeepseekV2ForSequenceClassification.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.DeepseekV2ForSequenceClassification.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"}],returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>SequenceClassifierOutputWithPast</code></p> | |
| `});var G=e(S,4);g(G,{children:(o,t)=>{var n=_();r(o,n)},$$slots:{default:!0}}),d(I),d(h);var X=e(h,2);Y(X,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/deepseek_v2.md"}),U(2),r(J,k),ne()}export{pe as component}; | |
Xet Storage Details
- Size:
- 50.5 kB
- Xet hash:
- 837e5ddd777a9738f9e0894882e0200f7241e5a54b85cc763e7c212762dee2ca
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.