autoliuweijie / K-BERT

Source code of K-BERT (AAAI2020)
https://ojs.aaai.org//index.php/AAAI/article/view/5681
953 stars 213 forks source link

Where is the -inf condition being enforced ? #83

Open swarnadeep8597 opened 1 year ago

swarnadeep8597 commented 1 year ago

Hello, How are you enforcing the -inf condition if the two words are not in the same branch ? In the code you are setting both the places as 1, bit shouldn't it be 0 and -inf ?

Calculate Visible Matrix

        visible_matrix = np.zeros((token_num,token_num))
        for item in abs_idx_tree:
            src_ids = item[0]
            for id in src_ids:
                visible_abs_idx = abs_idx_src + [idx for ent in item[1] for idx in ent]
                #print(visible_abs_idx)
                visible_matrix[id,visible_abs_idx] = 1 
            for ent in item[1]:
                for id in ent:
                    visible_abs_idx = ent + src_ids
                    visible_matrix[id,visible_abs_idx] = 1