fix(ai-sdk): make interpretation-intent override reliably win (#35)
CI / detect-changes (push) Successful in 8s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Successful in 4s
CI / validate-canonical-controls (push) Successful in 2s
CI / loc-budget (push) Successful in 18s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Successful in 57s
CI / iace-gt-coverage (push) Successful in 15s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
CI / detect-changes (push) Successful in 8s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Successful in 4s
CI / validate-canonical-controls (push) Successful in 2s
CI / loc-budget (push) Successful in 18s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Successful in 57s
CI / iace-gt-coverage (push) Successful in 15s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
This commit was merged in pull request #35.
This commit is contained in:
@@ -16,7 +16,7 @@ const (
|
|||||||
scopePenalty = 0.25 // BDSG Teil 3 (law enforcement) on a general DP question
|
scopePenalty = 0.25 // BDSG Teil 3 (law enforcement) on a general DP question
|
||||||
topicGain = 0.18 // amplifier only
|
topicGain = 0.18 // amplifier only
|
||||||
supersededPenalty = 0.50 // superseded Alt-Quelle (pre-eu-v1): demoted, nicht versteckt
|
supersededPenalty = 0.50 // superseded Alt-Quelle (pre-eu-v1): demoted, nicht versteckt
|
||||||
guidanceIntentGain = 0.25 // controlled guidance override on explicit interpretation intent
|
guidanceIntentGain = 0.10 // epsilon a qualifying guideline is lifted ABOVE the best binding hit
|
||||||
guidanceIntentMargin = 0.05 // ...only if the guideline is semantically competitive with binding
|
guidanceIntentMargin = 0.05 // ...only if the guideline is semantically competitive with binding
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -110,17 +110,36 @@ func rerankByAuthority(query string, results []LegalSearchResult) []LegalSearchR
|
|||||||
copy(out, results)
|
copy(out, results)
|
||||||
for i := range out {
|
for i := range out {
|
||||||
out[i].Score = authorityScore(query, out[i], qDomain, qForeign)
|
out[i].Score = authorityScore(query, out[i], qDomain, qForeign)
|
||||||
// Interpretations-Intent (eng begrenzt): NUR wenn die Query explizit nach
|
}
|
||||||
// Guidance/Auslegung fragt UND die Leitlinie semantisch konkurrenzfaehig ist
|
if wantsGuidance {
|
||||||
// (>= bester binding-Treffer - margin), darf supervisory_guidance die bindende
|
applyGuidanceIntent(out, results, bestBindingSem)
|
||||||
// Norm ueberholen. Sonst bleibt binding > guidance (Normfrage unveraendert).
|
|
||||||
if wantsGuidance && out[i].SourceClass == "supervisory_guidance" &&
|
|
||||||
results[i].Score >= bestBindingSem-guidanceIntentMargin {
|
|
||||||
out[i].Score += guidanceIntentGain
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sort.SliceStable(out, func(a, b int) bool {
|
sort.SliceStable(out, func(a, b int) bool {
|
||||||
return out[a].Score > out[b].Score
|
return out[a].Score > out[b].Score
|
||||||
})
|
})
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// applyGuidanceIntent lifts semantically-competitive guidance just ABOVE the best
|
||||||
|
// binding hit (ordered by semantic), so an EXPLICIT interpretation question can
|
||||||
|
// return guidance Top-1. Obligation questions (no intent → not called) keep
|
||||||
|
// binding on top. Guidance below the semantic margin is left untouched, so an
|
||||||
|
// off-topic guideline can never ride the override — and the lift is computed from
|
||||||
|
// the binding FINAL score, so authority/topic/domain bonuses cannot edge it out.
|
||||||
|
func applyGuidanceIntent(out, raw []LegalSearchResult, bestBindingSem float64) {
|
||||||
|
bestBindingFinal := 0.0
|
||||||
|
for i := range out {
|
||||||
|
if out[i].SourceClass == "binding_law" && out[i].Score > bestBindingFinal {
|
||||||
|
bestBindingFinal = out[i].Score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range out {
|
||||||
|
if out[i].SourceClass != "supervisory_guidance" || raw[i].Score < bestBindingSem-guidanceIntentMargin {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lifted := bestBindingFinal + guidanceIntentGain + (raw[i].Score - bestBindingSem)
|
||||||
|
if lifted > out[i].Score {
|
||||||
|
out[i].Score = lifted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user