SYMBOL INDEX (298 symbols across 47 files) FILE: gnn/dataset_load.py class BasicDataLoader (line 18) | class BasicDataLoader(object): method __init__ (line 24) | def __init__(self, config, word2id, relation2id, entity2id, tokenize, ... method _load_file (line 31) | def _load_file(self, config, data_type="train"): method _load_data (line 62) | def _load_data(self): method _parse_args (line 88) | def _parse_args(self, config, word2id, relation2id, entity2id): method get_quest (line 130) | def get_quest(self, training=False): method decode_text (line 143) | def decode_text(self, np_array_x): method _prepare_data (line 159) | def _prepare_data(self): method build_rel_words (line 354) | def build_rel_words(self, tokenize): method create_kb_adj_mats (line 432) | def create_kb_adj_mats(self, sample_id): method _build_fact_mat (line 473) | def _build_fact_mat(self, sample_ids, fact_dropout): method reset_batches (line 530) | def reset_batches(self, is_sequential=True): method _build_global2local_entity_maps (line 536) | def _build_global2local_entity_maps(self): method _add_entity_to_map (line 562) | def _add_entity_to_map(entity2id, entities, g2l): method deal_q_type (line 577) | def deal_q_type(self, q_type=None): class SingleDataLoader (line 592) | class SingleDataLoader(BasicDataLoader): method __init__ (line 596) | def __init__(self, config, word2id, relation2id, entity2id, tokenize, ... method get_batch (line 599) | def get_batch(self, iteration, batch_size, fact_dropout, q_type=None, ... function load_dict (line 632) | def load_dict(filename): function load_dict_int (line 640) | def load_dict_int(filename): function load_data (line 648) | def load_data(config, tokenize): FILE: gnn/dataset_load_graft.py class GraftBasicDataLoader (line 19) | class GraftBasicDataLoader(BasicDataLoader): method __init__ (line 24) | def __init__(self, config, word2id, relation2id, entity2id, tokenize, ... method create_kb_adj_mats_facts (line 27) | def create_kb_adj_mats_facts(self, sample_id): method _build_fact_mat_maxfacts (line 70) | def _build_fact_mat_maxfacts(self, sample_ids, fact_dropout): class GraftSingleDataLoader (line 106) | class GraftSingleDataLoader(GraftBasicDataLoader): method __init__ (line 110) | def __init__(self, config, word2id, relation2id, entity2id, tokenize, ... method get_batch (line 113) | def get_batch(self, iteration, batch_size, fact_dropout, q_type=None, ... function load_dict (line 152) | def load_dict(filename): function load_dict_int (line 160) | def load_dict_int(filename): function load_data_graft (line 168) | def load_data_graft(config, tokenize): FILE: gnn/evaluate.py function cal_accuracy (line 10) | def cal_accuracy(pred, answer_dist): function f1_and_hits (line 25) | def f1_and_hits(answers, candidate2prob, id2entity, entity2name, eps=0.5): class Evaluator (line 70) | class Evaluator: method __init__ (line 72) | def __init__(self, args, model, entity2id, relation2id, device): method write_info (line 106) | def write_info(self, valid_data, tp_list, num_step): method evaluate (line 140) | def evaluate(self, valid_data, test_batch_size=20, write_info=False): FILE: gnn/main.py function main (line 29) | def main(): FILE: gnn/models/GraftNet/graftnet.py class GraftNet (line 21) | class GraftNet(BaseModel): method __init__ (line 22) | def __init__(self, args, num_entity, num_relation, num_word): method layers (line 37) | def layers(self, args): method private_module_def (line 61) | def private_module_def(self, args, num_entity, num_relation): method get_ent_init (line 74) | def get_ent_init(self, local_entity, kb_adj_mat, rel_features): method get_rel_feature (line 85) | def get_rel_feature(self): method init_reason (line 105) | def init_reason(self, curr_dist, local_entity, kb_adj_mat, kb_adj_mat_... method calc_loss_label (line 128) | def calc_loss_label(self, curr_dist, teacher_dist, label_valid): method forward (line 135) | def forward(self, batch, training=False): FILE: gnn/models/NSM/nsm.py class NSM (line 19) | class NSM(BaseModel): method __init__ (line 20) | def __init__(self, args, num_entity, num_relation, num_word): method layers (line 37) | def layers(self, args): method private_module_def (line 69) | def private_module_def(self, args, num_entity, num_relation): method get_ent_init (line 85) | def get_ent_init(self, local_entity, kb_adj_mat, rel_features): method get_rel_feature (line 97) | def get_rel_feature(self): method init_reason (line 114) | def init_reason(self, curr_dist, local_entity, kb_adj_mat, q_input): method get_js_div (line 142) | def get_js_div(self, dist_1, dist_2): method calc_loss_backward (line 151) | def calc_loss_backward(self, case_valid): method calc_loss_label (line 172) | def calc_loss_label(self, curr_dist, teacher_dist, label_valid): method forward (line 179) | def forward(self, batch, training=False): FILE: gnn/models/ReaRev/rearev.py class ReaRev (line 19) | class ReaRev(BaseModel): method __init__ (line 20) | def __init__(self, args, num_entity, num_relation, num_word): method layers (line 51) | def layers(self, args): method get_ent_init (line 79) | def get_ent_init(self, local_entity, kb_adj_mat, rel_features): method get_rel_feature (line 91) | def get_rel_feature(self): method private_module_def (line 114) | def private_module_def(self, args, num_entity, num_relation): method init_reason (line 132) | def init_reason(self, curr_dist, local_entity, kb_adj_mat, q_input, qu... method calc_loss_label (line 156) | def calc_loss_label(self, curr_dist, teacher_dist, label_valid): method forward (line 163) | def forward(self, batch, training=False): FILE: gnn/models/base_model.py class BaseModel (line 9) | class BaseModel(torch.nn.Module): method __init__ (line 14) | def __init__(self, args, num_entity, num_relation, num_word): method embedding_def (line 70) | def embedding_def(self): method load_relation_file (line 153) | def load_relation_file(self, filename): method use_rel_texts (line 164) | def use_rel_texts(self, rel_texts, rel_texts_inv): method encode_rel_texts (line 168) | def encode_rel_texts(self, rel_texts, rel_texts_inv): method init_hidden (line 178) | def init_hidden(self, num_layer, batch_size, hidden_size): method encode_question (line 181) | def encode_question(self, q_input): method get_instruction (line 184) | def get_instruction(self, query_hidden_emb, query_mask, states): method get_loss_bce (line 187) | def get_loss_bce(self, pred_dist_score, answer_dist): method get_loss_kl (line 193) | def get_loss_kl(self, pred_dist, answer_dist): method get_loss (line 201) | def get_loss(self, pred_dist, answer_dist, reduction='mean'): method f1_and_hits (line 217) | def f1_and_hits(self, answers, candidate2prob, eps=0.5): method calc_f1_new (line 249) | def calc_f1_new(self, curr_dist, dist_ans, h1_vec): method calc_h1 (line 287) | def calc_h1(self, curr_dist, dist_ans, eps=0.01): method get_eval_metric (line 294) | def get_eval_metric(self, pred_dist, answer_dist): FILE: gnn/modules/kg_reasoning/base_gnn.py class BaseGNNLayer (line 7) | class BaseGNNLayer(torch.nn.Module): method __init__ (line 11) | def __init__(self, args, num_entity, num_relation): method build_matrix (line 19) | def build_matrix(self): method _build_sparse_tensor (line 53) | def _build_sparse_tensor(self, indices, values, size): method build_adj_facts (line 56) | def build_adj_facts(self): FILE: gnn/modules/kg_reasoning/graft_gnn.py class GraftLayer (line 14) | class GraftLayer(BaseGNNLayer): method __init__ (line 15) | def __init__(self, args, num_entity, num_relation, entity_dim): method init_layers (line 27) | def init_layers(self, args): method init_reason (line 45) | def init_reason(self, local_entity, kb_adj_mat, kb_adj_mat_graft, kb_f... method compute_attention (line 64) | def compute_attention(self, query_hidden_emb, query_mask): method reason_layer (line 89) | def reason_layer(self, curr_dist, kb_self_linear, kb_head_linear, kb_t... method forward (line 111) | def forward(self, current_dist, query_hidden_emb, query_mask, step=0, ... FILE: gnn/modules/kg_reasoning/nsm_gnn.py class NSMBaseLayer (line 14) | class NSMBaseLayer(BaseGNNLayer): method __init__ (line 15) | def __init__(self, args, num_entity, num_relation, entity_dim): method init_layers (line 24) | def init_layers(self, args): method init_reason (line 38) | def init_reason(self, local_entity, kb_adj_mat, local_entity_emb, rel_... method reason_layer (line 51) | def reason_layer(self, curr_dist, instruction, rel_linear): method forward (line 54) | def forward(self, current_dist, relational_ins, step=0, return_score=F... class NSMLayer (line 83) | class NSMLayer(NSMBaseLayer): method __init__ (line 84) | def __init__(self, args, num_entity, num_relation, entity_dim): method reason_layer (line 87) | def reason_layer(self, curr_dist, instruction, rel_linear): class NSMLayer_back (line 114) | class NSMLayer_back(NSMBaseLayer): method __init__ (line 115) | def __init__(self, args, num_entity, num_relation, entity_dim): method reason_layer (line 118) | def reason_layer(self, curr_dist, instruction, rel_linear): FILE: gnn/modules/kg_reasoning/reasongnn.py class ReasonGNNLayer (line 11) | class ReasonGNNLayer(BaseGNNLayer): method __init__ (line 15) | def __init__(self, args, num_entity, num_relation, entity_dim, alg): method init_layers (line 27) | def init_layers(self, args): method init_reason (line 46) | def init_reason(self, local_entity, kb_adj_mat, local_entity_emb, rel_... method reason_layer (line 61) | def reason_layer(self, curr_dist, instruction, rel_linear, pos_emb): method reason_layer_inv (line 91) | def reason_layer_inv(self, curr_dist, instruction, rel_linear, pos_emb... method combine (line 118) | def combine(self,emb): method forward (line 134) | def forward(self, current_dist, relational_ins, step=0, return_score=F... FILE: gnn/modules/layer_init.py class TypeLayer (line 9) | class TypeLayer(nn.Module): method __init__ (line 14) | def __init__(self, in_features, out_features, linear_drop, device, nor... method forward (line 25) | def forward(self, local_entity, edge_list, rel_features): method _build_sparse_tensor (line 64) | def _build_sparse_tensor(self, indices, values, size): FILE: gnn/modules/query_update.py class Fusion (line 6) | class Fusion(nn.Module): method __init__ (line 8) | def __init__(self, d_hid): method forward (line 13) | def forward(self, x, y): class QueryReform (line 18) | class QueryReform(nn.Module): method __init__ (line 20) | def __init__(self, h_dim): method forward (line 26) | def forward(self, q_node, ent_emb, seed_info, ent_mask): class AttnEncoder (line 46) | class AttnEncoder(nn.Module): method __init__ (line 48) | def __init__(self, d_hid): method forward (line 52) | def forward(self, x, x_mask): class Attention (line 63) | class Attention(nn.Module): method __init__ (line 89) | def __init__(self, dimensions, attention_type='general'): method forward (line 103) | def forward(self, query, context): FILE: gnn/modules/question_encoding/base_encoder.py class BaseInstruction (line 8) | class BaseInstruction(torch.nn.Module): method __init__ (line 10) | def __init__(self, args, constraint): method _parse_args (line 16) | def _parse_args(self, args): method share_module_def (line 48) | def share_module_def(self): method init_hidden (line 53) | def init_hidden(self, num_layer, batch_size, hidden_size): method encode_question (line 57) | def encode_question(self, *args): method get_node_emb (line 62) | def get_node_emb(query_hidden_emb, action): method init_reason (line 74) | def init_reason(self, query_text): method get_instruction (line 82) | def get_instruction(self, relational_ins, step=0, query_node_emb=None): method forward (line 105) | def forward(self, query_text, lm=None): FILE: gnn/modules/question_encoding/bert_encoder.py class BERTInstruction (line 18) | class BERTInstruction(BaseInstruction): method __init__ (line 20) | def __init__(self, args, word_embedding, num_word, model, constraint=F... method encoder_def (line 74) | def encoder_def(self): method encode_question (line 89) | def encode_question(self, query_text, store=True): FILE: gnn/modules/question_encoding/lstm_encoder.py class LSTMInstruction (line 10) | class LSTMInstruction(BaseInstruction): method __init__ (line 12) | def __init__(self, args, word_embedding, num_word): method encoder_def (line 25) | def encoder_def(self): method encode_question (line 32) | def encode_question(self, query_text, store=True): FILE: gnn/modules/question_encoding/tokenizers.py class LSTMTokenizer (line 5) | class LSTMTokenizer(): method __init__ (line 6) | def __init__(self, word2id, max_query_word): method tokenize (line 11) | def tokenize(self, question): method tokenize_sent (line 28) | def tokenize_sent(question_text): class BERTTokenizer (line 41) | class BERTTokenizer(): method __init__ (line 42) | def __init__(self, max_query_word): method tokenize (line 50) | def tokenize(self, question): FILE: gnn/parsing.py function bool_flag (line 5) | def bool_flag(v): function add_shared_args (line 13) | def add_shared_args(parser): function add_parse_args (line 68) | def add_parse_args(parser): function create_parser_rearev (line 85) | def create_parser_rearev(parser): function create_parser_nsm (line 101) | def create_parser_nsm(parser): function create_parser_graftnet (line 115) | def create_parser_graftnet(parser): FILE: gnn/train_model.py class Trainer_KBQA (line 24) | class Trainer_KBQA(object): method __init__ (line 25) | def __init__(self, args, model_name, logger=None): method optim_def (line 89) | def optim_def(self): method load_data (line 96) | def load_data(self, args, tokenize): method load_pretrain (line 113) | def load_pretrain(self): method evaluate (line 120) | def evaluate(self, data, test_batch_size=20, write_info=False): method train (line 123) | def train(self, start_epoch, end_epoch): method evaluate_best (line 182) | def evaluate_best(self): method evaluate_single (line 201) | def evaluate_single(self, filename): method train_epoch (line 209) | def train_epoch(self): method save_ckpt (line 236) | def save_ckpt(self, reason="h1"): method load_ckpt (line 246) | def load_ckpt(self, filename): FILE: gnn/utils.py function create_logger (line 5) | def create_logger(args): function get_dict (line 29) | def get_dict(data_folder, filename): FILE: llm/src/align_kg/build_align_qa_dataset.py function build_data (line 13) | def build_data(args): function process_data (line 35) | def process_data(data, remove_duplicate=False): FILE: llm/src/align_kg/data_loader.py function load_new_tokens (line 10) | def load_new_tokens(default_new_tokens, rel_dict_path): function load_multiple_datasets (line 21) | def load_multiple_datasets(data_path_list, shuffle=False): function get_test_dataset (line 41) | def get_test_dataset(dataset): FILE: llm/src/joint_training/generate_explanation_results.py function formatting_prompts_func (line 106) | def formatting_prompts_func(example): FILE: llm/src/joint_training/joint_finetuning.py class ScriptArguments (line 37) | class ScriptArguments: class ScriptTrainingArguments (line 72) | class ScriptTrainingArguments(TrainingArguments): function train (line 84) | def train(): FILE: llm/src/joint_training/preprocess_align.py function formatting_prompts_func (line 29) | def formatting_prompts_func(example): FILE: llm/src/joint_training/preprocess_qa.py function formatting_prompts_func (line 36) | def formatting_prompts_func(example): FILE: llm/src/llms/language_models/__init__.py function get_registed_model (line 18) | def get_registed_model(model_name) -> BaseLanguageModel: FILE: llm/src/llms/language_models/alpaca.py class Alpaca (line 5) | class Alpaca(BaseLanguageModel): method add_args (line 8) | def add_args(parser): method __init__ (line 13) | def __init__(self, args): method load_model (line 17) | def load_model(self, **kwargs): method tokenize (line 20) | def tokenize(self, text): method prepare_for_inference (line 23) | def prepare_for_inference(self, **model_kwargs): method generate_sentence (line 28) | def generate_sentence(self, llm_input): FILE: llm/src/llms/language_models/base_language_model.py class BaseLanguageModel (line 4) | class BaseLanguageModel(object): method add_args (line 12) | def add_args(parser): method __init__ (line 15) | def __init__(self, args): method load_model (line 18) | def load_model(self, **kwargs): method prepare_for_inference (line 21) | def prepare_for_inference(self, **model_kwargs): method tokenize (line 24) | def tokenize(self, text): method generate_sentence (line 33) | def generate_sentence(self, lm_input): FILE: llm/src/llms/language_models/chatgpt.py function get_token_limit (line 13) | def get_token_limit(model='gpt-4'): class ChatGPT (line 25) | class ChatGPT(BaseLanguageModel): method add_args (line 28) | def add_args(parser): method __init__ (line 31) | def __init__(self, args): method tokenize (line 37) | def tokenize(self, text): method prepare_for_inference (line 46) | def prepare_for_inference(self, model_kwargs={}): method generate_sentence (line 52) | def generate_sentence(self, llm_input): FILE: llm/src/llms/language_models/flan_t5.py class FlanT5 (line 5) | class FlanT5(BaseLanguageModel): method add_args (line 8) | def add_args(parser): method __init__ (line 13) | def __init__(self, args): method load_model (line 17) | def load_model(self, **kwargs): method tokenize (line 21) | def tokenize(self, text): method prepare_for_inference (line 24) | def prepare_for_inference(self, **model_kwargs): method generate_sentence (line 30) | def generate_sentence(self, llm_input): FILE: llm/src/llms/language_models/llama.py class Llama (line 6) | class Llama(BaseLanguageModel): method add_args (line 9) | def add_args(parser): method __init__ (line 15) | def __init__(self, args): method load_model (line 19) | def load_model(self, **kwargs): method tokenize (line 23) | def tokenize(self, text): method prepare_for_inference (line 26) | def prepare_for_inference(self, **model_kwargs): method generate_sentence (line 34) | def generate_sentence(self, llm_input): FILE: llm/src/llms/language_models/longchat/llama_condense_monkey_patch.py function rank0_print (line 10) | def rank0_print(*args): class CondenseRotaryEmbedding (line 18) | class CondenseRotaryEmbedding(torch.nn.Module): method __init__ (line 19) | def __init__(self, dim, ratio, max_position_embeddings=2048, base=1000... method forward (line 37) | def forward(self, x, seq_len=None): function replace_llama_with_condense (line 53) | def replace_llama_with_condense(ratio): FILE: llm/src/llms/language_models/longchat/llama_flash_attn_monkey_patch.py function forward (line 14) | def forward( function _prepare_decoder_attention_mask (line 84) | def _prepare_decoder_attention_mask(self, attention_mask, input_shape, function replace_llama_attn_with_flash_attn (line 90) | def replace_llama_attn_with_flash_attn(): FILE: llm/src/llms/language_models/longchat/longchat.py function maybe_monkey_patch (line 5) | def maybe_monkey_patch(args): class Longchat (line 14) | class Longchat(BaseLanguageModel): method add_args (line 18) | def add_args(parser): method __init__ (line 25) | def __init__(self, args): method load_model (line 30) | def load_model(self, **kwargs): method tokenize (line 35) | def tokenize(self, text): method prepare_for_inference (line 38) | def prepare_for_inference(self, **model_kwargs): method generate_sentence (line 44) | def generate_sentence(self, llm_input): FILE: llm/src/llms/llm_proxy.py class LLMProxy (line 7) | class LLMProxy(object): method regist_args (line 10) | def regist_args(parser): method __init__ (line 18) | def __init__(self, args) -> None: method query (line 33) | def query(message, model_name, timeout=60, max_retry=3): FILE: llm/src/llms/start_fastchat_api.py function terminate_process (line 8) | def terminate_process(): function start_fastchat_api (line 18) | def start_fastchat_api(model_names, model_path, conv_template, host, port): function exit_handler (line 49) | def exit_handler(signal, frame): FILE: llm/src/qa_prediction/build_qa_input.py function normalize (line 15) | def normalize(s: str) -> str: class PromptBuilder (line 26) | class PromptBuilder(object): method __init__ (line 40) | def __init__(self, prompt_path, encrypt=False, add_rule = False, use_t... method _read_prompt_template (line 53) | def _read_prompt_template(self, template_file): method apply_rules (line 58) | def apply_rules(self, graph, rules, srouce_entities): method direct_answer (line 66) | def direct_answer(self, question_dict): method process_input (line 83) | def process_input(self, question_dict): method check_prompt_length (line 164) | def check_prompt_length(self, prompt, list_of_paths, maximun_token): FILE: llm/src/qa_prediction/evaluate_multi_hop.py function normalize (line 21) | def normalize(s: str) -> str: function match (line 33) | def match(s1: str, s2: str) -> bool: function eval_acc (line 38) | def eval_acc(prediction, answer): function eval_hit (line 45) | def eval_hit(prediction, answer): function eval_hit1 (line 51) | def eval_hit1(prediction, answer): function eval_f1 (line 57) | def eval_f1(prediction, answer): function extract_topk_prediction (line 72) | def extract_topk_prediction(prediction, k=-1): function eval_result (line 84) | def eval_result(predict_file1, encrypt=False, cal_f1=True, topk = -1): FILE: llm/src/qa_prediction/evaluate_results.py function normalize (line 15) | def normalize(s: str) -> str: function match (line 27) | def match(s1: str, s2: str) -> bool: function eval_acc (line 32) | def eval_acc(prediction, answer): function eval_hit (line 39) | def eval_hit(prediction, answer): function eval_hit1 (line 45) | def eval_hit1(prediction, answer): function eval_f1 (line 51) | def eval_f1(prediction, answer): function extract_topk_prediction (line 66) | def extract_topk_prediction(prediction, k=-1): function eval_result (line 78) | def eval_result(predict_file, encrypt=False, cal_f1=True, topk = -1): FILE: llm/src/qa_prediction/gen_rule_path.py function get_output_file (line 25) | def get_output_file(path, force=False): function parse_prediction (line 42) | def parse_prediction(prediction): function generate_seq (line 71) | def generate_seq( function gen_prediction (line 102) | def gen_prediction(args): FILE: llm/src/qa_prediction/predict_answer.py function normalize (line 25) | def normalize(s: str) -> str: function match (line 37) | def match(s1: str, s2: str) -> bool: function load_gnn_rag (line 43) | def load_gnn_rag(g_data_file, g_data_file2=None): function get_output_file (line 83) | def get_output_file(path, force=False): function merge_rule_result (line 100) | def merge_rule_result(qa_dataset, rule_dataset, n_proc=1, filter_empty=F... function prediction (line 127) | def prediction(data, processed_list, input_builder, model, encrypt=False... function main (line 174) | def main(args, LLM): FILE: llm/src/utils/graph_utils.py function build_graph (line 10) | def build_graph(graph: list, entities=None, encrypt=False) -> nx.Graph: function bfs_with_rule (line 24) | def bfs_with_rule(graph, start_node, target_rule, max_p = 10): function get_truth_paths (line 49) | def get_truth_paths(q_entity: list, a_entity: list, graph: nx.Graph) -> ... function get_simple_paths (line 77) | def get_simple_paths(q_entity: list, a_entity: list, graph: nx.Graph, ho... function get_negative_paths (line 100) | def get_negative_paths(q_entity: list, a_entity: list, graph: nx.Graph, ... function get_random_paths (line 129) | def get_random_paths(q_entity: list, graph: nx.Graph, n=3, hop=2):# -> t... FILE: llm/src/utils/merge_peft.py class ScriptArguments (line 8) | class ScriptArguments: FILE: llm/src/utils/training_utils.py function smart_tokenizer_and_embedding_resize (line 4) | def smart_tokenizer_and_embedding_resize( FILE: llm/src/utils/utils.py function read_prompt (line 5) | def read_prompt(prompt_path): function load_jsonl (line 10) | def load_jsonl(file_path): function load_multiple_jsonl (line 17) | def load_multiple_jsonl(file_path_list): function list_to_string (line 23) | def list_to_string(l: list) -> str: function rule_to_string (line 27) | def rule_to_string(rule: list, sep_token = "", bop = "", eop ... function path_to_string (line 34) | def path_to_string(path: list) -> str: class InstructFormater (line 46) | class InstructFormater(object): method __init__ (line 47) | def __init__(self, prompt_path): method format (line 57) | def format(self, instruction, message):