Fix benchmarks/models/itemknn/README.md
#2
by NonameUntitled - opened
123456789101112131415161718192021## ItemKNNWe employ cosine similarity to measure the similarity between vectors. The item vectors are num_users-dimensional vectors derived from the user-item interaction matrix. In the simplest case, we generate top-k recommendations by retrieving the nearest vectors to the user’s most recent item (which corresponds to a decay parameter $\tau \rightarrow 0$). The more general formulation is as follows:$score(user_i, item_j) = cos(V[i, :], U[:,j])$,where $U$ is num_user x num_items interaction matrix,$V$ is num_users x num_users matrix, $V[i, :] = \sum_{(t, k) \in A_i} \tau^{max_t(i) - t} \cdot U[:, k]^T$, where $A_i$ is set of $i$-th user's (interaction_timestamp, item_index) pairs, $max_t(i)$ is last $i$-th user's interaction timestamp, $\tau$ is the decay coefficient (per second).The hyperparameter “hour” defines the time period (in hours) associated with a decay factor of 0.9.For 5b datasets, the matrix multiplications [num_users × num_item] and [num_item × num_items] to obtain [num_user x num_user] matrix of user embeddings exceed memory constraints. We also use cosine similarity to the mean embedding instead of pairwise similarities to avoid new dimension (x basket_size).123456789101112131415161718192021222324252627282930# ItemKNNWe employ cosine similarity to measure similarity between vectors. Item vectors are represented as num_users-dimensional vectors derived from the user-item interaction matrix.Top-k recommendations are generated by retrieving vectors closest to the user's temporal interaction pattern (with decay parameter \\(\tau \rightarrow 0\\)) controlling historical influence).The formulation is: \\(score(user_i, item_j) = \cos(V[i, :], U[:,j])\\),where:- \\(U\\) [num user \\(\times\\) num items]: original user-item interaction matrix- \\(V\\) [num users \\(\times\\) num users]: user embedding matrix, where each row is:\\(V[i, :] = \sum_{(t, k) \in A_i} \tau^{\max_t(i) - t} U[:, k]^T\\)- \\(A_i\\): set of \\(i\\)-th user's (interaction timestamp, item index) pairs- \\(\max_t(i)\\): last \\(i\\)-th user's interaction timestamp- \\(\tau\\): time decay coefficient (per second)The hyperparameter `hour` defines the time period (in hours) associated with a decay factor of 0.9.## Memory OptimizationFor 5b datasets, the matrix multiplications between [num users \\(\times\\) num item] and [num item \\(\times\\) num items] exceeds memory constraints.To solve this, we leverage cosine similarity to the mean embedding instead of pairwise similarities to avoid new dimension (x basket_size).
benchmarks/models/itemknn/README.md+16-7