Downloads · 30 days
117
15% of all-time downloads
Infinigence/Megrez2-3x7B-A3B
Megrez2-3x7B-A3B is a text generation model from Infinigence. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
<div align="center" <img src="./assets/megrez-logo.png" alt="Megrez Logo" width="400" /
Downloads · 30 days
117
15% of all-time downloads
All-time downloads
785
Public
Parameters
7.5B
14.9 GB on disk
Likes
18
Public
Click a slice to open those files.
.safetensors14.9 GB · 100%
From the Hugging Face model README
<strong>中文 | English</strong>
</div>Megrez2-3x7B-A3B is a device native large language model. Megrez2 takes advantages of both the accuracy of Mixture-of-Experts (MoE) architecture and the compact size of Dense models. This release model was trained on 8T Tokens of data. In the future, we plan to improve the model's reasoning and agent capabilities.
| Architecture | Mixture-of-Experts (MoE) |
| Total Parameters | 3x7B |
| Activated Parameters | 3B |
| Experts Shared Frequency | 3 |
| Number of Layers (Dense layer included) | 31 |
| Number of Dense Layers | 1 |
| Attention Hidden Dimension | 2048 |
| MoE Hidden Dimension (per Expert) | 1408 |
| Number of Attention Heads | 16 |
| Number of Experts | 64 |
| Selected Experts per Token | 6 |
| Number of Shared Experts | 4 |
| Vocabulary Size | 128,880 |
| Context Length | 32K |
| Base Frequency of RoPE | 5,000,000 |
| Attention Mechanism | GQA |
| Activation Function | SwiGLU |
We evaluated Megrez2-3x7B-A3B using the open-source evaluation tool OpenCompass on several important benchmarks. Some of the evaluation results are shown in the table below.
<div align="center"> <table> <thead> <tr> <th align="center">Benchmark</th> <th align="center">Metric</th> <th align="center"><sup>Megrez2-3x7B<br>-A3B</sup></th> <th align="center"><sup>Megrez2-3x7B<br>-A3B-Preview</sup></th> <th align="center"><sup>SmallThinker-21B<br>-A3B-Instruct</sup></th> <th align="center"><sup>Qwen3-30B-A3B</sup></th> <th align="center"><sup>Qwen3-8B</sup></th> <th align="center"><sup>Qwen3-4B<br>-Instruct-2507</sup></th> <th align="center"><sup>Phi4-14B<br>(nothink)</sup></th> <th align="center"><sup>Gemma3-12B</sup></th> </tr> </thead> <tbody> <tr> <td align="center">Activate Params (B)</td> <td align="center"></td> <td align="center">3.0</td> <td align="center">3.0</td> <td align="center">3.0</td> <td align="center">3.3</td> <td align="center">8.2</td> <td align="center">4.0</td> <td align="center">14.7</td> <td align="center">12.2</td> </tr> <tr> <td align="center">Stored Params (B)</td> <td align="center"></td> <td align="center">7.5</td> <td align="center">7.5</td> <td align="center">21.5</td> <td align="center">30.5</td> <td align="center">8.2</td> <td align="center">4.0</td> <td align="center">14.7</td> <td align="center">12.2</td> </tr> <tr> <td align="center">MMLU</td> <td align="center">EM</td> <td align="center">85.4</td> <td align="center"><strong>87.5</strong></td> <td align="center">84.4</td> <td align="center">85.1</td> <td align="center">81.8</td> <td align="center">-</td> <td align="center">84.6</td> <td align="center">78.5</td> </tr> <tr> <td align="center">GPQA</td> <td align="center">EM</td> <td align="center"><strong>58.8</strong></td> <td align="center">28.8</td> <td align="center">55.0</td> <td align="center">44.4</td> <td align="center">38.9</td> <td align="center">62</td> <td align="center">55.5</td> <td align="center">34.9</td> </tr> <tr> <td align="center">IFEval</td> <td align="center">Inst<br>loose</td> <td align="center"><strong>87.7</strong></td> <td align="center">80.2</td> <td align="center">85.8</td> <td align="center">84.3</td> <td align="center">83.9</td> <td align="center">83.4</td> <td align="center">63.2</td> <td align="center">74.7</td> </tr> <tr> <td align="center">MATH-500</td> <td align="center">EM</td> <td align="center"><strong>87.2</strong></td> <td align="center">81.6</td> <td align="center">82.4</td> <td align="center">84.4</td> <td align="center">81.6</td> <td align="center">-</td> <td align="center">80.2</td> <td align="center">82.4</td> </tr> </tbody> </table> </div>The latest version of transformers is recommended or transformers>=4.52.4 is required.
The following contains a code snippet illustrating how to use the model generate content based on given inputs.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
path = "Infinigence/Megrez2-3x7B-A3B"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map=device, trust_remote_code=True)
messages = [
{"role": "user", "content": "世界上最高的山峰是哪座?"},
]
model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(device)
model_outputs = model.generate(
model_inputs,
do_sample=True,
max_new_tokens=1024
)
output_token_ids = [
model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
]
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
print(responses)
# 世界上最高的山峰是珠穆朗玛峰(Mount Everest),位于喜马拉雅山脉的中尼边境。珠穆朗玛峰的海拔高度为8,848.86米(29,031.7英尺),这一数据是由中国和尼泊尔在2020年共同宣布的最新测量结果。珠穆朗玛峰不仅是登山爱好者的圣地,也是地理和科学研究的重要对象。
ModelScope adopts Python API similar to (though not entirely identical to) Transformers. For basic usage, simply modify the first line of the above code as follows:
from modelscope import AutoModelForCausalLM, AutoTokenizer
llama.cpp enables LLM inference with minimal setup and state-of-the-art performance on a wide range of hardware. Now supported, please refer to the support-megrez branch for details.
Megrez2-3x7B-A3B support using vLLM and SGLang as inference backends. For more information, please visit the gitHub repository.
To achieve optimal performance, we recommend the following settings:
Sampling Parameters: we suggest using Temperature=0.7 and TopP=0.9 .
Standardize Output Format: We recommend using prompts to standardize model outputs when benchmarking.
All our open-weight models are licensed under Apache 2.0.
If you find our work helpful, feel free to give us a cite.
@misc{li2025megrez2technicalreport,
title={Megrez2 Technical Report},
author={Boxun Li and Yadong Li and Zhiyuan Li and Congyi Liu and Weilin Liu and Guowei Niu and Zheyue Tan and Haiyang Xu and Zhuyu Yao and Tao Yuan and Dong Zhou and Yueqing Zhuang and Bo Zhao and Guohao Dai and Yu Wang},
year={2025},
eprint={2507.17728},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2507.17728},
}
If you have any questions, please feel free to submit a GitHub issue or contact WeChat groups.