-
Notifications
You must be signed in to change notification settings - Fork 737
[Demo] Internlm3 math500 thinking demo #1846
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
Merged
tonysy
merged 4 commits into
open-compass:main
from
MaiziXiao:internlm3_math500_reasoning
Jan 24, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| from opencompass.models import VLLMwithChatTemplate, OpenAISDK | ||
| from mmengine.config import read_base | ||
|
|
||
| with read_base(): | ||
| from opencompass.configs.datasets.math.math_prm800k_500_0shot_nocot_genericllmeval_gen_63a000 import ( | ||
| math_datasets, | ||
| ) | ||
|
|
||
| api_meta_template = dict( | ||
| round=[ | ||
| dict(role='HUMAN', api_role='HUMAN'), | ||
| dict(role='BOT', api_role='BOT', generate=True), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| judge_cfg = dict( | ||
| abbr='qwen2-5-72b-instruct', | ||
| type=OpenAISDK, | ||
| path='Qwen/Qwen2.5-72B-Instruct', | ||
| key='YOUR_API_KEY', | ||
| openai_api_base=[ | ||
| 'http://172.30.56.81:23333/v1/', ### Change to your own server | ||
| ], | ||
| meta_template=api_meta_template, | ||
| query_per_second=16, | ||
| batch_size=16, | ||
| temperature=0.001, | ||
| max_seq_len=32768, | ||
| max_completion_tokens=32768, | ||
| ) | ||
|
|
||
| datasets = sum( | ||
| (v for k, v in locals().items() if k.endswith('_datasets')), | ||
| [], | ||
| ) | ||
| # set max_out_len for inference | ||
| for item in datasets: | ||
| item['infer_cfg']['inferencer']['max_out_len'] = 16384 | ||
| if 'judge_cfg' in item['eval_cfg']['evaluator']: | ||
| item['eval_cfg']['evaluator']['judge_cfg'] = judge_cfg | ||
|
|
||
| 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: | ||
| ## Deep Understanding | ||
| Take time to fully comprehend the problem before attempting a solution. Consider: | ||
| - What is the real question being asked? | ||
| - What are the given conditions and what do they tell us? | ||
| - Are there any special restrictions or assumptions? | ||
| - Which information is crucial and which is supplementary? | ||
| ## Multi-angle Analysis | ||
| Before solving, conduct thorough analysis: | ||
| - What mathematical concepts and properties are involved? | ||
| - Can you recall similar classic problems or solution methods? | ||
| - Would diagrams or tables help visualize the problem? | ||
| - Are there special cases that need separate consideration? | ||
| ## Systematic Thinking | ||
| Plan your solution path: | ||
| - Propose multiple possible approaches | ||
| - Analyze the feasibility and merits of each method | ||
| - Choose the most appropriate method and explain why | ||
| - Break complex problems into smaller, manageable steps | ||
| ## Rigorous Proof | ||
| During the solution process: | ||
| - Provide solid justification for each step | ||
| - Include detailed proofs for key conclusions | ||
| - Pay attention to logical connections | ||
| - Be vigilant about potential oversights | ||
| ## Repeated Verification | ||
| After completing your solution: | ||
| - Verify your results satisfy all conditions | ||
| - Check for overlooked special cases | ||
| - Consider if the solution can be optimized or simplified | ||
| - Review your reasoning process | ||
| Remember: | ||
| 1. Take time to think thoroughly rather than rushing to an answer | ||
| 2. Rigorously prove each key conclusion | ||
| 3. Keep an open mind and try different approaches | ||
| 4. Summarize valuable problem-solving methods | ||
| 5. Maintain healthy skepticism and verify multiple times | ||
| Your response should reflect deep mathematical understanding and precise logical thinking, making your solution path and reasoning clear to others. | ||
| When you're ready, present your complete solution with: | ||
| - Clear problem understanding | ||
| - Detailed solution process | ||
| - Key insights | ||
| - Thorough verification | ||
| 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. | ||
| """ | ||
|
|
||
| reasoning_meta_template = dict( | ||
| begin=dict( | ||
| role='SYSTEM', api_role='SYSTEM', prompt=reasoning_chat_template | ||
| ), | ||
| round=[ | ||
| dict(role='HUMAN', api_role='HUMAN'), | ||
| # XXX: all system roles are mapped to human in purpose | ||
| dict(role='BOT', api_role='BOT', generate=True), | ||
| ], | ||
| ) | ||
|
|
||
| models = [ | ||
| dict( | ||
| type=VLLMwithChatTemplate, | ||
| abbr='internlm3-8b-instruct-vllm', | ||
| path='internlm/internlm3-8b-instruct', | ||
| model_kwargs=dict(tensor_parallel_size=1), | ||
| generation_kwargs=dict(do_sample=False), # greedy | ||
| max_seq_len=32768, | ||
| max_out_len=8192, | ||
| batch_size=16, | ||
| run_cfg=dict(num_gpus=1), | ||
| meta_template=reasoning_meta_template, | ||
| ) | ||
| ] | ||
|
|
||
| datasets = math_datasets | ||
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.