Skip to content

Additional description information during testing(inference) #29

Description

@meaningful96

I have a question about code implementation. First, in the doc.py section

def vectorize(self) -> dict:
head_desc, tail_desc = self.head_desc, self.tail_desc
if args.use_link_graph:
if len(head_desc.split()) < 20:
head_desc += ' ' + get_neighbor_desc(head_id=self.head_id, tail_id=self.tail_id)
if len(tail_desc.split()) < 20:
tail_desc += ' ' + get_neighbor_desc(head_id=self.tail_id, tail_id=self.head_id)

head_word = _parse_entity_name(self.head)
head_text = _concat_name_desc(head_word, head_desc)
hr_encoded_inputs = _custom_tokenize(text=head_text,
text_pair=self.relation)

head_encoded_inputs = _custom_tokenize(text=head_text)

tail_word = _parse_entity_name(self.tail)
tail_encoded_inputs = _custom_tokenize(text=_concat_name_desc(tail_word, tail_desc))

Looking at this part, when the number of tokens is less than 20, the description of the neighbors is included.
By the way, in the predict.py file

args.use_link_graph = self.train_args.use_link_graph
args.is_test = True

According to this part, additional description will be included in the test, so isn't the description of the tail, which is the correct answer, even though the problem solving in the knowledge graph is to match the tail when the head and relation are given?

Activity

  1. meaningful96 commented on Aug 29, 2023

    @meaningful96
    Author

    even if the get_neighbor_desc doesn't take the true tail's id during training, isn't it possible to get the True id from the neighbors in the link graph?

  2. intfloat commented on Aug 29, 2023

    @intfloat
    Owner

    I am not entirely clear about your question, but I guess you are asking whether the groundtruth tail entity will be leaked in the input during test stage?

    The link graph used to get entity neighbors is constructed based on training data. So, it is possible that the groundtruth tail entity will be included in the 2-hop or 3-hop neighbors of the head entity. But this is OK as we do not assume access to the test labels.

  3. meaningful96 commented on Aug 29, 2023

    @meaningful96
    Author

    Oh yes, that's what I wondered. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions