Skip to content

Conversation

hpsun1109
Copy link
Contributor

@hpsun1109 hpsun1109 commented Sep 9, 2025

兼容no think数据中包含<think> \n\n</think>\n\n;目前这部分数据budget被设置为512,正常应该是0

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Write the detail information belongs to this PR.

Experiment results

Paste your experiment result here(if needed).

兼容no think数据中包含\n\n\n\n;目前这部分数据budget被设置为512,正常应该是0
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @hpsun1109, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在修复LLM模板中思考预算计算的一个缺陷。它通过引入一个条件检查来确保只有在think标签包含实际文本内容时才计算其token长度,从而避免了因空白或仅含换行符的think内容导致预算被错误地设置为非零值(例如512)的问题。这一改动提高了预算分配的准确性,特别是对于那些不应有思考预算的数据。

Highlights

  • 修复思考预算计算错误: 解决了当think标签内容为空或仅包含空白字符(如换行符)时,思考预算被错误地计算为非零值的问题。
  • 优化空白内容处理: 确保只有当think标签内包含实际内容时才计算其token长度,从而避免了对“无思考”数据的错误预算分配。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次变更修复了当 <think> 标签中只包含换行符等空白字符时,thinking_budget 被错误计算的问题。通过增加对 think 内容的检查,确保了只在 think 标签内有实际内容时才计算token长度,从而避免了错误的budget设置。此修复是正确且必要的。我提供了一个小建议以提高代码的简洁性。

Comment on lines +29 to +30
if thinking_token_len > max_length:
max_length = thinking_token_len
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了使代码更简洁,您可以使用 max() 函数来更新 max_length,从而减少一个嵌套层级,提高代码的可读性。

                            max_length = max(max_length, thinking_token_len)

@hpsun1109
Copy link
Contributor Author

@Jintao-Huang 解决no think数据中包含<think> \n\n</think>\n\n字段会被误判断为budget=512的问题

@tastelikefeet tastelikefeet merged commit f760a0d into modelscope:main Sep 11, 2025
1 of 2 checks passed
Jintao-Huang pushed a commit that referenced this pull request Sep 15, 2025
兼容no think数据中包含\n\n\n\n;目前这部分数据budget被设置为512,正常应该是0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants