ShulinCao / OpenNRE-PyTorch

Neural Relation Extraction implemented in PyTorch
MIT License
219 stars 45 forks source link

[Question] Scope and Bag #5

Closed siddsach closed 5 years ago

siddsach commented 5 years ago

I'm a bit confused as to what the scope and bag variables are actually doing, specifically at this line (https://github.com/ShulinCao/OpenNRE-PyTorch/blob/11bf7ce0aa5ac6ef168e43065722fb3cad2a14b4/gen_data.py#L152).

I'm working on some modifications to this repo, and would be very appreciate if you could give a more full description of what the purpose of the bag_scope variable and the mechanics of how it's used, (and perhaps I can add comments to this code in a PR for others to understand as well).

It seems there're two components, scope, which i really don't understand, and bag, which I intuitively think is a way to use multi-instance learning, but don't know much more than that. If you could provide me some more detailed explanation of what's going on, I'd be very grateful!!!!

Thank you for open-sourcing this tool!!!!

ShulinCao commented 5 years ago

Bag is used for multi-instance learning. First we sort the all the sentences, making sentences with the same <h, r, t> be together. Then we can need to record the scope for each bag. if the "tup" is different from the last tup, we know it is a different bag, and we record the scope.