feat: atropos reward registry - pluggable reward bridge - #68
Conversation
Summary of ChangesHello, 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 flexible reward registry for the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a pluggable reward registry to gracefully handle unknown data sources in Atropos, which is a solid improvement. The implementation is generally good, but I've identified a couple of areas in atropos_reward/reward_registry.py where robustness can be improved. Specifically, I'm suggesting a refactoring of the _gsm8k_score function to fix a correctness bug and improve its reliability, and enhancing the error handling when calling the verl built-in reward function.
| if not solutions: | ||
| # flexible fallback | ||
| numbers = re.findall(r"(\-?[0-9\.,]+)", solution_str) | ||
| final = None | ||
| for n in reversed(numbers): | ||
| if n not in ["", "."]: | ||
| final = n | ||
| break | ||
| else: | ||
| final = solutions[-1].replace(",", "").replace("$", "") | ||
|
|
||
| if final is None: | ||
| return 0.0 | ||
| try: | ||
| gt = str(ground_truth).replace(",", "").replace("$", "").strip() | ||
| return 1.0 if final.strip() == gt else 0.0 | ||
| except Exception: | ||
| return 0.0 |
There was a problem hiding this comment.
The current implementation of _gsm8k_score has a few issues that affect its correctness and robustness:
- Inconsistent Cleaning: The fallback logic for number extraction does not clean the extracted string (e.g., removing
,or$), while the primary path for####answers does. This can lead to incorrect comparisons. - Broad Exception: The
except Exceptionclause is too broad and can hide underlying bugs. It's better to catch more specific exceptions.
I suggest refactoring this section to address these points. The proposed change unifies the logic to ensure the extracted number string is always cleaned and catches more specific exceptions, making the function more reliable.
| if not solutions: | |
| # flexible fallback | |
| numbers = re.findall(r"(\-?[0-9\.,]+)", solution_str) | |
| final = None | |
| for n in reversed(numbers): | |
| if n not in ["", "."]: | |
| final = n | |
| break | |
| else: | |
| final = solutions[-1].replace(",", "").replace("$", "") | |
| if final is None: | |
| return 0.0 | |
| try: | |
| gt = str(ground_truth).replace(",", "").replace("$", "").strip() | |
| return 1.0 if final.strip() == gt else 0.0 | |
| except Exception: | |
| return 0.0 | |
| final = None | |
| if not solutions: | |
| # flexible fallback | |
| numbers = re.findall(r"(\-?[0-9\.,]+)", solution_str) | |
| for n in reversed(numbers): | |
| if n not in ["", "."]: | |
| final = n | |
| break | |
| else: | |
| final = solutions[-1] | |
| if final is None: | |
| return 0.0 | |
| final = final.replace(",", "").replace("$", "") | |
| try: | |
| gt = str(ground_truth).replace(",", "").replace("$", "").strip() | |
| return 1.0 if final.strip() == gt else 0.0 | |
| except (ValueError, TypeError): | |
| return 0.0 |
Adds a pluggable reward registry that complements the existing Atropos integration (#61).
Problem: verl raises NotImplementedError for unknown data sources, causing crashes with custom environments (see verl#5558, verl#5531, verl#5536).
Solution: RewardRegistry gracefully handles unknown data sources by trying verl built-ins first, then registered handlers, then Atropos scoring, then returning 0.0.
Built-in: openai/gsm8k handler with flexible answer extraction. 5/5 tests passing.
Companion to verl-project/verl#5520.