intfloat / SimKGC

ACL 2022, SimKGC: Simple Contrastive Knowledge Graph Completion with Pre-trained Language Models
188 stars 36 forks source link

Negative sampling #7

Open NoviceCrom opened 2 years ago

NoviceCrom commented 2 years ago

Hi! The paper argues that in-batch samples can be used as negatives. In the implementation of training, it seems there's no explicit positives, just mm() for all hr_vectors and tail_vectors?

intfloat commented 2 years ago

The diagonal elements of the resulting matrix correspond to positives.

To be more specific, for the i-th row in hr_vectors, the positive is the i-th row in tail-vectors, and all other rows are in-batch negatives.