Skip to content

[WIP] Add BertIterator (MultiDataSetIterator for BERT training) - #7430

Merged
AlexDBlack merged 9 commits into
masterfrom
ab_bert_iterator
Apr 4, 2019
Merged

AlexDBlack merged 9 commits into
masterfrom
ab_bert_iterator

Conversation

@AlexDBlack

@AlexDBlack AlexDBlack commented Apr 2, 2019 •

Copy link
Copy Markdown
Contributor

Fixes: #7287

@treo treo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a good start. I'm mostly nitpicking on documentation and some edge case checks.

Concerning the tasks I'm not quite satisfied.

From my understanding of the paper, the big thing about Bert is that they pre-train using both the MLM / Cloze task and next sentence classification task at the same time. This can also be seen when they create training examples in https://github.com/google-research/bert/blob/master/create_pretraining_data.py#L219. They are using the same masked input for both tasks there.

The SEQ_CLASSIFICATION task also doesn't look like it is not an instance of the next-sentence classification task.

To make this a proper BertIterator in my opinion we need to add both the next-sentence classification task, as well as allow multi task training.

* <b>RANK2_IDX</b>: return int32 [minibatch, numTokens] array with entries being class numbers<br>
* <b>RANK3_NCL</b>: return float32 [minibatch, numClasses, numTokens] array with 1-hot entries along dimension 1<br>
* <b>RANK3_NLC</b>: return float32 [minibatch, numTokens, numClasses] array with 1-hot entries along dimension 2<br>
* <br>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a short explanation when someone would use each of those options

@AlexDBlack

Copy link
Copy Markdown
Contributor Author

@treo Thanks for the review

From my understanding of the paper, the big thing about Bert is that they pre-train using both the MLM / Cloze task and next sentence classification task at the same time.

Yes, that is my understanding also, and the omission was intentional at this point. I want to get something usable sooner rather than later, even if it's not optimal. My main goal for now was the sequence classification task as that's what we'll be using initially for transfer learning.

As for supporting the "next sentence classification" task, I want that. But it'll be more complex to implement: instead of iterating over sentences, we'll want to iterate over documents, and we'l need some automated way to break text into sentences.
Alternatively (or, additionally), we introduce a "labelled sentence pair iterator" for this.

So, future additions we'll need here:

There's some non-trivial challenges with those, and I planned to address them separately. (Javadoc should reflect that, however)

The SEQ_CLASSIFICATION task also doesn't look like it is not an instance of the next-sentence classification task.

It's not. It's designed for transfer learning, single sequence in, single label out... I'll clarify that.

@treo

treo commented Apr 4, 2019

Copy link
Copy Markdown
Member

Great, with the clarification that the intent wasn't to support all the unsupervised pre-training options yet, and the fixes in the java doc, only the question of when you'd use RANK3_NLC, my guess is that some of the imported models may need it?

@AlexDBlack
AlexDBlack merged commit 288e258 into master Apr 4, 2019
@AlexDBlack
AlexDBlack deleted the ab_bert_iterator branch April 4, 2019 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants