Aluode/PerceptionLabPortable
0
1# coding=utf-82# Copyright 2025 MiniMaxAI and HuggingFace Inc. teams. All rights reserved.3#4#5# Licensed under the Apache License, Version 2.0 (the "License");6# you may not use this file except in compliance with the License.7# You may obtain a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing, software12# distributed under the License is distributed on an "AS IS" BASIS,13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14# See the License for the specific language governing permissions and15# limitations under the License.16"""PyTorch MiniMax model."""17 18from typing import Optional19 20import torch21import torch.nn.functional as F22from torch import nn23 24from ...activations import ACT2FN25from ...cache_utils import Cache, DynamicCache26from ...configuration_utils import layer_type_validation27from ...masking_utils import create_causal_mask, create_sliding_window_causal_mask28from ...modeling_flash_attention_utils import FlashAttentionKwargs29from ...modeling_layers import GradientCheckpointingLayer30from ...modeling_outputs import MoeModelOutputWithPast31from ...processing_utils import Unpack32from ...utils import TransformersKwargs, logging33from ...utils.deprecation import deprecate_kwarg34from ...utils.generic import OutputRecorder, check_model_inputs35from ..mixtral.configuration_mixtral import MixtralConfig36from ..mixtral.modeling_mixtral import (37 MixtralAttention,38 MixtralDecoderLayer,39 MixtralForCausalLM,40 MixtralForQuestionAnswering,41 MixtralForSequenceClassification,42 MixtralForTokenClassification,43 MixtralModel,44 MixtralPreTrainedModel,45 MixtralRMSNorm,46 MixtralSparseMoeBlock,47)48 49 50logger = logging.get_logger(__name__)51 52 53class MiniMaxConfig(MixtralConfig):54 r"""55 This is the configuration class to store the configuration of a [`MiniMaxModel`]. It is used to instantiate an56 MiniMax model according to the specified arguments, defining the model architecture. Instantiating a configuration57 with the defaults will yield a similar configuration to that of the MiniMax.58 59 [MiniMaxAI/MiniMax-Text-01-hf](https://huggingface.co/MiniMaxAI/MiniMax-Text-01-hf)60 61 Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the62 documentation from [`PretrainedConfig`] for more information.63 64 65 Args:66 vocab_size (`int`, *optional*, defaults to 32000):67 Vocabulary size of the MiniMax model. Defines the number of different tokens that can be represented by the68 `inputs_ids` passed when calling [`MiniMaxModel`]69 hidden_size (`int`, *optional*, defaults to 4096):70 Dimension of the hidden representations.71 intermediate_size (`int`, *optional*, defaults to 14336):72 Dimension of the MLP representations.73 num_hidden_layers (`int`, *optional*, defaults to 32):74 Number of hidden layers in the Transformer encoder.75 num_attention_heads (`int`, *optional*, defaults to 32):76 Number of attention heads for each attention layer in the Transformer encoder.77 num_key_value_heads (`int`, *optional*, defaults to 8):78 This is the number of key_value heads that should be used to implement Grouped Query Attention. If79 `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if80 `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When81 converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed82 by meanpooling all the original heads within that group. For more details, check out [this83 paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `8`.84 head_dim (`int`, *optional*, defaults to `hidden_size // num_attention_heads`):85 The attention head dimension.86 hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):87 The non-linear activation function (function or string) in the decoder.88 max_position_embeddings (`int`, *optional*, defaults to `4096*32`):89 The maximum sequence length that this model might ever be used with. MiniMax's sliding window attention90 allows sequence of up to 4096*32 tokens.91 initializer_range (`float`, *optional*, defaults to 0.02):92 The standard deviation of the truncated_normal_initializer for initializing all weight matrices.93 rms_norm_eps (`float`, *optional*, defaults to 1e-05):94 The epsilon used by the rms normalization layers.95 use_cache (`bool`, *optional*, defaults to `True`):96 Whether or not the model should return the last key/values attentions (not used by all models). Only97 relevant if `config.is_decoder=True`.98 pad_token_id (`int`, *optional*):99 The id of the padding token.100 bos_token_id (`int`, *optional*, defaults to 1):101 The id of the "beginning-of-sequence" token.102 eos_token_id (`int`, *optional*, defaults to 2):103 The id of the "end-of-sequence" token.104 tie_word_embeddings (`bool`, *optional*, defaults to `False`):105 Whether the model's input and output word embeddings should be tied.106 rope_theta (`float`, *optional*, defaults to 1000000.0):107 The base period of the RoPE embeddings.108 sliding_window (`int`, *optional*):109 Sliding window attention window size. If not specified, will default to `4096`.110 attention_dropout (`float`, *optional*, defaults to 0.0):111 The dropout ratio for the attention probabilities.112 num_experts_per_tok (`int`, *optional*, defaults to 2):113 The number of experts to route per-token, can be also interpreted as the `top-k` routing114 parameter115 num_local_experts (`int`, *optional*, defaults to 8):116 Number of experts per Sparse MLP layer.117 output_router_logits (`bool`, *optional*, defaults to `False`):118 Whether or not the router logits should be returned by the model. Enabling this will also119 allow the model to output the auxiliary loss. See [here]() for more details120 router_aux_loss_coef (`float`, *optional*, defaults to 0.001):121 The aux loss factor for the total loss.122 router_jitter_noise (`float`, *optional*, defaults to 0.0):123 Amount of noise to add to the router.124 layer_types (`list`, *optional*):125 Attention pattern for each layer.126 block_size (`int`, *optional*, defaults to 256):127 The length of each attention block, determining how queries, keys, and values128 are grouped and processed for intra- and inter-block attention.129 full_attn_alpha_factor (`float`, *optional*, defaults to 1):130 Weight for residual value in residual connection after normal attention.131 full_attn_beta_factor (`float`, *optional*, defaults to 1):132 Weight for hidden state value in residual connection after normal attention.133 linear_attn_alpha_factor (`float`, *optional*, defaults to 1):134 Weight for residual value in residual connection after lightning attention.135 linear_attn_beta_factor (`float`, *optional*, defaults to 1):136 Weight for hidden state value in residual connection after lightning attention.137 mlp_alpha_factor (`float`, *optional*, defaults to 1):138 Weight for residual value in residual connection after MLP.139 mlp_beta_factor (`float`, *optional*, defaults to 1):140 Weight for hidden state value in residual connection after MLP.141 142 ```python143 >>> from transformers import MiniMaxModel, MiniMaxConfig144 145 >>> # Initializing a MiniMax style configuration146 >>> configuration = MiniMaxConfig()147 148 >>> # Initializing a model from the MiniMax style configuration149 >>> model = MiniMaxModel(configuration)150 151 >>> # Accessing the model configuration152 >>> configuration = model.config153 ```"""154 155 def __init__(156 self,157 layer_types=None,158 block_size=256,159 full_attn_alpha_factor=1,160 full_attn_beta_factor=1,161 linear_attn_alpha_factor=1,162 linear_attn_beta_factor=1,163 mlp_alpha_factor=1,164 mlp_beta_factor=1,165 **super_kwargs,166 ):167 super().__init__(**super_kwargs)168 self.layer_types = layer_types169 self.block_size = block_size170 self.full_attn_alpha_factor = full_attn_alpha_factor171 self.full_attn_beta_factor = full_attn_beta_factor172 self.linear_attn_alpha_factor = linear_attn_alpha_factor173 self.linear_attn_beta_factor = linear_attn_beta_factor174 self.mlp_alpha_factor = mlp_alpha_factor175 self.mlp_beta_factor = mlp_beta_factor176 177 if self.layer_types is None:178 self.layer_types = [179 "full_attention" if bool((i + 1) % 2) else "linear_attention" for i in range(self.num_hidden_layers)180 ]181 layer_type_validation(self.layer_types, self.num_hidden_layers)182 183 184class MiniMaxRMSNorm(MixtralRMSNorm):185 pass186 187 188class MiniMaxCache(DynamicCache):189 def __init__(self):190 super().__init__()191 self.linear_cache: list[torch.Tensor] = []192 193 def set_linear_cache(self, layer_idx, linear_cache):194 # There may be skipped layers, fill them with empty lists195 for _ in range(len(self.linear_cache), layer_idx + 1):196 self.linear_cache.append([])197 self.linear_cache[layer_idx] = linear_cache198 199 def get_linear_cache(self, layer_idx: int):200 if layer_idx < len(self):201 return self.linear_cache[layer_idx]202 return None203 204 def __len__(self):205 return max(super().__len__(), len(self.linear_cache))206 207 def __getitem__(self, layer_idx: int):208 if layer_idx < len(self.linear_cache) and self.linear_cache[layer_idx] != []:209 return (self.linear_cache[layer_idx],)210 return super().__getitem__(layer_idx)211 212 def __iter__(self):213 for layer_idx in range(len(self)):214 yield self[layer_idx]215 216 def batch_repeat_interleave(self, repeats: int):217 for layer_idx in range(len(self)):218 if self.linear_cache[layer_idx] != []:219 self.linear_cache[layer_idx] = self.linear_cache[layer_idx].repeat_interleave(repeats, dim=0)220 else:221 self.layers[layer_idx].batch_repeat_interleave(repeats)222 223 def batch_select_indices(self, indices: torch.Tensor):224 for layer_idx in range(len(self)):225 if self.linear_cache[layer_idx] != []:226 self.linear_cache[layer_idx] = self.linear_cache[layer_idx][indices, ...]227 else:228 self.layers[layer_idx].batch_select_indices(indices)229 230 def crop(self, max_length: int):231 raise RuntimeError("MiniMaxCache doesnot support `crop` method")232 233 234class MiniMaxLightningAttention(nn.Module):235 def __init__(self, config: MiniMaxConfig, layer_idx: int):236 super().__init__()237 self.layer_idx = layer_idx238 self.head_dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads239 self.num_attention_heads = config.num_attention_heads240 self.num_hidden_layers = config.num_hidden_layers241 self.block_size = config.block_size242 243 self.act_fn = ACT2FN[config.hidden_act]244 self.norm = MiniMaxRMSNorm(self.head_dim * self.num_attention_heads)245 self.qkv_proj = nn.Linear(config.hidden_size, self.num_attention_heads * self.head_dim * 3, bias=False)246 self.out_proj = nn.Linear(self.num_attention_heads * self.head_dim, config.hidden_size, bias=False)247 self.output_gate = nn.Linear(config.hidden_size, self.num_attention_heads * self.head_dim, bias=False)248 249 slope_rate = self.get_slope_rate()250 query_decay, key_decay, diagonal_decay = self.decay_factors(slope_rate)251 252 self.register_buffer("slope_rate", slope_rate)253 self.register_buffer("query_decay", query_decay)254 self.register_buffer("key_decay", key_decay)255 self.register_buffer("diagonal_decay", diagonal_decay)256 257 def get_slope_rate(self):258 base = 1 / (2 ** (8 / self.num_attention_heads))259 exponent = torch.arange(self.num_attention_heads) + 1260 factor = 1 - self.layer_idx / (self.num_hidden_layers - 1 + 1e-5) + 1e-5261 262 rate = base**exponent263 rate = rate * factor264 rate = rate[:, None, None]265 266 return rate267 268 def decay_factors(self, slope_rate):269 block_size_range = torch.arange(self.block_size) + 1270 271 query_decay = torch.exp(-slope_rate * block_size_range[:, None])272 key_decay = torch.exp(-slope_rate * (self.block_size - block_size_range[:, None]))273 274 diagonal_decay = block_size_range[:, None] - block_size_range[None, :]275 diagonal_decay = diagonal_decay[None, None, :, :]276 diagonal_decay = slope_rate * diagonal_decay277 diagonal_decay = torch.where(diagonal_decay >= 0, -diagonal_decay, float("-inf"))278 diagonal_decay = torch.exp(diagonal_decay)279 280 return query_decay, key_decay, diagonal_decay281 282 @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")283 def forward(284 self,285 hidden_states: torch.Tensor,286 position_embeddings: tuple[torch.Tensor, torch.Tensor],287 attention_mask: Optional[torch.Tensor],288 past_key_values: Optional[Cache] = None,289 cache_position: Optional[torch.LongTensor] = None,290 **kwargs: Unpack[FlashAttentionKwargs],291 ) -> tuple[torch.Tensor, Optional[torch.Tensor], Optional[tuple[torch.Tensor]]]:292 batch_size, seq_len, hidden_size = hidden_states.shape293 num_blocks = (seq_len + self.block_size - 1) // self.block_size294 295 qkv_states = self.act_fn(self.qkv_proj(hidden_states))296 qkv_states = qkv_states.reshape(batch_size, seq_len, self.num_attention_heads, 3 * self.head_dim)297 298 query_states, key_states, value_states = torch.split(qkv_states, self.head_dim, dim=3)299 300 query_states = query_states.transpose(1, 2)301 key_states = key_states.transpose(1, 2)302 value_states = value_states.transpose(1, 2)303 304 # calculated (K.T @ V) and saved as cache305 attn_weights_inter = None306 if past_key_values is not None:307 attn_weights_inter = past_key_values.get_linear_cache(self.layer_idx)308 309 if attn_weights_inter is None:310 attn_weights_inter = torch.zeros(batch_size, self.num_attention_heads, self.head_dim, self.head_dim).to(311 value_states312 )313 314 # apply attention_mask315 if attention_mask is not None:316 attention_mask = attention_mask.to(dtype=torch.bool) # Ensure it's a boolean tensor317 value_states = value_states.masked_fill(~attention_mask.unsqueeze(1).unsqueeze(-1), 0)318 319 attn_output = []320 for i in range(num_blocks):321 start_idx = i * self.block_size322 end_idx = min(start_idx + self.block_size, seq_len)323 current_block_size = end_idx - start_idx324 325 current_query_states = query_states[:, :, start_idx:end_idx]326 current_key_states = key_states[:, :, start_idx:end_idx]327 current_value_states = value_states[:, :, start_idx:end_idx]328 329 current_query_decay = self.query_decay[:, :current_block_size]330 current_key_decay = self.key_decay[:, -current_block_size:]331 current_diagonal_decay = self.diagonal_decay[:, :, :current_block_size, :current_block_size]332 block_decay = torch.exp(-self.slope_rate * current_block_size)333 334 # intra: ( Q @ K.T ) @ V -> QK * V335 attn_weights_intra = torch.matmul(current_query_states, current_key_states.transpose(-1, -2))336 attn_output_intra = torch.matmul(attn_weights_intra * current_diagonal_decay, current_value_states)337 338 # inter: Q @ ( K.T @ V ) -> Q * KV339 attn_output_inter = torch.matmul(current_query_states * current_query_decay, attn_weights_inter)340 341 # final attention output342 current_attn_output = attn_output_inter + attn_output_intra343 attn_output.append(current_attn_output)344 345 # calculate attn_weights_inter for next block or cache346 next_attn_weights_inter = torch.matmul(347 (current_key_states * current_key_decay).transpose(-1, -2), current_value_states348 )349 attn_weights_inter = attn_weights_inter * block_decay + next_attn_weights_inter350 351 else:352 ratio = torch.exp(-self.slope_rate)353 attn_output = []354 for i in range(seq_len):355 current_query_states = query_states[:, :, i : i + 1]356 current_key_states = key_states[:, :, i : i + 1]357 current_value_states = value_states[:, :, i : i + 1]358 359 current_attn_weights_inter = torch.matmul(current_key_states.transpose(-1, -2), current_value_states)360 attn_weights_inter = ratio * attn_weights_inter + current_attn_weights_inter361 current_attn_output = torch.matmul(current_query_states, attn_weights_inter)362 363 attn_output.append(current_attn_output)364 365 # concatenate attention outputs over all blocks366 attn_output = torch.cat(attn_output, dim=-2)367 368 # final output projection369 attn_output = attn_output.transpose(1, 2)370 attn_output = attn_output.reshape(batch_size, seq_len, self.num_attention_heads * self.head_dim)371 attn_output = self.norm(attn_output)372 attn_output = F.sigmoid(self.output_gate(hidden_states)) * attn_output373 attn_output = self.out_proj(attn_output)374 375 # update cache376 if past_key_values is not None:377 past_key_values.set_linear_cache(self.layer_idx, attn_weights_inter)378 379 return attn_output, attn_weights_inter380 381 382class MiniMaxAttention(MixtralAttention):383 pass384 385 386class MiniMaxSparseMoeBlock(MixtralSparseMoeBlock):387 pass388 389 390class MiniMaxDecoderLayer(MixtralDecoderLayer, GradientCheckpointingLayer):391 def __init__(self, config: MiniMaxConfig, layer_idx: int):392 super().__init__(config, layer_idx)393 394 self.layer_idx = layer_idx395 self.layer_type = config.layer_types[layer_idx]396 self.mlp_alpha_factor = config.mlp_alpha_factor397 self.mlp_beta_factor = config.mlp_beta_factor398 399 if self.layer_type == "linear_attention":400 self.self_attn = MiniMaxLightningAttention(config, layer_idx)401 self.attn_alpha_factor = config.linear_attn_alpha_factor402 self.attn_beta_factor = config.linear_attn_beta_factor403 else:404 self.self_attn = MiniMaxAttention(config, layer_idx)405 self.attn_alpha_factor = config.full_attn_alpha_factor406 self.attn_beta_factor = config.full_attn_beta_factor407 408 @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")409 def forward(410 self,411 hidden_states: torch.Tensor,412 position_embeddings: tuple[torch.Tensor, torch.Tensor],413 attention_mask: Optional[torch.Tensor] = None,414 position_ids: Optional[torch.LongTensor] = None,415 past_key_values: Optional[Cache] = None,416 output_attentions: Optional[bool] = False,417 output_router_logits: Optional[bool] = False,418 use_cache: Optional[bool] = False,419 cache_position: Optional[torch.LongTensor] = None,420 **kwargs: Unpack[FlashAttentionKwargs],421 ) -> tuple[torch.FloatTensor, Optional[tuple[torch.FloatTensor, torch.FloatTensor]]]:422 """423 Args:424 hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`425 position_embeddings (`tuple[torch.FloatTensor, torch.FloatTensor]`):426 Tuple containing the cosine and sine positional embeddings of shape `(batch_size, seq_len, head_dim)`,427 with `head_dim` being the embedding dimension of each attention head.428 attention_mask (`torch.Tensor`, *optional*): attention mask of size429 `(batch, sequence_length)` where padding elements are indicated by 0.430 past_key_values (`Cache`, *optional*): cached past key and value projection states431 output_attentions (`bool`, *optional*):432 Whether or not to return the attentions tensors of all attention layers. See `attentions` under433 returned tensors for more detail.434 output_router_logits (`bool`, *optional*):435 Whether or not to return the logits of all the routers. They are useful for computing the router loss, and436 should not be returned during inference.437 use_cache (`bool`, *optional*):438 If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding439 (see `past_key_values`).440 cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):441 Indices depicting the position of the input sequence tokens in the sequence.442 kwargs (`dict`, *optional*):443 Arbitrary kwargs to be ignored, used for FSDP and other methods that injects code444 into the model445 """446 447 hidden_states = self.input_layernorm(hidden_states)448 residual = hidden_states449 450 # Self Attention451 hidden_states, _ = self.self_attn(452 hidden_states=hidden_states,453 position_embeddings=position_embeddings,454 attention_mask=attention_mask,455 position_ids=position_ids,456 past_key_values=past_key_values,457 output_attentions=output_attentions,458 use_cache=use_cache,459 cache_position=cache_position,460 **kwargs,461 )462 hidden_states = residual * self.attn_alpha_factor + hidden_states * self.attn_beta_factor463 464 # Fully Connected465 hidden_states = self.post_attention_layernorm(hidden_states)466 residual = hidden_states467 hidden_states, _ = self.block_sparse_moe(hidden_states)468 hidden_states = residual * self.mlp_alpha_factor + hidden_states * self.mlp_beta_factor469 470 return hidden_states471 472 473class MiniMaxPreTrainedModel(MixtralPreTrainedModel):474 _can_compile_fullgraph = False475 _can_record_outputs = {476 "router_logits": OutputRecorder(MiniMaxSparseMoeBlock, index=1),477 "hidden_states": MiniMaxDecoderLayer,478 "attentions": [MiniMaxAttention, MiniMaxLightningAttention],479 }480 481 482class MiniMaxModel(MixtralModel):483 @check_model_inputs()484 def forward(485 self,486 input_ids: Optional[torch.LongTensor] = None,487 attention_mask: Optional[torch.Tensor] = None,488 position_ids: Optional[torch.LongTensor] = None,489 past_key_values: Optional[MiniMaxCache] = None,490 inputs_embeds: Optional[torch.FloatTensor] = None,491 use_cache: Optional[bool] = None,492 output_attentions: Optional[bool] = None,493 cache_position: Optional[torch.LongTensor] = None,494 **kwargs: Unpack[TransformersKwargs],495 ) -> MoeModelOutputWithPast:496 if (input_ids is None) ^ (inputs_embeds is not None):497 raise ValueError("You must specify exactly one of input_ids or inputs_embeds")498 499 if use_cache and past_key_values is None:500 past_key_values = MiniMaxCache()501 elif use_cache and not isinstance(past_key_values, MiniMaxCache):502 raise ValueError(503 f"MiniMax uses cache of its own and is not compatible with `past_key_values` of type {type(past_key_values)}."504 )505 506 if inputs_embeds is None:507 inputs_embeds = self.embed_tokens(input_ids)508 509 if cache_position is None:510 past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0511 cache_position = torch.arange(512 past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device513 )514 if position_ids is None:515 position_ids = cache_position.unsqueeze(0)516 517 mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask518 causal_mask = mask_function(519 config=self.config,520 input_embeds=inputs_embeds,521 attention_mask=attention_mask,522 cache_position=cache_position,523 past_key_values=past_key_values,524 position_ids=position_ids,525 )526 527 hidden_states = inputs_embeds528 529 # create position embeddings to be shared across the decoder layers530 position_embeddings = self.rotary_emb(hidden_states, position_ids)531 532 for decoder_layer in self.layers:533 if decoder_layer.layer_type == "full_attention":534 input_attention_mask = causal_mask535 else:536 # lightning attention uses original attention_mask, and uses it only for the first step537 input_attention_mask = attention_mask538 539 hidden_states = decoder_layer(540 hidden_states,541 position_embeddings=position_embeddings,542 attention_mask=input_attention_mask,543 position_ids=position_ids,544 past_key_values=past_key_values,545 use_cache=use_cache,546 cache_position=cache_position,547 **kwargs,548 )549 550 hidden_states = self.norm(hidden_states)551 552 return MoeModelOutputWithPast(553 last_hidden_state=hidden_states,554 past_key_values=past_key_values,555 )556 557 558class MiniMaxForCausalLM(MixtralForCausalLM):559 def forward(self, **super_kwargs):560 r"""561 labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):562 Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,563 config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored564 (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.565 566 Example:567 568 ```python569 >>> from transformers import AutoTokenizer, MiniMaxForCausalLM570 571 >>> model = MiniMaxForCausalLM.from_pretrained("MiniMaxAI/MiniMax-Text-01-hf")572 >>> tokenizer = AutoTokenizer.from_pretrained("MiniMaxAI/MiniMax-Text-01-hf")573 574 >>> prompt = "Hey, are you conscious? Can you talk to me?"575 >>> inputs = tokenizer(prompt, return_tensors="pt")576 577 >>> # Generate578 >>> generate_ids = model.generate(inputs.input_ids, max_length=30)579 >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]580 "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."581 ```"""582 return super().forward(**super_kwargs)583 584 585class MiniMaxForSequenceClassification(MixtralForSequenceClassification):586 pass587 588 589class MiniMaxForTokenClassification(MixtralForTokenClassification):590 pass591 592 593class MiniMaxForQuestionAnswering(MixtralForQuestionAnswering):594 pass595 596 597__all__ = [598 "MiniMaxConfig",599 "MiniMaxPreTrainedModel",600 "MiniMaxModel",601 "MiniMaxForCausalLM",602 "MiniMaxForSequenceClassification",603 "MiniMaxForTokenClassification",604 "MiniMaxForQuestionAnswering",605]606 