Cannot learn from large numbers of interactions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 724
- PR merge metrics
- No merged PRs in 30d
Description
Hi there!
I'm trying to fit LightFM model on a quite large dataset: it contains ~13 million items and ~38.5 million users. But the main problem is that the number of interactions is more than 3 billion, this is > (2^32 - 1). And I have the following error while calling fit method:
File ~/.cache/pypoetry/virtualenvs/complementary-items-GrOWNq8P-py3.10/lib/python3.10/site-packages/lightfm/lightfm.py:684, in LightFM._run_epoch(self, item_features, user_features, interactions, sample_weight, num_threads, loss)
677 """
678 Run an individual epoch.
679 """
681 if loss in ("warp", "bpr", "warp-kos"):
682 # The CSR conversion needs to happen before shuffle indices are created.
683 # Calling .tocsr may result in a change in the data arrays of the COO matrix,
--> 684 positives_lookup = CSRMatrix(
685 self._get_positives_lookup_matrix(interactions)
686 )
688 # Create shuffle indexes.
689 shuffle_indices = np.arange(len(interactions.data), dtype=np.int32)
File lightfm/_lightfm_fast_openmp.pyx:167, in lightfm._lightfm_fast_openmp.CSRMatrix.__init__()
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
I guess this problem caused by using int type for num interactions in CPython-file _lightfm_fast_openmp.c. Is there a plan to expand the data type to long?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at LightFM._run_epoch in lightfm/lightfm.py and follow its construction of CSRMatrix in lightfm/_lightfm_fast_openmp.pyx and the generated C implementation referenced by the issue. Reproduce the fit failure with interaction counts above 2^32, then verify that the relevant integer and buffer types remain compatible and the model can learn from the larger interaction set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100