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

Add an example of fast prediction via BLAS to documentation #427

Closed
inpefess opened this issue Mar 1, 2019 · 3 comments
Closed

Add an example of fast prediction via BLAS to documentation #427

inpefess opened this issue Mar 1, 2019 · 3 comments

Comments

@inpefess
Copy link

inpefess commented Mar 1, 2019

There is already one optimisation PR for predict method: #105

But sometimes one probably can do it in a simpler way (just using numpy with BLAS):
https://github.com/inpefess/lightfm/blob/predict_comparison/examples/batch_predict/predicting_with_matrix_multiplication.ipynb

@maciejkula what do you think about adding another, say predict_numpy/predict_all method like that for batch predictions? If yes, I can prepare a PR from the example code above.

@maciejkula
Copy link
Collaborator

One of the reasons of the get_item/user_embeddings method is to allow fast prediction via BLAS, as you do in your example.

There are tricky balancing issues here:

  1. Materializing the embedding matrices is slow.
  2. Materialized matrices are large.
  3. There is an operating point where predict is faster than doing the above.
  4. What does the signature of the hypothetical fast_predict function look like? Does it compute recommendations for all users? A subset of users? All products? Subset of products? How much memory does it take to store all predictions for all users?

For that reason I have so far been reluctant to add this to the library. If you're interested, we could add a guide for fast predictions to the documentation?

@inpefess
Copy link
Author

inpefess commented Mar 4, 2019

A scenario which I encountered myself in a couple of projects and which several people I consulted also had is the following:

  • there are not too many items (all item_embeddings can fit the memory of one server)
  • prediction is done by batches of users
  • recommendations for one batch of users and all items fit into the memory of one server

In this scenario, one needs a function computing recommendations for a batch of users.
I agree that this case is far from being universal, but it could be useful for some people.

@inpefess inpefess changed the title Is faster predict possible? Add an example of fast prediction via BLAS to documentation Mar 4, 2019
@SimonCW
Copy link
Collaborator

SimonCW commented Jan 24, 2021

I’m closing this issue because it has been inactive for a long time. If you still encounter the problem, please open a new issue.

Thank you!

@SimonCW SimonCW closed this as completed Jan 24, 2021
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