mongodb-rag-core
Version:
Common elements used by MongoDB Chatbot Framework components.
22 lines (20 loc) • 1.11 kB
TypeScript
export interface ComputeNormalizedLogarithmicQueryEfficiencyParams {
/** Number of documents returned by the query */
nReturned: number;
/** Number of documents examined by the query */
nExamined: number;
/** Total number of documents in the collection. */
nTotal: number;
}
/**
Computes a normalized query efficiency score based on the logarithmic relationship
between documents examined and documents returned. The score ranges from 0 to 1, where:
- 1 means perfect efficiency (n_examined = n_returned)
- 0 means full scan with minimal results
- Score decreases logarithmically as examination overhead increases
- Formula: 1 - log((n_examined+eps2)/(n_returned+eps2)) / log((n_total+eps1)/(n_returned+eps2))
- Uses epsilon values for numerical stability and to handle zero-result queries
@returns A score between 0 and 1
*/
export declare function computeNormalizedLogarithmicQueryEfficiency({ nReturned, nExamined, nTotal, }: ComputeNormalizedLogarithmicQueryEfficiencyParams): number;
//# sourceMappingURL=computeNormalizedLogarithmicQueryEfficiency.d.ts.map