Pass instance metadata through to forward
, use it to compute official BiDAF metrics
#216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled with this, but I can see it's necessary for computing Bidaf metrics. There seems to be quite a bit of special casing for the "metadata" key which makes me think that the forward
signature is fundamentally wrong, if we need this sort of info to do forward passes of models (or that doing this sort of thing is fine in a separate training script but doesn't belong in the library) and the reflection isn't great as you said. But ultimately I think my only complaint here is more to do with building stuff from params, so LGTM.
We could have a |
One more idea to not have to do this: pass in a character representation of the passage without tokenising it first. This would make the predicted indices line up and remove the need to pass metadata. It's still a bit clunky though, and isn't particularly memory efficient. Is there a reason I haven't thought of why this won't work? Otherwise, I'm not sure about the |
I'm not sure what you mean by "a character representation of the passage without tokenizing it first", or how having that would solve the problem. For the |
The problem is that the predicted char span is for a tokenised version of the passage but the gold char span is for a non-tokenised version of the passage, right? So what if we passed in a non-tokenised character representation of the exact answer as another "label". Maybe I'm not understanding the problem at all, but it seems like it's possible to do exact string matching using indexed tensors where the indexed tensor is a padded version of the exact string answer. |
The problem is that I need a predicted character span, and all I have is a predicted token span. I need a way to go from the token span to the character span. I don't know of a way to do that other than keeping track of character offsets. |
9c7b766
to
9225b07
Compare
* Set default input limits for forms (#209) * Limit the max input of text inputs and areas. * maxlength -> maxLength * Use rudder for deploy related functionality. (#211) * Use rudder for deploy related functionality. This ensures that the application is deployed to the latest n' greatest skiff cluster. * Use the right image path. * Release pending changes. (#212) (#213) * Set default input limits for forms (#209) * Use rudder for deploy related functionality. (#211) * Bert srl (#214) * update srl model * update description * bump to commit which includes srl model * set timeout to 15 minutes * update to latest image, add numbers (#216)
There are two main things here:
I made the
metadata
that gets associated with each instance available inModel.forward()
, if it's requested. I used some reflection in order to make this work without requiringModel.forward()
to accept ametadata
argument. This is a bit magical, but I didn't really want to require every model to have to accept this argument.I used this metadata inside of BiDAF to compute the official metrics.