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+
library_name: transformers
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Confucius3-Math
|
| 12 |
+
|
| 13 |
+
## Introduction
|
| 14 |
+
**Confucius3-Math** is a reasoning model developed by the NetEase Youdao Team. It is a large language model with 14B parameters that (1) runs efficiently on a single consumer-grade GPU; (2) achieves SOTA performances on a range of mathematical reasoning tasks, outperforming many models with significantly larger sizes. Built via post-training with a pure large-scale reinforcement learning (RL) process, Confucius3-Math is the first open-source model that excels at solving main stream Chinese K-12 mathematical problems with low cost.
|
| 15 |
+
|
| 16 |
+
## Model Summary
|
| 17 |
+
|
| 18 |
+
**Selection of the Base Model**
|
| 19 |
+
- We selected the open-source [DeepSeek-R1-Distill-Qwen-14B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B) model as the initial model for training Confucius3-Math. This choice was made because the model already exhibits robust chain-of-thought capabilities and holds a greater initial edge in the field of mathematics compared to other models of comparable scale. Moreover, the responses in the answer section provided by this model align with our expectations for an educational model.
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
**Reinforcement Learning**
|
| 23 |
+
- In particular, we introduce Recent Sample Recovery and Policy-Specific Hardness Weighting, one novel data scheduling policy and one improved group-relative advantage estimator, respectively, that significantly improves data efficiency, stabilize the RL training process, and boost performance. By integrating the DAPO algorithm with the two newly proposed technologies, we have achieved SOTA results on several Chinese K12 mathematics test sets.
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
**Data Formatting**
|
| 27 |
+
- We standardize the output format of the model as follows: the chain-of-thought process is output in the `<think></think>` block, and then the step-by-step problem-solving process is summarized in the `<answer></answer>` block.
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
**Composition of Training Data**
|
| 31 |
+
- The data used for training the model comes from two major sources: open-source and proprietary. To enhance the model’s mathematical capabilities, we collect a large number of open-source English mathematics dataset. For our proprietary data, We also collect Chinese K12 math questions, and their solutions, accumulated during the operation of our business. They cover various mathematics problems for the domestic K-12 stage (primary, middle, and high school), including a rich variety of types, such as single-choice, multiple-choice, true/false, fill-in-the-blank, calculation, proof, and mixtures of multiple question types etc.
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
**More Stringent Data filtering**
|
| 35 |
+
- To ensure the quality and diversity of the learning data, we have implemented a rigorous preprocessing procedure for our data. For open-source data, we execute the following data processing workflow in sequence: exact deduplication, fuzzy deduplication, semantic deduplication and question type selection. For our proprietary data, we apply a cleaning stage additionally, as the data originates from mass-scale automated entry with manual correction, it inherently contains significant noise. After filtering, we retained approximately 540,000 examples of data for actual training, including 210,000 from open-source data and 330,000 from proprietary data.
|
| 36 |
+
|
| 37 |
+
## Evaluation and Results
|
| 38 |
+
For each model, we used the official system prompt provided by the corresponding model and took the question in the test set as the user content. For R1, we did not use the System Prompt because our evaluation found that this could achieve higher quality. The maximum generated response length of the models was uniformly set to 32,768 tokens. We used the sampling strategy to generate k response results and reported the pass@1 results. Specifically, for our model, we used a sampling temperature of 1.0 and a top-p value of 0.7, while for other models, we used the sampling parameters recommended by the official documentation. Regarding the setting of k, different test sets used different values. For MATH500, AIME24, and AIME25, we followed DeepSeek’s setting of k = 64, and for other test sets, k is set to approximately 2, 000/N where N is the number of samples in the set.
|
| 39 |
+
|
| 40 |
+
<div align="center">
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
| Benchmark | DeepSeek-R1 | Qwen3-14B | QwQ-32B | DeepSeek-R1-Distill-Qwen-14B | Confucius3-Math |
|
| 44 |
+
|-------------------|----------------------|------------|--------------|----------------|------------|
|
| 45 |
+
| CK12-MATH | 92.74 | 94.04 | 93.60 | 82.86 | 96.24 |
|
| 46 |
+
| GAOKAO-Bench(math) | 93.27 | 94.44 | 94.93 | 86.75 | 98.46 |
|
| 47 |
+
| MathBench(K12) | 89.99 | 96.51 | 96.57 | 88.40 | 95.10 |
|
| 48 |
+
| CMATH | 95.81 | 95.90 | 95.95 | 77.41 | 96.13 |
|
| 49 |
+
| MATH-500 | 97.30 | 96.80 | 98.00 | 93.90 | 98.80 |
|
| 50 |
+
| AIME 2024 | 79.80 | 79.30 | 79.50 | 69.70 | 81.15 |
|
| 51 |
+
| AIME 2025 | 70.00 | 70.40 | 69.50 | 42.97 | 69.95 |
|
| 52 |
+
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
## Limitations
|
| 58 |
+
|
| 59 |
+
However, there are some limitations that must be stated in advance:
|
| 60 |
+
1. **Scenario Limitations**: Our optimization is only carried out on data from the K12 mathematics scenario, and the effectiveness has only been verified in math-related benchmark tests. The performance of the model in non-mathematical scenarios has not been tested, so we cannot guarantee its quality and effectiveness in other fields.
|
| 61 |
+
2. **Invalid Results**: The model may sometimes fall into circular reasoning. Since we use explicit identifiers to divide the thinking and summary parts, when the model enters this mode, it may generate invalid results that cannot be parsed.
|
| 62 |
+
3. **Safety and Ethics**: This model has not undergone optimization and testing for alignment at the safety and ethical levels. Any output generated by the model does not represent the official positions, views, or attitudes of our company. When using this model, users should independently judge and evaluate the rationality and applicability of the output content and comply with relevant laws, regulations, and social ethics.
|
| 63 |
+
|
| 64 |
+
## Quickstart
|
| 65 |
+
The environmental requirements for running it are exactly the same as those of the [Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct) model. Therefore, you can easily use Transformers or vLLM to load and run the model for inference, and deploy your services.
|
| 66 |
+
|
| 67 |
+
The only thing you need to pay attention to is to use the predefined system message and user message templates provided below to request the model. Other templates may also be usable, but we haven't tested them yet.
|
| 68 |
+
```python
|
| 69 |
+
SYSTEM_PROMPT_TEMPLATE = """A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think> <answer> answer here </answer>."""
|
| 70 |
+
|
| 71 |
+
USER_PROMPT_TEMPLATE = """{question}"""
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
Then you can create your `messages` as follows and use them to request model results. You just need to fill in your instructions in the "question" field.
|
| 75 |
+
```python
|
| 76 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 77 |
+
|
| 78 |
+
model_name = "netease-youdao/Confucius3-Math"
|
| 79 |
+
|
| 80 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 81 |
+
model_name,
|
| 82 |
+
torch_dtype="auto",
|
| 83 |
+
device_map="auto"
|
| 84 |
+
)
|
| 85 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 86 |
+
|
| 87 |
+
messages = [
|
| 88 |
+
{'role': 'system', 'content': SYSTEM_PROMPT_TEMPLATE},
|
| 89 |
+
{'role': 'user', 'content': USER_PROMPT_TEMPLATE.format(question=question)},
|
| 90 |
+
]
|
| 91 |
+
|
| 92 |
+
text = tokenizer.apply_chat_template(
|
| 93 |
+
messages,
|
| 94 |
+
tokenize=False,
|
| 95 |
+
add_generation_prompt=True
|
| 96 |
+
)
|
| 97 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 98 |
+
|
| 99 |
+
generated_ids = model.generate(
|
| 100 |
+
**model_inputs,
|
| 101 |
+
max_new_tokens=16384
|
| 102 |
+
)
|
| 103 |
+
generated_ids = [
|
| 104 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
After obtaining the model results, you can parse out the "thinking" and "summary" parts as follows.
|
| 111 |
+
```python
|
| 112 |
+
def parse_result_nostep(result):
|
| 113 |
+
think_pattern = r"<think>(.*?)</think>(.*)"
|
| 114 |
+
|
| 115 |
+
think_list = re.findall(think_pattern, result, re.DOTALL)
|
| 116 |
+
|
| 117 |
+
assert len(think_list) == 1, \
|
| 118 |
+
f"The parsing results do not meet the expectations.\n{result}"
|
| 119 |
+
|
| 120 |
+
think = think_list[0][0].strip()
|
| 121 |
+
summary = think_list[0][1].strip()
|
| 122 |
+
return think, summary
|
| 123 |
+
|
| 124 |
+
thinking, summary = parse_result_nostep(response)
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
## Citation
|
| 128 |
+
If you find our work helpful, feel free to give us a cite.
|
| 129 |
+
```
|
| 130 |
+
@misc{confucius3-math,
|
| 131 |
+
author = {NetEase Youdao Team},
|
| 132 |
+
title = {Confucius3-Math: A Lightweight High-Performance Reasoning LLM for Chinese K-12 Mathematics Learning},
|
| 133 |
+
url = {https://huggingface.co/netease-youdao/Confucius3-Math},
|
| 134 |
+
month = {June},
|
| 135 |
+
year = {2025}
|
| 136 |
+
}
|
| 137 |
+
```
|