MultipleChoice評価でfew-shotリーク検査が機能しない問題を修正 - #293
Open
kiakiraki wants to merge 1 commit into
Open
Conversation
few_shot_generatorに"choices"キーを注入したtemplate_inputsを渡していた ため、サンプル済みインスタンスのinputs("choices"を含まない)との等価 比較が絶対に成立せず、num_trials_to_avoid_leakによるリーク検査が no-opになっていた。evaluate_generation.pyと同様に未加工の eval_instance.inputsを渡すことで検査が機能するようにする。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kiakiraki
marked this pull request as ready for review
July 19, 2026 01:06
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.
概要
MultipleChoice 評価で few-shot リーク検査(
num_trials_to_avoid_leak)が構造的に無効になっていた問題を修正します。問題
FewShotGenerator.__call__(few_shot_generator/base.py)は、サンプルした few-shot 例のinputsが評価インスタンスのeval_inputsと一致した場合に再サンプリング・最終的にValueErrorを発生させるリーク検査を持っています。しかし
evaluate_multiple_choice.pyだけは、プロンプト埋め込み用に"choices"キーを注入した後のtemplate_inputsを検査に渡していました:比較相手の
sampled.inputsは"choices"キーを含まないため、同一インスタンスでも dict の等価比較が絶対に成立せず、リーク検査は常に「リークなし」を返す no-op になっていました。評価インスタンスと同じ問題(正解付き)が few-shot 例としてプロンプトに混入しても、エラーにも警告にもならず精度が水増しされ得ます。evaluate_generation.py/evaluate_chat_response.pyは未加工のinputsを渡しており、この問題は MultipleChoice 経路のみです。修正
few-shot 生成器には
"choices"注入前のeval_instance.inputsを渡すようにしました(evaluate_generation.pyと同じ構造)。"choices"の注入はプロンプトテンプレート用のtemplate_inputs構築時のみ行います。再現確認方法
リークが必ず発生する状況(few-shot プール=評価データセット、
num_shots= データセット全件)を作ると:ValueErrorにならず評価が最後まで「成功」する(リーク未検出。答えがプロンプトに含まれるため accuracy は 1.0 になる)Few-shot instance has the same inputs as the evaluation instance, which indicates a data leak.のValueErrorが発生するこの検証をそのまま回帰テスト
test_evaluate_multiple_choice_detects_few_shot_leakとして追加しています(修正コミットを外すと failed になることを確認済み)。影響範囲
_sample_instancesはeval_inputsをサンプリングに使用していないため)。ValueErrorで失敗するようになります。これはnum_trials_to_avoid_leak本来の設計通りの挙動です。preset_configs/EvalSetup/*multiple_choice/の全プリセットは few-shot にtrain、評価にtest/validationを使う分離構成であることを確認済みです。_sample_instancesでeval_inputs["choices"]を参照するカスタムFewShotGeneratorを使っている場合、このキーは渡されなくなります(Generation / ChatResponse 経路は元々未加工inputsのみを渡しており、本修正で全経路の契約が統一されます)。🤖 Generated with Claude Code