bert icon indicating copy to clipboard operation
bert copied to clipboard

how to speed up the prediction?

Open quincyliang opened this issue 8 years ago • 9 comments

The fine-tuned Chinese model is good in my task, but I found it takes around 1s to process a batch of five records (each record is 128 characters long) using CPU. Is there any suggestion to speed up the prediction? Thanks.

quincyliang avatar Nov 20 '18 07:11 quincyliang

do you install tensorflow using bazel? it can accelerate the CPU calaulation about 3x, or maybe you can try GPU.

xwzhong avatar Nov 20 '18 12:11 xwzhong

for faster prediction, please kindly check my bert-as-service, which implements highly-scalable non-blocking prediction for BERT.

hanxiao avatar Nov 20 '18 14:11 hanxiao

@xwzhong No. I just use the docker image of tensorflow.

quincyliang avatar Nov 20 '18 15:11 quincyliang

If you use tpu, TPU prediction only works on a single host (one TPU worker). Gpu is much faster than cpu.. Maybe you can think about buy a graphic card...

monanahe avatar Nov 21 '18 07:11 monanahe

BERT will always be slow on the CPU, there is not an easy way to speed it up other than to switch to GPU or TPU as suggested here.

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

Why is bert prediction faster on gpu?

sibbsnb avatar Apr 26 '19 23:04 sibbsnb

@hanxiao If you can provide an example of entity recognition, it’s really good.

Thanks very much! super.single430

Single430 avatar Apr 29 '19 09:04 Single430

@hanxiao Can you please share an example for predicting sentence similarity without encoding sentence. I have fine tuned bert quora question pairs and inference is taking 1-2 seconds after export. Can we get faster than this?

Thanks,

ghost avatar Apr 30 '19 11:04 ghost

@xwzhong Hi. I tried building tensorflow using bazel from the official instruction. However the build runs for a long time, then throws error. Can you tell me the exact steps you followed?

sayak1711 avatar Feb 03 '20 15:02 sayak1711