bert icon indicating copy to clipboard operation
bert copied to clipboard

There is a endless loop when max_seq_length=64.

Open ethereal666 opened this issue 8 years ago • 2 comments

Thanks for your hard work. There is a endless loop when max_seq_length=64. your code:

max_tokens_for_doc = max_seq_length - len(query_tokens) - 3 ... while start_offset < len(all_doc_tokens): length = len(all_doc_tokens) - start_offset if length > max_tokens_for_doc: length = max_tokens_for_doc doc_spans.append(_DocSpan(start=start_offset, length=length)) if start_offset + length == len(all_doc_tokens): break start_offset += min(length, doc_stride)

I'm running fine-tuning on squad1.1. When "max_seq_length" is 64, "max_tokens_for_doc" is 0 in some training data, then the "length" is 0 and the "start_offset" is always 0. So the loop above is endless and my memory is growing until my program is killed.

ethereal666 avatar Nov 02 '18 03:11 ethereal666

Oops, there should be a check that max_seq_length > max_query_length + 3. But that also means that if you set max_seq_length = 64 then you'll also need to reduce max_query_length to something smaller so that there is at least one token left for the document. Keep in mind the results will be quite bad with max_seq_length=64.

jacobdevlin-google avatar Nov 02 '18 03:11 jacobdevlin-google

Added a validation check for this.

jacobdevlin-google avatar Nov 02 '18 22:11 jacobdevlin-google