relationPrediction icon indicating copy to clipboard operation
relationPrediction copied to clipboard

Why we have to use node_neighbors_2hop and then just get index of [source, 2hop_relation, 1hop_relation, 1hop_entity] instead of entity_2hop

Open hmthanh opened this issue 4 years ago • 3 comments

Hi, Why we have to use node_neighbors_2hop and then just get index of [source, 2hop_relation, 1hop_relation, 1hop_entity] instead of entity_2hop ? In your code node_neighbors_2hop will return a dictionary like this

neighbors[source][distance] = [(tuple(relations), tuple(entities[:-1]))]

and after that just get value of {source, relation_1hop, entity_1hop, relation_2hop} instead of entity_2hop in the following code

batch_source_triples.append([source, nhop_list[i][0][-1], nhop_list[i][0][0], nhop_list[i][1][0]])

As index was show bellow

[source, 2hop_relation, 1hop_relation, 1hop_entity]
0,      1    ,           2 ,              3

edge_list_nhop = train_indices_nhop  [3, 0] # entity : source_entity, 1hop_entity
edge_type_nhop = train_indices_nhop  [1, 2] # relation : 2hop_relation, 1hop_relation

Why we must add source to n-hop. Because as I know in your paper, we want to get neighborhood with n-hop to get more info about neighborhood and aggregation it to present more info about embedding.

hmthanh avatar Aug 06 '20 07:08 hmthanh

Can you answer my question ? @chauhanjatin10 , @nom007 , @deepakn97

hmthanh avatar Aug 18 '20 03:08 hmthanh

Hi @hmthanh . Thanks for showing interest in our work. I apologise for the delayed response. As we have mentioned in the paper, we want to obtain n-hop neighbourhood around each entity. On this n-hop path, we are navigating from one entity to the other via the relation-type edges. Thus intuitively speaking, we want to gather the information about the target entity as well the types of relations we encountered in this path, which mean starting from the source entity and taking a compositional vector of all these relation types, we reach the tail entity. This compositional vector was chosen to be simple sum, however it can be a more complicated vector based on our design choice. This is inline with the choice of margin loss function of TransE. I hope this clarifies the use of relation type edges encountered in the n-hop paths. Thanks and Regards Jatin

chauhanjatin10 avatar Aug 18 '20 09:08 chauhanjatin10

It is corresponding to {source, relation_1hop, relation_2hop, entity_2hop}. After entities[:-1], entities=[entity_2hop, entity_1hop].

YancaoZhang avatar Dec 03 '20 11:12 YancaoZhang