Skip to content

Conversation

@natolambert
Copy link
Collaborator

@natolambert natolambert commented Nov 3, 2025

Note

Updates olmo_thinker_no_think to parse assistant messages, extract <think> content, and emit it as a dedicated reasoning block only after the last user turn before the assistant’s final content.

  • Dataset preprocessing — Chat templates:
    • open_instruct/dataset_transformation.py:
      • olmo_thinker_no_think:
        • Track last_user_index across messages.
        • For assistant turns, split content to extract reasoning between <think> ... </think> and the remaining assistant text.
        • If the assistant turn is after the last user and reasoning exists, emit a consolidated '<think>...\n</think>' block before assistant content; otherwise output assistant content only.
        • Preserve existing handling for functions, function_calls, and message boundaries/EOS.

Written by Cursor Bugbot for commit faab9de. This will update automatically on new commits. Configure here.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @natolambert, 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!

This pull request introduces a new message formatting template, olmo_thinker_no_think, to the open_instruct library. The primary purpose of this template is to standardize how conversational turns, particularly those involving the Olmo AI assistant, are structured. It specifically refines the presentation of the assistant's internal reasoning by extracting and consolidating 'thinking' content into a dedicated block, moving away from potentially interleaved formats. Additionally, it ensures consistent handling of system prompts and function calls across different message roles.

Highlights

  • New Jinja Template for Olmo: A new Jinja template, olmo_thinker_no_think, has been introduced in open_instruct/dataset_transformation.py to manage message formatting for the Olmo AI assistant.
  • Structured Thinking Content: This template processes assistant messages to extract and format 'thinking' content, presenting it within <think> tags as a distinct block, which aligns with the goal of removing interleaved thinking.
  • Function Call Handling: The template includes logic for handling and formatting function calls for system, user, and assistant messages, ensuring they are properly integrated into the conversation structure.
  • Default System Prompt: A default system prompt for Olmo is automatically added if no system message is explicitly provided in the conversation history.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

@natolambert natolambert force-pushed the olmo-thinker-no-think-strip branch from 97f65c4 to faab9de Compare November 3, 2025 19:40
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

This pull request introduces a new chat template, olmo_thinker_no_think, designed to remove interleaved thinking and control when reasoning is emitted. My review focuses on improving the robustness and consistency of this new template. I've identified a potential data loss issue in the parsing logic for the <think> block and an inconsistency in the default system prompt compared to other olmo templates. The suggested changes aim to make the template more reliable and align it with existing conventions.

Comment on lines +429 to +433
"{% if '</think>' in assistant_content %}"
"{% set think_split = assistant_content.split('</think>') %}"
"{% set reasoning_content = think_split[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}"
"{% set assistant_content = think_split[-1].lstrip('\\n') %}"
"{% endif %}"
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current logic for parsing the <think> block is fragile and can lead to data loss. Specifically, any content before the <think> tag is discarded. For example, if the assistant content is Preamble <think>reasoning</think> Answer, the preamble will be lost.

I suggest a more robust parsing logic that correctly handles content before and after the <think> block, and also ensures both <think> and </think> tags are present before attempting to split.

Suggested change
"{% if '</think>' in assistant_content %}"
"{% set think_split = assistant_content.split('</think>') %}"
"{% set reasoning_content = think_split[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}"
"{% set assistant_content = think_split[-1].lstrip('\\n') %}"
"{% endif %}"
"{% if '<think>' in assistant_content and '</think>' in assistant_content %}"
"{% set _before_think, _after_think = assistant_content.split('<think>', 1) %}"
"{% set _reasoning, _after_reasoning = _after_think.split('</think>', 1) %}"
"{% set reasoning_content = _reasoning.strip() %}"
"{% set assistant_content = (_before_think ~ _after_reasoning).lstrip('\\n') %}{% endif %}"

"olmo_thinker_no_think": (
"{% set has_system = messages|selectattr('role', 'equalto', 'system')|list|length > 0 %}"
"{% if not has_system %}"
"{{ '<|im_start|>system\nYou are Olmo, a helpful AI assistant built by Ai2. Your date cutoff is December 2024, and your model weights are available at https://huggingface.co/allenai.<|im_end|>\n' }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The default system prompt for olmo_thinker_no_think is missing information about function-calling capabilities. Other olmo templates include this, and the rest of this template handles functions. This inconsistency could be confusing. For consistency, I suggest updating the default system prompt to mention functions, similar to other olmo templates.

Suggested change
"{{ '<|im_start|>system\nYou are Olmo, a helpful AI assistant built by Ai2. Your date cutoff is December 2024, and your model weights are available at https://huggingface.co/allenai.<|im_end|>\n' }}"
"{{ '<|im_start|>system\nYou are Olmo, a helpful AI assistant built by Ai2. Your date cutoff is December 2024, and your model weights are available at https://huggingface.co/allenai. You do not currently have access to any functions. <functions></functions><|im_end|>\n' }}"

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