Skip to content

Instantly share code, notes, and snippets.

View gauravchak's full-sized avatar
🏠

Gaurav Chakravorty gauravchak

🏠
View GitHub Profile
@gauravchak
gauravchak / gist:eaabe02cd5d7b2418dd24161381c7a9c
Created January 15, 2024 18:56
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())