High frequency credentials dominate the search even when the label or user text is not at all close to the search query. #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Credentials that are used very often end dominating other credentials and show up in the search result even when they don't have any text or part of text even close to the search query.
The string scoring should have a higher bias, frequency scoring should also flatten out faster and harder to prevent frequency dominance in search results.
Actual Example
labplutoglis no where near related toyelo_analytics_dbyet it surfaced because it has a relatively high access count.Access Count
Bug: Behavioral metrics are overpowering string matches & prefix inversion
Problem Statement: The current search algorithm suffers from two fundamental ranking flaws. First, "behavioral dominance" allows highly-used credentials to bypass the
MIN_SCORE_THRESHOLDand surface over actual text matches strictly based on usage history. Second, an unbounded string scoring logic creates an "inversion zone" where partial prefix matches can mathematically outrank exact matches.Here is the mathematical breakdown of the flaws and the proposed structural fixes.
1. Frequency Scoring is not flat enough
The logarithmic growth of our current frequency score scales too aggressively, allowing high-usage credentials to permanently dominate the ranking.
Current Formula:
f(x) = \frac{\log(x + 1)}{5.0}f(200) = 1.06\leftarrowSurpasses 1.0 at just 200 accesses, overpowering the base string score (which is theoretically bounded at 1.0).f(2000) = 1.52Proposed Formula:
g(x) = \frac{\log(x + 1)}{15.0}g(200) = 0.35g(2000) = 0.50\leftarrowStays comfortably within the desired bounds. It will never exceed 1.0 under realistic usage patterns.Mathematical Outcome:
We achieve a
3\timesflatter curve.f'(x) = \frac{1}{5(x+1)}g'(x) = \frac{1}{15(x+1)} = \boxed{f'(x) \times \frac{1}{3}}2. The Additive Nature of the Combined Scoring
Currently, the final combined score places behavioral metrics on the same additive plane as the text match:
Score = (S_{\text{label}} \times 0.60) + (S_{\text{user}} \times 0.20) + (S_{\text{recency}} \times 0.12) + (S_{\text{frequency}} \times 0.05)Because it is additive, a credential with massive behavioral scores can pass the visibility threshold even if it shares zero characters with the search query (e.g.,
Score = 0.0 + 0.25 = 0.25).To fix this, we are switching to a multiplicative model where behavior acts as an amplifier to an existing text match, rather than an independent score provider:
Score = \text{StringScore} \times (1.0 + (S_{\text{recency}} \times 0.12) + (S_{\text{frequency}} \times 0.05))(where
\text{StringScore} = (S_{\text{label}} \times 0.60) + (S_{\text{user}} \times 0.20))The base
1.0ensures a perfect text match retains its core score, while the behavioral metrics act strictly as a percentage bonus. If the text match is0.0, the final score mathematically collapses to0.0.3. The Prefix Inversion (Asymptotic Gap Closing)
Currently,
PREFIX_BOOST = 1.0and is added directly to the similarity score. A partial prefix match (e.g., searching "git" for "github") evaluates toS_{\text{sim}} + 1.0, which yields an unbounded score> 1.0. Because an exact match strictly returns1.0, a partial prefix match will mathematically outrank a flawless exact match.The Fix: Asymptotic Gap Closing
Instead of adding a flat integer and breaking the ceiling, the boost should close a percentage of the remaining gap to
1.0.S_{\text{boosted}} = S_{\text{sim}} + ((1.0 - S_{\text{sim}}) \times \beta)(where
\beta = 0.80for Prefix, and0.40for Substring)Mathematical Rigour:
S_1 > S_2, thenS_1 + (1.0 - S_1)\beta > S_2 + (1.0 - S_2)\beta. The relative Levenshtein ranking is perfectly maintained; better partial matches still beat worse partial matches.\lim_{S \to 1} S_{\text{boosted}} = 1.0. The score approaches1.0asymptotically but never actually breaches it, guaranteeing exact matches remain the undisputed ceiling without requiring hacky hard-clamps.Proposed Action Items
frequencyScoredivisor from5.0to15.0.ScoreQueryto use the multiplicative base structure.PREFIX_BOOSTandSUBSTRING_BOOSTwith asymptotic gap-closing multipliers (0.80and0.40respectively) instringScore.Also requires adding certain base case unit testing to ensure any changes to the search algorithm does not break expected behavior.