Skip to content

Add RL unit tests: normalize and match_approximately#3379

Merged
copybara-service[bot] merged 1 commit intomainfrom
hengtaoguo-rl
Mar 11, 2026
Merged

Add RL unit tests: normalize and match_approximately#3379
copybara-service[bot] merged 1 commit intomainfrom
hengtaoguo-rl

Conversation

@hengtaoguo
Copy link
Collaborator

@hengtaoguo hengtaoguo commented Mar 11, 2026

Description

Add two unit tests for RL utils:

  • normalize_final_answer: Various numeric/string formats ("1,000", "$100", "\boxed{100}", etc.)
  • match_format_approximately: Test reward/penalty logic with 0-4 matching tokens

Tests

CI

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link

🤖 Hi @hengtaoguo, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

## 📋 Review Summary

This PR successfully adds comprehensive unit tests for normalize_final_answer and match_format_approximately in the RL utilities. The added tests correctly evaluate formatting rewards and penalties as well as string normalization edge cases, contributing to better test coverage for RL post-training functionality.

🔍 General Feedback

  • Positive Highlight: The test coverage for normalize_final_answer correctly anticipates and verifies several tricky LaTeX edge cases such as wrapper extraction and shorthand expansions.
  • Testing Pattern: Consider breaking down monolithic test methods with multiple assertions (as seen in test_partial_format_scores and test_normalize_final_answer) into smaller, isolated test cases to improve diagnosability.
  • The mixing of unittest.TestCase with @pytest.mark.cpu_only remains consistent with the rest of the testing suite in this file, so no immediate action is needed on that front.

Copy link
Collaborator

@richjames0 richjames0 left a comment

Choose a reason for hiding this comment

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

lgtm

@copybara-service copybara-service bot merged commit 8e0aaf5 into main Mar 11, 2026
54 of 56 checks passed
@copybara-service copybara-service bot deleted the hengtaoguo-rl branch March 11, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants