RECODE-H / annotations /annotation_38 /function_info.json
mcy98's picture
Upload folder using huggingface_hub
6077218 verified
Raw History Blame Contribute Delete
17.2 kB
[
{
"function_name": "__init__",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "super().__init__",
"functionality": "Initialize the parent SASRec class (transformer-based sequential encoder).",
"input": "config",
"output": "None",
"location_or_namespace": "models/SASRec/_model.py"
},
{
"function_call_name": "nn.Embedding",
"functionality": "Creates an embedding lookup table for the 'none' embedding.",
"input": "num_embeddings=1, embedding_dim=config['hidden_size']",
"output": "Embedding module",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "nn.init.normal_",
"functionality": "Fills the embedding weights with random values from a normal distribution.",
"input": "self.none_embedding.weight, mean=0, std=1",
"output": "None",
"location_or_namespace": "torch.nn.init"
},
{
"function_call_name": "PreferenceDiffusion",
"functionality": "",
"input": "config=config",
"output": "PreferenceDiffusion object",
"location_or_namespace": "diffusion.py"
},
{
"function_call_name": "SinusoidalPositionEmbeddings",
"functionality": "",
"input": "config['hidden_size']",
"output": "Module",
"location_or_namespace": "modules.py"
},
{
"function_call_name": "nn.Linear",
"functionality": "Applies a linear transformation to the incoming data.",
"input": "varies (input/output dims)",
"output": "Linear module",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "nn.GELU",
"functionality": "Applies the GELU activation function.",
"input": "input tensor",
"output": "output tensor",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "nn.Sequential",
"functionality": "Stacks modules together in sequence.",
"input": "modules",
"output": "Sequential module",
"location_or_namespace": "torch.nn"
}
]
},
{
"function_name": "get_embeddings",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.item_embeddings",
"functionality": "",
"input": "items",
"output": "item embeddings",
"location_or_namespace": ""
},
{
"function_call_name": "to",
"functionality": "Moves tensor to specified device.",
"input": "items.device",
"output": "Tensor on new device",
"location_or_namespace": "torch.Tensor"
}
]
},
{
"function_name": "get_all_embeddings",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.item_embeddings.weight.data",
"functionality": "Access all embedding weights.",
"input": "",
"output": "Tensor",
"location_or_namespace": "torch.nn.Embedding"
},
{
"function_call_name": "to",
"functionality": "Moves tensor to specified device.",
"input": "device",
"output": "Tensor on new device",
"location_or_namespace": "torch.Tensor"
}
]
},
{
"function_name": "get_current_embeddings",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.item_embeddings.weight.data",
"functionality": "Access all embedding weights.",
"input": "",
"output": "Tensor",
"location_or_namespace": "torch.nn.Embedding"
},
{
"function_call_name": "to",
"functionality": "Moves tensor to specified device.",
"input": "device",
"output": "Tensor on new device",
"location_or_namespace": "torch.Tensor"
}
]
},
{
"function_name": "load_item_embeddings",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "nn.Embedding",
"functionality": "Creates an embedding lookup table for items.",
"input": "num_embeddings, embedding_dim, padding_idx",
"output": "Embedding module",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "nn.init.normal_",
"functionality": "Fills the embedding weights with random values from a normal distribution.",
"input": "self.item_embeddings.weight, mean=0, std=1",
"output": "None",
"location_or_namespace": "torch.nn.init"
},
{
"function_call_name": "pickle.load",
"functionality": "Load object from file.",
"input": "open(file_path, 'rb')",
"output": "Python object",
"location_or_namespace": "pickle"
},
{
"function_call_name": "torch.tensor",
"functionality": "Creates a tensor from data.",
"input": "data",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "diagonalize_and_scale",
"functionality": "",
"input": "tensor",
"output": "scaled tensor",
"location_or_namespace": "modules.py"
},
{
"function_call_name": "torch.randn_like",
"functionality": "Returns a tensor with the same shape as input filled with random numbers from a normal distribution.",
"input": "input_tensor",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "reshape",
"functionality": "Reshapes the tensor.",
"input": "shape",
"output": "reshaped tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "torch.cat",
"functionality": "Concatenates tensors along a given dimension.",
"input": "tensors, dim",
"output": "Tensor",
"location_or_namespace": "torch"
}
]
},
{
"function_name": "calcu_h",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "torch.rand",
"functionality": "Returns a tensor filled with random numbers from a uniform distribution on [0,1).",
"input": "B",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "torch.sign",
"functionality": "Returns a new tensor with the signs of the elements of input.",
"input": "tensor",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "view",
"functionality": "Reshapes the tensor without changing its data.",
"input": "B, 1",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "torch.cat",
"functionality": "Concatenates tensors along a given dimension.",
"input": "tensors, dim",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "to",
"functionality": "Moves tensor to specified device.",
"input": "logits.device",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "self.none_embedding",
"functionality": "",
"input": "torch.tensor([0]).to(logits.device)",
"output": "embedding",
"location_or_namespace": ""
}
]
},
{
"function_name": "denoise_uncon",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.none_embedding",
"functionality": "",
"input": "torch.tensor([0]).to(x.device)",
"output": "embedding",
"location_or_namespace": ""
},
{
"function_call_name": "view",
"functionality": "Reshapes the tensor.",
"input": "1, x.shape[1]",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "torch.cat",
"functionality": "Concatenates tensors along a given dimension.",
"input": "tensors, dim",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "self.denoise",
"functionality": "",
"input": "x, h, step",
"output": "",
"location_or_namespace": ""
}
]
},
{
"function_name": "denoise",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.step_nn",
"functionality": "",
"input": "step",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "torch.cat",
"functionality": "Concatenates tensors along a given dimension.",
"input": "tensors, dim",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "self.denoise_nn",
"functionality": "",
"input": "torch.cat((x, h, t), dim=1) OR input",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "view",
"functionality": "Reshapes the tensor.",
"input": "B, N, D",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "unsqueeze",
"functionality": "Returns a new tensor with a dimension of size one inserted at the specified position.",
"input": "1",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "repeat",
"functionality": "Repeats the tensor along specified dimensions.",
"input": "1, N, 1",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
}
]
},
{
"function_name": "forward",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.get_representation",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self._generate_negative_samples",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "view",
"functionality": "Reshapes the tensor.",
"input": "-1",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "self.get_embeddings",
"functionality": "",
"input": "labels",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.get_embeddings",
"functionality": "",
"input": "labels_neg",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.calcu_h",
"functionality": "",
"input": "state_hidden, self.config['p']",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "torch.randint",
"functionality": "Returns a tensor with random integers in the specified range.",
"input": "0, self.config['timesteps'], (labels.shape[0],), device=h.device",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "self.diff.p_losses",
"functionality": "",
"input": "self, x_start, x_start_neg, h, n, loss_type=self.config['loss_type']",
"output": "loss, _",
"location_or_namespace": ""
}
]
},
{
"function_name": "predict",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.get_representation",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.diff.sample",
"functionality": "",
"input": "self, state_hidden",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.get_all_embeddings",
"functionality": "",
"input": "state_hidden.device",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "torch.matmul",
"functionality": "Performs a matrix multiplication of the two tensors.",
"input": "x, test_item_emb.transpose(0, 1)",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "topk",
"functionality": "Returns the top k elements and their indices along the specified dimension.",
"input": "n_return_sequences, dim=-1",
"output": "indices",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "self.get_samples",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.get_embeddings",
"functionality": "",
"input": "torch.tensor([30724]).to(x.device)",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "self.get_embeddings",
"functionality": "",
"input": "preds",
"output": "",
"location_or_namespace": ""
}
]
},
{
"function_name": "get_samples",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "self.get_representation",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "tqdm.tqdm",
"functionality": "Display a progress bar for the loop.",
"input": "range(1000)",
"output": "iterator",
"location_or_namespace": "tqdm"
},
{
"function_call_name": "self.diff.sample",
"functionality": "",
"input": "self, state_hidden",
"output": "",
"location_or_namespace": ""
},
{
"function_call_name": "detach",
"functionality": "Returns a new tensor, detached from the current graph.",
"input": "",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "cpu",
"functionality": "Moves tensor to CPU.",
"input": "",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "numpy",
"functionality": "Converts a tensor to a NumPy array.",
"input": "",
"output": "ndarray",
"location_or_namespace": "torch.Tensor"
}
]
},
{
"function_name": "_generate_negative_samples",
"file_path": "models/PreferDiff.py",
"function_calls": [
{
"function_call_name": "in_batch_negative_sampling",
"functionality": "",
"input": "batch['labels']",
"output": "",
"location_or_namespace": "modules.py"
},
{
"function_call_name": "in_batch_negative_sampling_sample",
"functionality": "",
"input": "batch['labels'], self.config['neg_samples']",
"output": "",
"location_or_namespace": "modules.py"
},
{
"function_call_name": "np.random.choice",
"functionality": "Generates a random sample from a given 1-D array.",
"input": "range(self.config['select_pool'][0], self.config['select_pool'][1]), size=1, replace=False",
"output": "ndarray",
"location_or_namespace": "numpy"
},
{
"function_call_name": "torch.LongTensor",
"functionality": "Constructs a tensor of type long.",
"input": "labels_neg",
"output": "Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "to",
"functionality": "Moves tensor to specified device.",
"input": "batch['labels'].device",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "reshape",
"functionality": "Reshapes the tensor.",
"input": "-1, 1",
"output": "Tensor",
"location_or_namespace": "torch.Tensor"
}
]
}
]