Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeWarning: invalid value encountered in divide #68

Closed
Und3r1ine opened this issue Nov 19, 2024 · 3 comments
Closed

RuntimeWarning: invalid value encountered in divide #68

Und3r1ine opened this issue Nov 19, 2024 · 3 comments

Comments

@Und3r1ine
Copy link

There is a RuntimeWarning in Fusion Retrieval: invalid value encountered in divide.
The related code is

vector_scores = 1 - (vector_scores - np.min(vector_scores)) / (np.max(vector_scores) - np.min(vector_scores))                                                        
bm25_scores = (bm25_scores - np.min(bm25_scores)) / (np.max(bm25_scores) -  np.min(bm25_scores))    

A suggestion to add an epsilon to prevent division by zero issues.

epsilon = 1e-8
vector_scores = 1 - (vector_scores - np.min(vector_scores)) / (np.max(vector_scores) - np.min(vector_scores) + epsilon)                                                        
bm25_scores = (bm25_scores - np.min(bm25_scores)) / (np.max(bm25_scores) -  np.min(bm25_scores) + epsilon)    
@NirDiamant
Copy link
Owner

Hi, thanks for that. would you like to open a PR and with a fix?

@HagaiAstrin
Copy link
Contributor

Hi, thanks for that. would you like to open a PR and with a fix?

Hey, I opened a PR with a fix.

@NirDiamant
Copy link
Owner

thanks, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants