Kind: Function
Source: atloria-monorepo/libs/parser-core/src/techdocs/grounded-ask.ts
Derive a confidence band from what retrieval actually returned and what the model actually grounded in — two signals already produced upstream, so no extra model call: • retrieval strength — the top hit's similarity (keyword-exact = 1, semantic = cosine) • grounding — how many retrieved sources the answer cited (validateCitations)
A cited answer over strong, corroborated retrieval is 'high'; a cited answer over a single decent source is 'medium'; cited-but-weak is 'low'. When the model cited NOTHING and retrieval was weak, there is no honest answer to give → 'insufficient' (the caller then substitutes INSUFFICIENT_EVIDENCE_ANSWER rather than surface a fabrication).
Signature
tsfunction deriveConfidence(sources: DocSearchHit[], citations: string[], thresholds: { strong: number; medium: number }): RagConfidence
Parameters
| Name | Type |
|---|---|
sources | DocSearchHit[] |
citations | string[] |
thresholds | { strong: number; medium: number } |
Returns: RagConfidence
Was this page helpful?