jpountz commented on issue #1043: LUCENE-9071: Speed up BM25 scores.
URL: https://github.com/apache/lucene-solr/pull/1043#issuecomment-562884448
 
 
   @bruno-roustant  It's not about multiplication vs. addition but more about 
preventing rounding errors from being in the way of monotonicity. The problem 
with `freq / (freq + norm)` is when `freq+norm` rounds down for a given value 
of `freq` and up for the next value. Then the score may decrease because the 
denominator suddenly grows slower than the numerator. Rewriting to 
`1-1/(1+freq*1/norm)` helps notably because `freq` only occurs once in the 
formula. `freq * 1/norm` is guaranteed to be non-decreasing when freq increases 
or when norm decreases given that multiplication and division round to the 
nearest float, and this property is maintained through composition via `x->1+x` 
and then `x ->1-1/x`. Rounding errors can cause two consecutive frequencies to 
return the same score, but they can't break monotonicity in that case. 
`1/(1+norm/freq)` would work too but it performed slower in my testing.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to