snap-stanford / GreaseLM

[ICLR 2022 spotlight]GreaseLM: Graph REASoning Enhanced Language Models for Question Answering
MIT License
228 stars 40 forks source link

About 2-hop node extraction function: According to code, I think it just extract 1hop nodes. Is there other code to change it? #18

Open Chienwang5 opened 2 months ago

Chienwang5 commented 2 months ago

In these code https://github.com/snap-stanford/GreaseLM/blob/65d7ac84854293f630d6f8ce1428234126c74281/preprocess_utils/graph.py#L315 It extract 2-hop nodes from KG, but it just extract 1-hop nodes from kg actually.

CodeBoyPhilo commented 3 weeks ago

I think it is indeed a 2-hop path: cid_1 - extra_node - cid_2, where cid_1 and cid_2 may be question and answer nodes that come from the qa_nodes of a statement.

Recall that in the code, the extra_nodes are the intersection of the neighbouring nodes of the each qid and aid. https://github.com/snap-stanford/GreaseLM/blob/65d7ac84854293f630d6f8ce1428234126c74281/preprocess_utils/graph.py#L322

So I think your conclusion

but it just extract 1-hop nodes from kg actually.

is correct, in the sense that the extra_nodes are just a 1-hop neighbour of qid and aid. However, by taking the intersection, the extra_nodes are the nodes that bridges qid and aid such that together they form a 2-hop path.

Please correct me if my interpretations were wrong:)