Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cookbooks/fireworks-rl-training/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def grade_final_integer(answer: object, expected: int) -> EvaluationResult:
"""Grade an integer on the last nonempty line, allowing thousands separators."""
text = (answer if isinstance(answer, str) else str(answer)).strip()
final = text.splitlines()[-1].strip() if text else ""
final = (
re.sub(r"\\boxed\{\s*([^{}]+?)\s*\}", r"\1", final.rstrip(".")).strip("$*` \t").rstrip(".")
)
got = (
int(final.replace(",", ""))
if re.fullmatch(r"[+-]?(?:\d+|\d{1,3}(?:,\d{3})+)", final)
Expand Down
5 changes: 4 additions & 1 deletion cookbooks/fireworks-rl-training/test_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ def test_default_renderer_matches_qwen38_chat_template() -> None:
(4861, 3217, "The answer is 15637837, as calculated above.", 0.0),
(4861, 3217, "The answer is 15,637,837, as calculated above.", 0.0),
(2, 3, "6,", 0.0),
(4861, 3217, r"\boxed{15,637,837}", 0.0),
(4861, 3217, r"\boxed{15,637,837}", 1.0),
(4861, 3217, r"$\boxed{15,637,837}$", 1.0),
(4861, 3217, "**15,637,837**", 1.0),
(4861, 3217, "`15,637,837`", 1.0),
(4861, 3217, "Working...\n\n 15,637,837 \n \t\n", 1.0),
(4861, 3217, "+15,637,837", 1.0),
(4861, 3217, "15637837\n0", 0.0),
Expand Down
3 changes: 3 additions & 0 deletions docs/v6/cookbooks/fireworks-rl-training.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ env = Environment(name="fireworks-arithmetic")
def grade_final_integer(answer: object, expected: int) -> EvaluationResult:
text = (answer if isinstance(answer, str) else str(answer)).strip()
final = text.splitlines()[-1].strip() if text else ""
final = (
re.sub(r"\\boxed\{\s*([^{}]+?)\s*\}", r"\1", final.rstrip(".")).strip("$*` \t").rstrip(".")
)
got = (
int(final.replace(",", ""))
if re.fullmatch(r"[+-]?(?:\d+|\d{1,3}(?:,\d{3})+)", final)
Expand Down