[ { "function_name": "AlphaRec.__init__", "file_path": "models/General/canonical.py", "function_calls": [ { "function_call_name": "super().__init__", "functionality": "Calls the parent class (AbstractModel) constructor.", "input": "args, data", "output": "", "location_or_namespace": "models/General/base/abstract_model.py" }, { "function_call_name": "torch.tensor", "functionality": "Creates a tensor from data.", "input": "self.init_user_cf_embeds, dtype=torch.float32", "output": "Tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.Tensor.cuda", "functionality": "Moves tensor to the specified CUDA device.", "input": "self.device", "output": "Tensor on CUDA device", "location_or_namespace": "torch" }, { "function_call_name": "nn.Linear", "functionality": "Creates a linear transformation module.", "input": "self.init_embed_shape, self.embed_size, bias=False", "output": "Linear module", "location_or_namespace": "torch.nn" }, { "function_call_name": "nn.Sequential", "functionality": "Combines modules in sequence.", "input": "layers/modules", "output": "Sequential module", "location_or_namespace": "torch.nn" }, { "function_call_name": "nn.LeakyReLU", "functionality": "Leaky ReLU activation function.", "input": "", "output": "LeakyReLU module", "location_or_namespace": "torch.nn" } ] }, { "function_name": "AlphaRec.init_embedding", "file_path": "models/General/canonical.py", "function_calls": [] }, { "function_name": "AlphaRec.compute", "file_path": "models/General/canonical.py", "function_calls": [ { "function_call_name": "self.mlp", "functionality": "Projects embeddings through the MLP or linear layer.", "input": "self.init_user_cf_embeds / self.init_item_cf_embeds", "output": "projected embeddings", "location_or_namespace": "" }, { "function_call_name": "torch.cat", "functionality": "Concatenates tensors along a dimension.", "input": "[users_emb, items_emb]", "output": "combined tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.sparse.mm", "functionality": "Sparse-dense matrix multiplication.", "input": "g_droped, all_emb", "output": "updated embeddings", "location_or_namespace": "torch" }, { "function_call_name": "torch.stack", "functionality": "Stacks sequence of tensors along new dimension.", "input": "embs, dim=1", "output": "stacked tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.mean", "functionality": "Averages tensor elements along given dimension.", "input": "embs, dim=1", "output": "averaged embeddings", "location_or_namespace": "torch" }, { "function_call_name": "torch.split", "functionality": "Splits tensor into chunks.", "input": "light_out, [self.data.n_users, self.data.n_items]", "output": "users, items", "location_or_namespace": "torch" } ] }, { "function_name": "AlphaRec.forward", "file_path": "models/General/canonical.py", "function_calls": [ { "function_call_name": "self.compute", "functionality": "Computes user and item embeddings after projection and graph convolution.", "input": "", "output": "all_users, all_items", "location_or_namespace": "" }, { "function_call_name": "F.normalize", "functionality": "Normalizes tensor along specified dimension.", "input": "users_emb/pos_emb/neg_emb, dim=-1", "output": "normalized tensor", "location_or_namespace": "torch.nn.functional" }, { "function_call_name": "torch.sum", "functionality": "Sums tensor elements along a dimension.", "input": "users_emb*pos_emb, dim=-1", "output": "pos_ratings", "location_or_namespace": "torch" }, { "function_call_name": "torch.matmul", "functionality": "Matrix product of two tensors.", "input": "torch.unsqueeze(users_emb, 1), neg_emb.permute(0, 2, 1)", "output": "neg_ratings", "location_or_namespace": "torch" }, { "function_call_name": "torch.unsqueeze", "functionality": "Adds singleton dimension to tensor.", "input": "users_emb, 1", "output": "reshaped tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.permute", "functionality": "Permutes dimensions of tensor.", "input": "neg_emb, (0, 2, 1)", "output": "reshaped tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.exp", "functionality": "Element-wise exponential.", "input": "pos_ratings / self.tau, neg_ratings / self.tau", "output": "exponentiated tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.mean", "functionality": "Mean of all tensor elements.", "input": "torch.negative(torch.log(numerator/denominator))", "output": "scalar loss", "location_or_namespace": "torch" }, { "function_call_name": "torch.negative", "functionality": "Negates tensor values.", "input": "torch.log(numerator/denominator)", "output": "", "location_or_namespace": "torch" }, { "function_call_name": "torch.log", "functionality": "Natural logarithm, element-wise.", "input": "numerator/denominator", "output": "", "location_or_namespace": "torch" } ] }, { "function_name": "AlphaRec.predict", "file_path": "models/General/canonical.py", "function_calls": [ { "function_call_name": "self.compute", "functionality": "Computes user and item embeddings after projection and graph convolution.", "input": "", "output": "all_users, all_items", "location_or_namespace": "" }, { "function_call_name": "torch.tensor", "functionality": "Creates tensor from input.", "input": "users/items", "output": "Tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.Tensor.cuda", "functionality": "Moves tensor to the specified CUDA device.", "input": "self.device", "output": "Tensor on CUDA device", "location_or_namespace": "torch" }, { "function_call_name": "F.normalize", "functionality": "Normalizes tensor along specified dimension.", "input": "users/items, dim=-1", "output": "normalized tensor", "location_or_namespace": "torch.nn.functional" }, { "function_call_name": "torch.transpose", "functionality": "Swaps dimensions of a tensor.", "input": "items, 0, 1", "output": "transposed tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.matmul", "functionality": "Matrix product of two tensors.", "input": "users, items", "output": "rate_batch", "location_or_namespace": "torch" }, { "function_call_name": "torch.Tensor.cpu", "functionality": "Moves tensor to CPU.", "input": "", "output": "Tensor on CPU", "location_or_namespace": "torch" }, { "function_call_name": "torch.Tensor.detach", "functionality": "Returns tensor detached from computation graph.", "input": "", "output": "Detached tensor", "location_or_namespace": "torch" }, { "function_call_name": "torch.Tensor.numpy", "functionality": "Converts tensor to numpy array.", "input": "", "output": "Numpy array", "location_or_namespace": "torch" } ] } ]