This commit is contained in:
wyn
2026-05-21 14:37:04 +08:00
parent 6f76c483ec
commit 3663dd4ea6
2 changed files with 38 additions and 10 deletions

View File

@@ -709,13 +709,27 @@ PROMPT;
}
/**
* 将模型输出的 confidence 吸附到固定档位,并与 is_match 规则对齐
* 与 buildReferenceCheckSystemPrompt3 一致的 confidence 档位
*/
private function getReferenceCheckConfidenceBands($isMatch)
{
return $isMatch
? [0.65, 0.78, 0.85, 0.92, 0.98]
: [0.15, 0.25, 0.35, 0.45];
}
/**
* 将模型输出的 confidence 吸附到合法档位(如 0.95 → 0.920.75 → 0.78
*/
private function snapReferenceCheckConfidence($confidence, $isMatch)
{
$matchBands = [0.75, 0.85, 0.95];
$mismatchBands = [0.15, 0.25, 0.35];
$bands = $isMatch ? $matchBands : $mismatchBands;
$bands = $this->getReferenceCheckConfidenceBands($isMatch);
foreach ($bands as $band) {
if (abs($confidence - $band) < 0.001) {
return $band;
}
}
$nearest = $bands[0];
$minDiff = abs($confidence - $nearest);
@@ -726,6 +740,7 @@ PROMPT;
$nearest = $band;
}
}
return $nearest;
}