Skip to content

Commit bb9b26d

Browse files
DanialTahericlaude
andauthored
feat(resources_servers): add string_match and gui_coordinate verifiers (#2332)
## Summary Adds two lightweight verifiers used by the blended Nemotron Super Omni RL dataset. `string_match` — exact/fuzzy answer comparison with boxed/latex extraction. Covers 14,988 of the 60,299 rows in that blend. `gui_coordinate` — 2D coordinate containment. Covers 16 rows. Both subclass `BaseVerifyResponse` and follow the existing simple-agent contract, so they need no special handling in the rollout path. Carrying them here removes the need for downstream launchers to copy verifier directories into the Gym checkout at submit time. --------- Signed-off-by: DanialTaheri <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent d055f37 commit bb9b26d

17 files changed

Lines changed: 850 additions & 0 deletions

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ The Dataset column links to publicly available datasets (e.g., on HuggingFace).
238238
| Graphwalks | other | Long-context graph-walks (BFS / parents) with F1-over-node-sets grading from openai/graphwalks | Improve long-context multi-step graph reasoning and adjacency-list traversal | - | - | - | <a href='resources_servers/graphwalks/configs/graphwalks.yaml'>graphwalks.yaml</a> | - |
239239
| Grl Sokoban | games | Single-box Sokoban in Gymnasium API style. | Model emits one move per turn until the puzzle is solved. | - | - | - | <a href='resources_servers/grl_sokoban/configs/grl_sokoban.yaml'>grl_sokoban.yaml</a> | - |
240240
| Grl Tetris | games | Tetris in Gymnasium API style. Model emits one or more moves per turn. | Multi-step Tetris environment | - | - | - | <a href='resources_servers/grl_tetris/configs/grl_tetris.yaml'>grl_tetris.yaml</a> | - |
241+
| Gui Coordinate | other | GUI coordinate grounding verifier for visual pointing tasks | Verify GUI coordinate predictions using smooth quadratic reward based on Euclidean distance | - | - | - | <a href='resources_servers/gui_coordinate/configs/gui_coordinate.yaml'>gui_coordinate.yaml</a> | - |
241242
| Gymnasium | other | Base class for Gymnasium-style servers. Not a standalone server. | Reusable base class for step/reset style environments | - | - | - | <a href='resources_servers/gymnasium/configs/gymnasium.yaml'>gymnasium.yaml</a> | - |
242243
| Harbor Agent | agent | Fast local smoketest task (trivial 1-turn task, no LLM judge) for iterating on the Gym<->Harbor bridge. | - | ✓ | - | - | <a href='responses_api_agents/harbor_agent/configs/harbor_agent_smoketest_docker.yaml'>harbor_agent_smoketest_docker.yaml</a> | - |
243244
| Harbor Agent | agent | Harbor integration for agent harnesses and environments. | Improve models in popular agentic environments supported by Harbor such as Terminus2. | - | - | - | <a href='responses_api_agents/harbor_agent/configs/harbor_agent_opensandbox.yaml'>harbor_agent_opensandbox.yaml</a> | - |
@@ -320,6 +321,7 @@ The Dataset column links to publicly available datasets (e.g., on HuggingFace).
320321
| Single Step Tool Use With Argument Comparison | agent | The model must output the next correct call in a given trajectory involving search tools. | Improve agentic search capability. | ✓ | ✓ | Apache 2.0 | <a href='resources_servers/single_step_tool_use_with_argument_comparison/configs/search_pivot_single_step_tool_use_with_argument_comparison.yaml'>search_pivot_single_step_tool_use_with_argument_comparison.yaml</a> | - |
321322
| Speed Bench | other | Speculative-decoding throughput benchmark. Reads vLLM `/metrics` Prometheus counters before/after generation to compute acceptance length and acceptance rate. | Measure inference-time speculative-decoding effectiveness for serving research and regression tests. | - | - | - | <a href='resources_servers/speed_bench/configs/speed_bench.yaml'>speed_bench.yaml</a> | - |
322323
| Spider2 Lite | coding | Text-to-SQL with execution-based evaluation on Spider 2.0-Lite (135 SQLite tasks). Binary reward based on result-set equivalence. | Improve text-to-SQL capabilities for real-world enterprise queries using execution-based binary reward without an LLM judge. | - | ✓ | - | <a href='resources_servers/spider2_lite/configs/spider2_lite.yaml'>spider2_lite.yaml</a> | - |
324+
| String Match | knowledge | General-purpose string matching verifier for free-form text answers | Verify answers via case-insensitive string matching with multiple extraction strategies | - | - | - | <a href='resources_servers/string_match/configs/string_match.yaml'>string_match.yaml</a> | - |
323325
| Structeval | instruction_following | StructEval non-renderable format verification (JSON, YAML, CSV, TOML, XML) | Improve structured output generation quality | ✓ | - | Apache 2.0 | <a href='resources_servers/structeval/configs/structeval_nonrenderable.yaml'>structeval_nonrenderable.yaml</a> | - |
324326
| Structured Outputs | instruction_following | Check if responses are following structured output requirements in prompts | Improve instruction following capabilities | ✓ | ✓ | Apache 2.0 | <a href='resources_servers/structured_outputs/configs/structured_outputs_json.yaml'>structured_outputs_json.yaml</a> | <a href='https://huggingface.co/datasets/nvidia/Nemotron-RL-instruction_following-structured_outputs'>Nemotron-RL-instruction_following-structured_outputs</a> |
325327
| Structured Outputs | instruction_following | Check if responses are following structured output requirements in prompts | Improve instruction following capabilities | ✓ | ✓ | Apache 2.0 | <a href='resources_servers/structured_outputs/configs/structured_outputs_json_yaml_xml_v1.yaml'>structured_outputs_json_yaml_xml_v1.yaml</a> | - |
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
import re
16+
from typing import Any, Optional
17+
18+
from fastapi import FastAPI
19+
20+
from nemo_gym.base_resources_server import (
21+
BaseResourcesServerConfig,
22+
BaseRunRequest,
23+
BaseVerifyRequest,
24+
BaseVerifyResponse,
25+
SimpleResourcesServer,
26+
)
27+
28+
29+
POINT_PATTERN = re.compile(r"<point>\s*\[?\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)\s*\]?\s*</point>")
30+
31+
32+
class GuiCoordinateResourcesServerConfig(BaseResourcesServerConfig):
33+
pass
34+
35+
36+
class GuiCoordinateRunRequest(BaseRunRequest):
37+
expected_answer: str # "x,y" normalized 0-1 coordinates
38+
max_dist: float = 0.15
39+
metadata: Optional[dict[str, Any]] = None
40+
41+
42+
class GuiCoordinateVerifyRequest(GuiCoordinateRunRequest, BaseVerifyRequest):
43+
pass
44+
45+
46+
class GuiCoordinateVerifyResponse(BaseVerifyResponse):
47+
expected_answer: str
48+
extracted_x: Optional[float]
49+
extracted_y: Optional[float]
50+
distance: Optional[float]
51+
52+
53+
def _extract_last_assistant_text(body: BaseVerifyRequest) -> str:
54+
texts: list[str] = []
55+
for o in body.response.output:
56+
if getattr(o, "type", None) == "message" and getattr(o, "role", None) == "assistant":
57+
content = getattr(o, "content", None)
58+
if isinstance(content, list):
59+
for c in content:
60+
t = getattr(c, "text", None)
61+
if isinstance(t, str):
62+
texts.append(t)
63+
elif isinstance(content, str):
64+
texts.append(content)
65+
return "\n".join(texts).strip()
66+
67+
68+
def _parse_gt(expected_answer: str) -> Optional[tuple[float, float]]:
69+
parts = expected_answer.split(",")
70+
if len(parts) != 2:
71+
return None
72+
try:
73+
return float(parts[0]), float(parts[1])
74+
except ValueError:
75+
return None
76+
77+
78+
def _parse_prediction(text: str) -> Optional[tuple[float, float]]:
79+
match = POINT_PATTERN.search(text)
80+
if not match:
81+
return None
82+
return int(match.group(1)) / 1000.0, int(match.group(2)) / 1000.0
83+
84+
85+
def _compute_reward(
86+
gt: tuple[float, float],
87+
pred: tuple[float, float],
88+
max_dist: float,
89+
) -> tuple[float, float]:
90+
dist = ((pred[0] - gt[0]) ** 2 + (pred[1] - gt[1]) ** 2) ** 0.5
91+
if dist >= max_dist:
92+
return 0.0, dist
93+
reward = (1.0 - dist / max_dist) ** 2
94+
return reward, dist
95+
96+
97+
class GuiCoordinateResourcesServer(SimpleResourcesServer):
98+
config: GuiCoordinateResourcesServerConfig
99+
100+
def setup_webserver(self) -> FastAPI:
101+
app = super().setup_webserver()
102+
return app
103+
104+
async def verify(self, body: GuiCoordinateVerifyRequest) -> GuiCoordinateVerifyResponse:
105+
text = _extract_last_assistant_text(body)
106+
gt = _parse_gt(body.expected_answer)
107+
pred = _parse_prediction(text)
108+
109+
reward = 0.0
110+
distance = None
111+
extracted_x = None
112+
extracted_y = None
113+
114+
if gt is not None and pred is not None:
115+
extracted_x, extracted_y = pred
116+
reward, distance = _compute_reward(gt, pred, body.max_dist)
117+
118+
return GuiCoordinateVerifyResponse(
119+
**body.model_dump(
120+
exclude={
121+
"expected_answer",
122+
"extracted_x",
123+
"extracted_y",
124+
"distance",
125+
}
126+
),
127+
reward=reward,
128+
expected_answer=body.expected_answer,
129+
extracted_x=extracted_x,
130+
extracted_y=extracted_y,
131+
distance=distance,
132+
)
133+
134+
135+
if __name__ == "__main__":
136+
GuiCoordinateResourcesServer.run_webserver()

0 commit comments

Comments
 (0)