NVIDIA-Merlin / NVIDIA-Merlin/Merlin

[QST] Help w/ exporting Retrieval Model.

Open
#1,092 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
907
Forks
129
PR merge metrics
No merged PRs in 30d

Description

❓ Questions & Help

Details

my current set up is on a vertex ai workbench w/ Tesla T4 GPU, 120 GB RAM, 32vCPUs, and using nvcr.io/nvidia/merlin/merlin-tensorflow:nightly container image.

I am currently working on a retrieval based model and depending on the version of the dataset I use, I cannot export the query tower.

The different dataset's that I've been using are as follows:

v3: various continuous and categorical features for both users and the items we want to recommend.

  • exporting the query tower works fine in this case.

v4: features of v3 + item embeddings generated from sentence transformer.

  • dim size is 384
  • in the NVTabular Workflow, I just tagged the embedding columns as item features. not sure if this is the cause of the issues but I wanted to include this just in case.

v5: features of v3 + item embeddings generated from sentence transformer + multi-hot encoding of user history as implicit feedback.

  • dim of multi-hot encoding is 332
  • in the NVTabular Workflow, I just tagged the these columns Categorify() >> TagAsUserFeatures(). not sure if this is the cause of the issues but I wanted to include this just in case.

so when training a model w/ either v4 or v5 and save the query encoder, I get the following message:
query_tower = model.query_encoder
query_tower.save(...)

Screen Shot 2024-01-03 at 12 04 30 PM
  • note: this screen shot is with v4, when using v5 ds, I get more functions that wont be available.

when I load the query_tower and then try to turn the model into a top_k_model I get another error.
query_tower = tf.keras.models.load_model(".../query_tower_based_on_v5",compile=False)
model = mm.TwoTowerModelV2(query_tower, candidate)
model.compile()
candidate_features = unique_rows_by_features(train, Tags.ITEM, Tags.ITEM_ID)
topk_model = model.to_top_k_encoder(candidate_features, k=10, batch_size=1)
error when trying to convert the model to a top k encoder

sorry for cutting the error message off but its talking about the encoder for the query tower.

sorry for being private w/ the data but its not public.

I hope i was able to portray the issue and any suggestions would be appreciated!

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 v4 and v5 NVTabular feature definitions and the full errors from query_tower.save/load_model and model.to_top_k_encoder. Compare the working v3 export with v4 and v5, then determine whether the added item embeddings or multi-hot user-history features cause the failure; done means the unsupported operation is reproduced and its cause or required change is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
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.