yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
836 stars 142 forks source link

disable padding. #20

Closed livc closed 4 years ago

livc commented 4 years ago

Hi, is there a fast way to disable padding to make sure all sentences in a batch have the same length? Thanks.

livc commented 4 years ago

I set k = len(d) in https://github.com/zysite/biaffine-parser/blob/master/parser/utils/alg.py#L7 to make sure no padding.

yzhangcs commented 4 years ago

I set k = len(d) in parser/utils/alg.py to make sure no padding.

No, this operation can't ensure no padding, since there is no guarantee that all sentences in a batch are in the same bucket.

livc commented 4 years ago

So any suggestions?

yzhangcs commented 4 years ago

Since sentences are variable-length, there's no way to totally avoid the padding. Actually, using kmeans algorithm can guarantee that all the sentences in a batch are roughly the same length.