tokenizers icon indicating copy to clipboard operation
tokenizers copied to clipboard

Average running time of encode vs encode_batch for BertWordPieceTokenizer in Python

Open Mansterteddy opened this issue 6 years ago • 2 comments

Hi,

Recently I am testing encode and encode_batch function for BertWordPieceTokenizer in Python, sequence length is 128, vocab is multi-lingual vocab from BERT (size=119547).

When Batch Size = 1, the average running times are similar, encode function and encode_batch function uses both 0.27ms.

However, when Batch Size = 5 and RAYON_RS_NUM_CPUS = 6, the average running time of encode function is 1.07ms, the average running time of encode_batch function is 1.50ms.

When RAYON_RS_NUM_CPUS = 1, the average running time of encode_batch function is 2.63ms.

Are above results expected?

Best Wishes!

Mansterteddy avatar Feb 14 '20 16:02 Mansterteddy

Seems related to this issue: https://github.com/rayon-rs/rayon/issues/319.

Mansterteddy avatar Feb 18 '20 05:02 Mansterteddy

Try with larger sequence length (128 * 5 = 640), encode_batch function is faster than encode function, thus I think it is related to NUMA aware Scheduling of Rayon.

Mansterteddy avatar Feb 29 '20 12:02 Mansterteddy