Skip to content

fix sft example#212

Closed
garyzhang99 wants to merge 3 commits intoagentscope-ai:mainfrom
garyzhang99:fix/sft_template_data
Closed

fix sft example#212
garyzhang99 wants to merge 3 commits intoagentscope-ai:mainfrom
garyzhang99:fix/sft_template_data

Conversation

@garyzhang99
Copy link
Collaborator

Description

As the title says. The "prompt" part should be dict or list of dict

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

@garyzhang99 garyzhang99 requested a review from chenyushuo August 21, 2025 07:51
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 @garyzhang99, 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 addresses an issue in the SFT (Supervised Fine-Tuning) example data by updating the format of the 'prompt' and 'response' fields. Previously, these fields were simple strings, but they have been changed to a more structured dictionary format. This change is crucial for ensuring the example data correctly represents conversational turns, making it suitable for training models that expect distinct roles (like 'user' and 'assistant') in their input.

Highlights

  • Data Structure Update for SFT Examples: The 'prompt' and 'response' fields within the sft.jsonl file have been refactored. They are no longer simple string values but are now structured as dictionary objects. This change introduces explicit 'role' (e.g., 'user', 'assistant') and 'content' keys for each entry.
  • Alignment with Chat-based Formats: This modification ensures that the example data for Supervised Fine-Tuning (SFT) is compatible with models or systems expecting a chat-like message format, where prompts and responses are clearly delineated by roles.
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

This pull request aims to fix the SFT example data by changing the format of the prompt and response fields. The change to a structured dictionary format is a good step. However, I've identified two issues with the implementation. First, the data file contains duplicated entries which should be removed for clarity and correctness of tests. Second, and more critically, the prompt and response fields should be a list of dictionaries, not a single dictionary, to be compatible with the existing SFTFormatter. I have provided specific suggestions to address these points.

Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The prompt and response fields are formatted as dictionaries, but the SFTFormatter in trinity/data/core/formatter.py expects them to be lists of dictionaries. This is necessary for tokenizer.apply_chat_template and for concatenating prompt and response lists. Please wrap the dictionary for both prompt and response in a list ([]) on each line in this file.

{"prompt": [{"role": "user", "content": "Mr. Sam shared a certain amount of money between his two sons, Ken and Tony. If Ken got $1750, and Tony got twice as much as Ken, how much was the money shared?"}], "response": [{"role": "assistant", "content": "<think> \nKen got $1750. Tony got twice as much as Ken, so Tony got 2 x $1750 = $3500. The total amount shared between Ken and Tony is $1750 + $3500 = $5250.\n</think>\n<answer> $5250 </answer>"}]}

Comment on lines 5 to 8
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These lines (5-8) are exact duplicates of lines 1-4. To keep the test data clean and avoid potential issues, it would be best to remove these repeated entries.

@garyzhang99 garyzhang99 reopened this Aug 21, 2025
@garyzhang99
Copy link
Collaborator Author

/unittest-module-trainer

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
11 11 0 0 0 0 654ms

Tests

Test Name Status Flaky Duration
tests/trainer/trainer_test.py::TestTrainerCountdown::test_trainer 150ms
tests/trainer/trainer_test.py::TestStepAheadAsyncRL::test_trainer 62ms
tests/trainer/trainer_test.py::TestTrainerGSM8K_0_fsdp::test_trainer 47ms
tests/trainer/trainer_test.py::TestTrainerGSM8K_1_fsdp2::test_trainer 44ms
tests/trainer/trainer_test.py::TestTrainerSFTWarmupGSM8K::test_trainer 57ms
tests/trainer/trainer_test.py::TestTrainerDPO::test_trainer 31ms
tests/trainer/trainer_test.py::TestTrainerSFTCHATPAIR::test_trainer 29ms
tests/trainer/trainer_test.py::TestTrainerSFT::test_trainer 29ms
tests/trainer/trainer_test.py::TestFullyAsyncMode::test_fully_async_mode_0_queue 70ms
tests/trainer/trainer_test.py::TestFullyAsyncMode::test_fully_async_mode_1_priority_queue 67ms
tests/trainer/trainer_test.py::TestTrainerMIX::test_trainer 56ms

Github Test Reporter by CTRF 💚

@pan-x-c
Copy link
Collaborator

pan-x-c commented Aug 27, 2025

Fixed in #226

@pan-x-c pan-x-c closed this Aug 27, 2025
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

Comments