MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / validate_think_pattern

Function validate_think_pattern

trinity/common/rewards/eval_utils.py:111–124  ·  view source on GitHub ↗

Validate whether the tag is properly formatted.

(text)

Source from the content-addressed store, hash-verified

109
110
111def validate_think_pattern(text):
112 """Validate whether the <think> </think> tag is properly formatted."""
113 start_tag = "<think>"
114 end_tag = "</think>"
115
116 start_count = text.count(start_tag)
117 end_count = text.count(end_tag)
118
119 if start_count == 1 and end_count == 1:
120 start_pos = text.find(start_tag)
121 end_pos = text.find(end_tag)
122 if start_pos < end_pos:
123 return True
124 return False
125
126
127# Adapted from https://github.com/EleutherAI/lm-evaluation-harness/blob/main/lm_eval/tasks/hendrycks_math/utils.py

Callers 2

__call__Method · 0.90
__call__Method · 0.90

Calls 1

countMethod · 0.45

Tested by

no test coverage detected