Skip to content

Instantly share code, notes, and snippets.

@gauravchak
Created January 15, 2024 18:56
Show Gist options
  • Save gauravchak/eaabe02cd5d7b2418dd24161381c7a9c to your computer and use it in GitHub Desktop.
Save gauravchak/eaabe02cd5d7b2418dd24161381c7a9c to your computer and use it in GitHub Desktop.
Schematic of two tower user and item encoder
# Compute the user embedding
user_embedding = self.compute_user_embedding(
user_id, user_features, user_history
) # [B, DU]
# Compute item embeddings
item_embeddings = self.compute_item_embeddings(
item_id, item_features
) # [B, DI]
# Compute the scores for every pair of user and item
scores = torch.matmul(user_embedding, item_embeddings.t())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment