tensorflow / tensorflow/recommenders
How to match embedding dimensions for different cardinalities of user and item sets?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 300
- PR merge metrics
- No merged PRs in 30d
Description
Thanks for the developers and for the community for the library and the excellent questions and answers.
According to this source, it is usually a good rule of thumb to specify the embedding dimension as the 4th square root of the number of unique categories.
Let's say I have a user space with a cardinality of 400k. The cardinality of the item space is 25k. I would trivially expect that the former requires a larger number for the embedding dimension. If we apply the rule of thumb, the emedding dimension for the Query tower would be around 25, while for the Candidate tower it would be ~13. Let's say that we also add context features to the user and item embeddings, so suppose that the final vectors would be of size 40 and 25, respectively.
My questions is, how to compute the inner product between these vectors? Should I add 1-s to the shorter one, or is there any solution applied in this case?
Another question is related to the size of the embeddings. With the above mentioned cardinalities, the two embedding matrices would be of sizes of 400_000 x 25 and 25_000 x 13. Is there any practical solutions how to make the training faster, instead of trainng such a large embeddings? I was thinking about to split the user space in a stratified way and train different models for each of the user subsets.
Also, because the item space is much smaller than the user space, the concerns described in #279 could be much relevant for this use-case, as the user-item interactions are not so sparse here, as in the case of youtube user-item interactions, for example.
Contributor guide
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
The issue names no repository files, tests, or entry points. Start by reading the linked TensorFlow Feature Columns source and related issue #279; the requested guidance would need to explain unequal embedding dimensions, large embedding matrices, and the practical training trade-offs, but the issue does not define a concrete documentation target or completion test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100