File size: 8,648 Bytes
6077218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
[
  {
    "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"
      }
    ]
  }
]