Skip to content

Commit 862bf78

Browse files
authored
[Demo] Internlm3 math500 thinking demo (#1846)
* [Demo] Add demo for Internlm3 math500 thinking * [Demo] Add demo for Internlm3 math500 thinking * update max_out_len * update start instruction
1 parent 412199f commit 862bf78

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# To run this example, you need to do the following steps:
2+
# 1. Install latest opencompass
3+
# 2. Start a local server with Qwen2.5-72B-Instruct as LLMJudge server (i.e. using vLLM or LMDeploy)
4+
# 3. Change the judge_cfg openai_api_base to your corresponindg local server address
5+
# 4. Start this evaluation by running 'opencompass eval_internlm3_math500_thinking.py'
6+
from opencompass.models import VLLMwithChatTemplate, OpenAISDK
7+
from mmengine.config import read_base
8+
9+
with read_base():
10+
from opencompass.configs.datasets.math.math_prm800k_500_0shot_nocot_genericllmeval_gen_63a000 import (
11+
math_datasets,
12+
)
13+
14+
api_meta_template = dict(
15+
round=[
16+
dict(role='HUMAN', api_role='HUMAN'),
17+
dict(role='BOT', api_role='BOT', generate=True),
18+
],
19+
)
20+
21+
22+
judge_cfg = dict(
23+
abbr='qwen2-5-72b-instruct',
24+
type=OpenAISDK,
25+
path='Qwen/Qwen2.5-72B-Instruct',
26+
key='YOUR_API_KEY',
27+
openai_api_base=[
28+
'http://172.30.56.81:23333/v1/', ### Change to your own server
29+
],
30+
meta_template=api_meta_template,
31+
query_per_second=16,
32+
batch_size=16,
33+
temperature=0.001,
34+
max_seq_len=32768,
35+
max_completion_tokens=32768,
36+
)
37+
38+
datasets = sum(
39+
(v for k, v in locals().items() if k.endswith('_datasets')),
40+
[],
41+
)
42+
# set max_out_len for inference
43+
for item in datasets:
44+
item['infer_cfg']['inferencer']['max_out_len'] = 16384
45+
if 'judge_cfg' in item['eval_cfg']['evaluator']:
46+
item['eval_cfg']['evaluator']['judge_cfg'] = judge_cfg
47+
48+
reasoning_chat_template = """You are an expert mathematician with extensive experience in mathematical competitions. You approach problems through systematic thinking and rigorous reasoning. When solving problems, follow these thought processes:
49+
## Deep Understanding
50+
Take time to fully comprehend the problem before attempting a solution. Consider:
51+
- What is the real question being asked?
52+
- What are the given conditions and what do they tell us?
53+
- Are there any special restrictions or assumptions?
54+
- Which information is crucial and which is supplementary?
55+
## Multi-angle Analysis
56+
Before solving, conduct thorough analysis:
57+
- What mathematical concepts and properties are involved?
58+
- Can you recall similar classic problems or solution methods?
59+
- Would diagrams or tables help visualize the problem?
60+
- Are there special cases that need separate consideration?
61+
## Systematic Thinking
62+
Plan your solution path:
63+
- Propose multiple possible approaches
64+
- Analyze the feasibility and merits of each method
65+
- Choose the most appropriate method and explain why
66+
- Break complex problems into smaller, manageable steps
67+
## Rigorous Proof
68+
During the solution process:
69+
- Provide solid justification for each step
70+
- Include detailed proofs for key conclusions
71+
- Pay attention to logical connections
72+
- Be vigilant about potential oversights
73+
## Repeated Verification
74+
After completing your solution:
75+
- Verify your results satisfy all conditions
76+
- Check for overlooked special cases
77+
- Consider if the solution can be optimized or simplified
78+
- Review your reasoning process
79+
Remember:
80+
1. Take time to think thoroughly rather than rushing to an answer
81+
2. Rigorously prove each key conclusion
82+
3. Keep an open mind and try different approaches
83+
4. Summarize valuable problem-solving methods
84+
5. Maintain healthy skepticism and verify multiple times
85+
Your response should reflect deep mathematical understanding and precise logical thinking, making your solution path and reasoning clear to others.
86+
When you're ready, present your complete solution with:
87+
- Clear problem understanding
88+
- Detailed solution process
89+
- Key insights
90+
- Thorough verification
91+
Focus on clear, logical progression of ideas and thorough explanation of your mathematical reasoning. Provide answers in the same language as the user asking the question, repeat the final answer using a '\\boxed{}' without any units, you have [[8192]] tokens to complete the answer.
92+
"""
93+
94+
reasoning_meta_template = dict(
95+
begin=dict(
96+
role='SYSTEM', api_role='SYSTEM', prompt=reasoning_chat_template
97+
),
98+
round=[
99+
dict(role='HUMAN', api_role='HUMAN'),
100+
# XXX: all system roles are mapped to human in purpose
101+
dict(role='BOT', api_role='BOT', generate=True),
102+
],
103+
)
104+
105+
models = [
106+
dict(
107+
type=VLLMwithChatTemplate,
108+
abbr='internlm3-8b-instruct-vllm',
109+
path='internlm/internlm3-8b-instruct',
110+
model_kwargs=dict(tensor_parallel_size=1),
111+
generation_kwargs=dict(do_sample=False), # greedy
112+
max_seq_len=32768,
113+
max_out_len=16384,
114+
batch_size=16,
115+
run_cfg=dict(num_gpus=1),
116+
meta_template=reasoning_meta_template,
117+
)
118+
]
119+
120+
datasets = math_datasets

0 commit comments

Comments
 (0)