Extend ContrastiveOutput to support sequential encoders #1086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals ⚽
This PR adds support for negative sampling to the ContrastiveOutput class for session-based models where the query encoder returns a 3-D ragged tensor.
Implementation Details 🚧
Testing Details 🔍
Benchmark 🔍
I used the session-based script (implemented here)) to perform a benchmark of sampled softmax in various configurations, similar to the study conducted in T4Rec (available here)).
Commandline
I use the first four days for training and evaluation is computed for the fifth day. Here is the base command line with the utilized hparam:
The hparams that are changed for the experiments are --sampled_softmax (enables sampled softmax if provided), --logq_correction, and --num_negatives (number of negative samples).
Results
The results can be seen in the following table. Average examples/sec represents the throughtput and Recall and NDCG are accuracy top-k metrics.