tensorflow / tensorflow/recommenders

[Question]Retrieval with CategoricalCrossentropy really minimizing the affinity between the query and negative candidates?

Open
#560 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
300
PR merge metrics
No merged PRs in 30d

Description

In tfrs.tasks.retireval document, retrieval task is explained like
The main argument are pairs of query and candidate embeddings: the first row of query_embeddings denotes a query for which the candidate from the first row of candidate embeddings was selected by the user.The task will try to maximize the affinity of these query, candidate pairs while minimizing the affinity between the query and candidates belonging to other queries in the batch.
The default loss function of tfrs.tasks.Retrieval is tf.keras.losses.CategoricalCrossentropy. But in CategoricalCrossentropy, the loss of label 0 candidate become 0.

So,

  • if I use CategoricalCrossentropy for retrieval loss function, the label 1 candidate will affect loss value and embeddings, but the label 0 candidate will not.Is that right?
  • if I set num_hard_negatives argument with CategoricalCrossentropy loss, the number of negative(label 0)candidates will decrease, but the loss value will not change.Is that right?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked tfrs.tasks.Retrieval documentation and the behavior of tf.keras.losses.CategoricalCrossentropy. Trace how Retrieval.call handles candidate labels and num_hard_negatives, then clarify in the documentation whether label-0 candidates affect the loss and embeddings and whether hard-negative selection changes the loss.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.