tensorflow / tensorflow/recommenders

index_from_dataset returns indices rather than movie names

Open
#650 3 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

Hello

In my code I added another feature to the candidate tower in addition to movie title (for each movie I have a vector representation of that movie which is precalculated using some other algorithms) and just feed it directly to the candidate tower.

interactions_dict = a dictionary

ratings = tf.data.Dataset.from_tensor_slices(interactions_dict)

movies = ratings.map(lambda x: {
    'movie_title' : x['movie_title'], 
    'movie_vector' : x['movie_vector'],

})
index = tfrs.layers.factorized_top_k.BruteForce(model.query_model,k=CANDIDATE_POOL_SIZE)
index.index_from_dataset(movies.batch(100).map(lambda x: model.candidate_model(x)))
    query_dict = {'user_id':tf.constant([user]),
              'user_vector':np.stack([user_vector])}

Any idea why title after running _, titles = index(query_dict) contains indices rather than the actual movie names?

Here is the call method in my candidate tower:


  def call(self, titles):
    return tf.concat([
        self.title_embedding(titles["movie_title"]),
        titles["movie_vector"]
    ], axis=1)

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 BruteForce index_from_dataset entry point and the provided movies dataset and candidate_model call. Check how indexed values are represented and returned by index(query_dict); done when the query result returns the expected movie names instead of numeric indices, with a regression test for this dataset shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.