chenchens190009/KG-S2S

Question about constrained decoding

Closed this issue · 4 comments

Hi,

Great work! May I know why you need the ground-truth triplet information (see code here) for the constrained decoding? I think all you need are just the entity names and descriptions.

Hi,

Thanks for your attention. Basically, we store the ground-truth information as index to retrieve the entity names and descriptions. This is reflected in (code), where we get the token ids by the entity id. So you are right, only the entity names and descriptions are fed into the KG-S2S model.

Thanks for your quick reply! But I'm still confused why you need to use ground-truth triplet for retrieval. I thought all you need is just self.next_token_dict. Can you elaborate more about this code here?

self.next_token_dict holds the next token information for each prefix from all the data (train, valid and test), which could be used for the raw evaluation setting. While as mentioned in the paper (section 4.1: Implementation details), we evaluate our method with the filtered setting, so we are expected to filter out the ground truth entities for each test triplet (h, r, t). In our case, T5 predicts the target entities autoregressively, so we need to filter out the next target entity tokens at each step. This code refers to the operation: 1) filtering out all the ground truth next tokens (gt_next_tokens) and 2) bringing back the target next tokens (pred_id).

I see. Thanks for your clear explanation!