File size: 14,839 Bytes
e89a301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
[
    {
        "function_name": "ContextGNN.__init__",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "super().__init__()",
                "functionality": "Initialize parent class (RHSEmbeddingGNN), which sets up global item embedding and config.",
                "input": "Arguments for the parent class RHSEmbeddingGNN.",
                "output": "None (initializes attributes and internal states).",
                "location_or_namespace": "contextgnn.nn.models.rhsembeddinggnn.RHSEmbeddingGNN"
            },
            {
                "function_call_name": "HeteroEncoder()",
                "functionality": "Encodes multi-modal tabular features for each node type.",
                "input": "channels, node_to_col_names_dict, node_to_col_stats, stype_encoder_cls_kwargs, torch_frame_model_cls, torch_frame_model_kwargs",
                "output": "torch.nn.Module that outputs node features.",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroEncoder"
            },
            {
                "function_call_name": "HeteroTemporalEncoder()",
                "functionality": "Encodes relative time for each node type as features using positional encodings.",
                "input": "node_types, channels",
                "output": "torch.nn.Module that outputs temporal node features.",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroTemporalEncoder"
            },
            {
                "function_call_name": "HeteroGraphSAGE()",
                "functionality": "Heterogeneous GNN for message passing over multi-relation graphs.",
                "input": "node_types, edge_types, channels, aggr, num_layers",
                "output": "torch.nn.Module that computes updated node features.",
                "location_or_namespace": "contextgnn.nn.models.HeteroGraphSAGE"
            },
            {
                "function_call_name": "MLP()",
                "functionality": "Multi-layer perceptron for transforming embeddings (used for scoring/prediction).",
                "input": "channels, out_channels=1, norm, num_layers",
                "output": "MLP module (torch.nn.Module) with output dimension out_channels.",
                "location_or_namespace": "torch_geometric.nn.MLP"
            },
            {
                "function_call_name": "torch.nn.Linear()",
                "functionality": "Linear transformation (fully connected layer) used for projection and offset scoring.",
                "input": "in_features, out_features",
                "output": "torch.nn.Linear module.",
                "location_or_namespace": "torch.nn"
            },
            {
                "function_call_name": "torch.nn.Embedding()",
                "functionality": "Creates an embedding matrix (ID awareness feature for user node).",
                "input": "num_embeddings, embedding_dim",
                "output": "Embedding lookup module.",
                "location_or_namespace": "torch.nn"
            }
        ]
    },
    {
        "function_name": "ContextGNN.reset_parameters",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "super().reset_parameters()",
                "functionality": "Calls reset_parameters on the parent RHSEmbeddingGNN.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "contextgnn.nn.models.rhsembeddinggnn.RHSEmbeddingGNN"
            },
            {
                "function_call_name": "self.encoder.reset_parameters()",
                "functionality": "Resets the parameters of the HeteroEncoder module.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroEncoder"
            },
            {
                "function_call_name": "self.temporal_encoder.reset_parameters()",
                "functionality": "Resets the parameters of the HeteroTemporalEncoder module.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroTemporalEncoder"
            },
            {
                "function_call_name": "self.gnn.reset_parameters()",
                "functionality": "Resets the parameters of the HeteroGraphSAGE module.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "contextgnn.nn.models.HeteroGraphSAGE"
            },
            {
                "function_call_name": "self.head.reset_parameters()",
                "functionality": "Resets the parameters of the MLP head.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "torch_geometric.nn.MLP"
            },
            {
                "function_call_name": "self.id_awareness_emb.reset_parameters()",
                "functionality": "Resets the parameters of the ID-awareness embedding.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "torch.nn.Embedding"
            },
            {
                "function_call_name": "self.rhs_embedding.reset_parameters()",
                "functionality": "Resets the parameters of the right-hand-side (item) shallow embedding matrix.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "contextgnn.nn.models.rhsembeddinggnn.RHSEmbeddingGNN"
            },
            {
                "function_call_name": "self.lin_offset_embgnn.reset_parameters()",
                "functionality": "Resets parameters of the embgnn offset linear layer.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "torch.nn.Linear"
            },
            {
                "function_call_name": "self.lin_offset_idgnn.reset_parameters()",
                "functionality": "Resets parameters of the idgnn offset linear layer.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "torch.nn.Linear"
            },
            {
                "function_call_name": "self.lhs_projector.reset_parameters()",
                "functionality": "Resets parameters of the user embedding projection layer.",
                "input": "None",
                "output": "None",
                "location_or_namespace": "torch.nn.Linear"
            }
        ]
    },
    {
        "function_name": "ContextGNN.sample_step",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "torch.rand()",
                "functionality": "Generates a tensor of random numbers in [0,1).",
                "input": "size (int or tuple), device",
                "output": "Tensor of random floats.",
                "location_or_namespace": "torch"
            },
            {
                "function_call_name": "map_index()",
                "functionality": "Remaps indices according to a reference index set, used for advanced indexing/sampling.",
                "input": "index, reference index, max_index, inclusive",
                "output": "Remapped indices and boolean mask.",
                "location_or_namespace": "torch_geometric.utils.map"
            },
            {
                "function_call_name": "self.rhs_embedding()",
                "functionality": "Returns the embedding vectors of the sampled item (RHS) indices.",
                "input": "rhs_index (Tensor)",
                "output": "Tensor of embedding vectors.",
                "location_or_namespace": "contextgnn.nn.models.rhsembeddinggnn.RHSEmbeddingGNN"
            }
        ]
    },
    {
        "function_name": "ContextGNN.construct_logits",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "Tensor.t()",
                "functionality": "Returns the transpose of a tensor (for dot product scoring).",
                "input": "None",
                "output": "Transposed tensor.",
                "location_or_namespace": "torch.Tensor"
            },
            {
                "function_call_name": "self.head()",
                "functionality": "Applies MLP head to the right-hand-side (item) GNN embeddings for scoring.",
                "input": "rhs_gnn_embedding (Tensor)",
                "output": "Score tensor.",
                "location_or_namespace": "torch_geometric.nn.MLP"
            },
            {
                "function_call_name": "Tensor.flatten()",
                "functionality": "Returns a contiguous flattened tensor.",
                "input": "start_dim=0, end_dim=-1 (optional)",
                "output": "Flattened tensor.",
                "location_or_namespace": "torch.Tensor"
            },
            {
                "function_call_name": "Tensor.sum()",
                "functionality": "Returns the sum of each row (used for user-item elementwise product).",
                "input": "dim (int), keepdim (bool)",
                "output": "Summed tensor.",
                "location_or_namespace": "torch.Tensor"
            }
        ]
    },
    {
        "function_name": "ContextGNN.forward_gnn",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "self.encoder()",
                "functionality": "Encodes tabular/multimodal node features to embedding tensors.",
                "input": "tf_dict (Dict of TensorFrames)",
                "output": "Dict of node embeddings.",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroEncoder"
            },
            {
                "function_call_name": "self.id_awareness_emb.weight",
                "functionality": "Returns the weights of the ID-awareness embedding for addition to node features.",
                "input": "None",
                "output": "Tensor of embedding weights.",
                "location_or_namespace": "torch.nn.Embedding"
            },
            {
                "function_call_name": "self.temporal_encoder()",
                "functionality": "Encodes relative time into features for each node type.",
                "input": "seed_time (Tensor), time_dict (Dict), batch_dict (Dict)",
                "output": "Dict of temporal feature tensors.",
                "location_or_namespace": "contextgnn.nn.encoder.HeteroTemporalEncoder"
            },
            {
                "function_call_name": "self.gnn()",
                "functionality": "Performs message passing and updates node features with GNN.",
                "input": "x_dict (Dict), edge_index_dict (Dict)",
                "output": "Dict of updated node embeddings.",
                "location_or_namespace": "contextgnn.nn.models.HeteroGraphSAGE"
            }
        ]
    },
    {
        "function_name": "ContextGNN.forward",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "self.forward_gnn()",
                "functionality": "Obtains context-aware embeddings from the GNN.",
                "input": "batch (HeteroData), entity_table (NodeType)",
                "output": "Dict of node embeddings.",
                "location_or_namespace": "self (ContextGNN)"
            },
            {
                "function_call_name": "self.lhs_projector()",
                "functionality": "Projects user embeddings into a common space for dot-product scoring.",
                "input": "lhs_embedding (Tensor)",
                "output": "Projected user embedding (Tensor).",
                "location_or_namespace": "torch.nn.Linear"
            },
            {
                "function_call_name": "self.rhs_embedding()",
                "functionality": "Returns the embedding vectors of all candidate items (RHS).",
                "input": "None",
                "output": "Tensor of embedding vectors.",
                "location_or_namespace": "contextgnn.nn.models.rhsembeddinggnn.RHSEmbeddingGNN"
            },
            {
                "function_call_name": "self.construct_logits()",
                "functionality": "Fuses two-tower and pair-wise logits as final prediction.",
                "input": "Various embedding tensors and batch indices.",
                "output": "Tensor of fused logits.",
                "location_or_namespace": "self (ContextGNN)"
            }
        ]
    },
    {
        "function_name": "ContextGNN.forward_sample_softmax",
        "file_path": "contextgnn/nn/models/contextgnn.py",
        "function_calls": [
            {
                "function_call_name": "self.forward_gnn()",
                "functionality": "Obtains context-aware embeddings from the GNN.",
                "input": "batch (HeteroData), entity_table (NodeType)",
                "output": "Dict of node embeddings.",
                "location_or_namespace": "self (ContextGNN)"
            },
            {
                "function_call_name": "self.lhs_projector()",
                "functionality": "Projects user embeddings into a common space for dot-product scoring.",
                "input": "lhs_embedding (Tensor)",
                "output": "Projected user embedding (Tensor).",
                "location_or_namespace": "torch.nn.Linear"
            },
            {
                "function_call_name": "self.sample_step()",
                "functionality": "Selects a subset of RHS indices and associated features for sampled softmax.",
                "input": "rhs_idgnn_index, lhs_idgnn_batch, rhs_gnn_embedding, src_batch, dst_index",
                "output": "Sampled indices, embeddings, and associated batch indices.",
                "location_or_namespace": "self (ContextGNN)"
            },
            {
                "function_call_name": "self.construct_logits()",
                "functionality": "Fuses two-tower and pair-wise logits as final prediction.",
                "input": "Various embedding tensors and batch indices.",
                "output": "Tensor of fused logits.",
                "location_or_namespace": "self (ContextGNN)"
            }
        ]
    }
]