Reasoning_parserでマッチしなかった時にlm_outputがNoneではなく空文字列になるように変更 - #291
Merged
Conversation
UnifiedRegexReasoningParser/SeparatedRegexReasoningParser return Reasoning(text=None, ...) when the pattern fails to match, and this None was assigned directly to LMOutput.text, bypassing the None -> "" coercion in LMOutput.__post_init__. Downstream consumers that call re.findall() directly on LMOutput.text (llm_judge, llm_score, llm_label) would then raise an uncaught TypeError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
issue
#292
を解決するためのPR
変更
Reasoning_parserでマッチしなかった時にlm_outputがNoneではなく空文字列になるように変更
空文字列を返す理由
マッチ失敗した場合lm_outputとして考えられるのは以下の二通り
resoning_contentをそのまま返す場合、生の思考過程がそのまま judge や他の下流メトリクスに渡ってしまい、
といった問題が発生する可能性がある。
"" であれば「reasoningが未完了/失敗=有効な回答なし」として扱われ、少なくとも安全側(スコアが不当に高くならない方向)に倒せると考えこのような実装になっています。
備考
^(?:(?P<reasoning_content>.*)</think>\\s*)?(?P<content>.*)$'のように、マッチしない場合は全ての文字列をマッチさせるようにすればresoning_contentをそのまま返す場合の挙動を再現することが可能