Skip to content
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

server: extract <think> tags from qwq outputs #12297

Merged
merged 4 commits into from
Mar 10, 2025

Conversation

ochafik
Copy link
Collaborator

@ochafik ochafik commented Mar 10, 2025

Fixes #12275

Note: unrelated to this PR, but streaming mode is still not dealing w/ thoughts extraction, which means templates that pre-feed the <think> tag (like DeepSeek R1 Distills & QwQ-32B) will lack the <think> tag in their output. Will address separately w/ a streaming overhaul + tool call support.

@github-actions github-actions bot added the testing Everything test related label Mar 10, 2025
common/chat.cpp Outdated
Comment on lines 1126 to 1128
static std::regex function_regex("<|tool▁call▁begin|>function<|tool▁sep|>([^\n]+)\n```json\n");
static std::regex close_regex("```[\\s\\r\\n]*<|tool▁call▁end|>");
static std::regex tool_calls_regex("[\\s\\r\\n]*(?:<|tool▁calls▁begin|>|<|tool_calls_begin|>|<|tool calls begin|>|<|tool\\\\_calls\\\\_begin|>)([\\s\\S\\r\\n]*?)<|tool▁calls▁end|>");
Copy link
Member

Choose a reason for hiding this comment

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

These should be static const

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated, thanks!

@ochafik ochafik marked this pull request as ready for review March 10, 2025 09:50
@ochafik ochafik merged commit 4e39a3c into ggml-org:master Mar 10, 2025
24 checks passed
@ochafik ochafik deleted the qwq-think branch March 10, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Everything test related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misc. bug: QwQ 32B doesn't put the reasoning content in message.reasoning_content
3 participants