-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Add support for MiniMax-M2 #42028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rogeryoungh
wants to merge
9
commits into
huggingface:main
Choose a base branch
from
rogeryoungh:minimax-m2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,642
−0
Open
Add support for MiniMax-M2 #42028
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5363916
update: init m2
261fe5c
update: docs and config
ac4613c
update: init minimax-m2 test
3421fe7
update: fix tests
3a5df7a
update: use partial_rotary_factor
cb17f62
update: some fix
f6775d8
fix: import Unpack from processing_utils
73904ee
update: apply suggestions from code review
rogeryoungh 6b7e397
update: remove MiniMaxM2DecoderLayer and MiniMaxM2MLP
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| <!--Copyright 2025 the HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
|
|
||
| ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. | ||
|
|
||
| --> | ||
|
|
||
|
|
||
| # MiniMax-M2 | ||
|
|
||
| ## Overview | ||
|
|
||
| MiniMax-M2 redefines efficiency for agents. It's a compact, fast, and cost-effective MoE model (230 billion total parameters with 10 billion active parameters) built for elite performance in coding and agentic tasks, all while maintaining powerful general intelligence. With just 10 billion activated parameters, MiniMax-M2 provides the sophisticated, end-to-end tool use performance expected from today's leading models, but in a streamlined form factor that makes deployment and scaling easier than ever. | ||
|
|
||
| For more details refer to the [release blog post](https://www.minimax.io/news/minimax-m2). | ||
|
|
||
| ## Usage examples | ||
|
|
||
| ```python | ||
| from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig | ||
|
|
||
| model = AutoModelForCausalLM.from_pretrained("MiniMaxAI/MiniMax-M2", device_map="auto") | ||
|
|
||
| tokenizer = AutoTokenizer.from_pretrained("MiniMaxAI/MiniMax-M2") | ||
|
|
||
| generation_config = GenerationConfig.from_pretrained("MiniMaxAI/MiniMax-M2") | ||
|
|
||
| messages = [ | ||
| {"role": "user", "content": "What is your favourite condiment?"}, | ||
| {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"}, | ||
| {"role": "user", "content": "Do you have mayonnaise recipes?"} | ||
| ] | ||
|
|
||
| model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to("cuda") | ||
|
|
||
| generated_ids = model.generate(model_inputs, max_new_tokens=100, generation_config=generation_config) | ||
|
|
||
| response = tokenizer.batch_decode(generated_ids)[0] | ||
|
|
||
| print(response) | ||
| ``` | ||
|
|
||
| ## MiniMaxM2Config | ||
|
|
||
| [[autodoc]] MiniMaxM2Config | ||
|
|
||
| ## MiniMaxM2ForCausalLM | ||
|
|
||
| [[autodoc]] MiniMaxM2ForCausalLM | ||
| - forward | ||
|
|
||
| ## MiniMaxM2ForQuestionAnswering | ||
|
|
||
| [[autodoc]] MiniMaxM2ForQuestionAnswering | ||
| - forward | ||
|
|
||
| ## MiniMaxM2Model | ||
|
|
||
| [[autodoc]] MiniMaxM2Model | ||
| - forward | ||
|
|
||
| ## MiniMaxM2ForSequenceClassification | ||
|
|
||
| [[autodoc]] MiniMaxM2ForSequenceClassification | ||
| - forward | ||
|
|
||
| ## MiniMaxM2ForTokenClassification | ||
|
|
||
| [[autodoc]] MiniMaxM2ForTokenClassification | ||
| - forward | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # coding=utf-8 | ||
| # Copyright 2025 the HuggingFace Team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from ...utils import _LazyModule | ||
| from ...utils.import_utils import define_import_structure | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from .configuration_minimax_m2 import * | ||
| from .modeling_minimax_m2 import * | ||
| else: | ||
| import sys | ||
|
|
||
| _file = globals()["__file__"] | ||
| sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.