-
Notifications
You must be signed in to change notification settings - Fork 48
Add chat_template_path and trust_remote_code #379
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
pan-x-c
merged 7 commits into
agentscope-ai:main
from
hiyuchang:dev/add_chat_template_path
Nov 18, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18d219c
add chat_template_path and trust_remote_code
hiyuchang b0577ed
add message for dapo
hiyuchang f2b7f85
add unittest
hiyuchang 92fd176
Merge branch 'main' into dev/add_chat_template_path
hiyuchang c11eba7
Merge branch 'main' into dev/add_chat_template_path
hiyuchang 96c7f77
add explanation
hiyuchang 3c1799c
fix test
hiyuchang 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # DAPO on DAPO-MATH-17k dataset [WIP] | ||
|
|
||
| This example shows the usage of DAPO on the [DAPO-MATH-17k](https://huggingface.co/datasets/open-r1/DAPO-Math-17k-Processed) dataset. | ||
| Note this example only shows the usage of GRPO on the [DAPO-MATH-17k](https://huggingface.co/datasets/open-r1/DAPO-Math-17k-Processed) dataset. We plan to implement DAPO algorithm soon. | ||
|
|
||
| The config file is located in [`dapo.yaml`](dapo.yaml). |
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,67 @@ | ||
| {%- if tools %} | ||
| {{- '<|im_start|>system\n' }} | ||
| {%- if messages[0].role == 'system' %} | ||
| {{- messages[0].content + '\n\n' }} | ||
| {%- endif %} | ||
| {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }} | ||
| {%- for tool in tools %} | ||
| {{- "\n" }} | ||
| {{- tool | tojson }} | ||
| {%- endfor %} | ||
| {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }} | ||
| {%- else %} | ||
| {%- if messages[0].role == 'system' %} | ||
| {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} | ||
| {%- endif %} | ||
| {%- endif %} | ||
| {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} | ||
| {%- for message in messages[::-1] %} | ||
| {%- set index = (messages|length - 1) - loop.index0 %} | ||
| {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %} | ||
| {%- set ns.multi_step_tool = false %} | ||
| {%- set ns.last_query_index = index %} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| {%- for message in messages %} | ||
| {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} | ||
| {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} | ||
| {%- elif message.role == "assistant" %} | ||
| {{- '<|im_start|>' + message.role + '\n' + message.content }} | ||
| {%- if message.tool_calls %} | ||
| {%- for tool_call in message.tool_calls %} | ||
| {%- if (loop.first and content) or (not loop.first) %} | ||
| {{- '\n' }} | ||
| {%- endif %} | ||
| {%- if tool_call.function %} | ||
| {%- set tool_call = tool_call.function %} | ||
| {%- endif %} | ||
| {{- '<tool_call>\n{"name": "' }} | ||
| {{- tool_call.name }} | ||
| {{- '", "arguments": ' }} | ||
| {%- if tool_call.arguments is string %} | ||
| {{- tool_call.arguments }} | ||
| {%- else %} | ||
| {{- tool_call.arguments | tojson }} | ||
| {%- endif %} | ||
| {{- '}\n</tool_call>' }} | ||
| {%- endfor %} | ||
| {%- endif %} | ||
| {{- '<|im_end|>\n' }} | ||
| {%- elif message.role == "tool" %} | ||
| {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} | ||
| {{- '<|im_start|>user' }} | ||
| {%- endif %} | ||
| {{- '\n<tool_response>\n' }} | ||
| {{- message.content }} | ||
| {{- '\n</tool_response>' }} | ||
| {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} | ||
| {{- '<|im_end|>\n' }} | ||
| {%- endif %} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| {%- if add_generation_prompt %} | ||
| {{- '<|im_start|>assistant\n' }} | ||
| {%- if enable_thinking is defined and enable_thinking is false %} | ||
| {{- '<think>\n\n</think>\n\n' }} | ||
| {%- endif %} | ||
| {%- endif %} |
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
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.