macanv / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services
https://github.com/macanv/BERT-BiLSMT-CRF-NER
4.69k stars 1.25k forks source link

推理速度 #293

Open caseware66 opened 4 years ago

caseware66 commented 4 years ago

使用 1个cpu 12核心,一个1000个字的文章,推理速度在1000ms,这个速度正常吗,GPU,大概是100毫秒。一般什么速度比较正常?

caseware66 commented 4 years ago

还有什么可以优化的方案吗?

caseware66 commented 4 years ago

公司现在要进行实时预测,一般速度多少合适?

macanv commented 4 years ago

实时要10ms左右吧,控制在30ms/example. 想加速的话,明天争取写个教程

caseware66 commented 4 years ago

好的,多谢您,请问您的加速是要使用gpu的基础上是吧。

---原始邮件--- 发件人: "MaCan"<notifications@github.com> 发送时间: 2020年1月11日(周六) 晚上8:28 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "caseware66"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

实时要10ms左右吧,控制在30ms/example. 想加速的话,明天争取写个教程

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

caseware66 commented 4 years ago

期待您明天的教程,谢谢!

---原始邮件--- 发件人: "MaCan"<notifications@github.com> 发送时间: 2020年1月11日(周六) 晚上8:28 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "caseware66"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

实时要10ms左右吧,控制在30ms/example. 想加速的话,明天争取写个教程

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

caseware66 commented 4 years ago

您好:

     您的推理加速的教程要是写好了,可以发给我学习一下吗?

 

------------------ 原始邮件 ------------------ 发件人: "MaCan"<notifications@github.com>; 发送时间: 2020年1月11日(星期六) 晚上8:27 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "泡沫"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

实时要10ms左右吧,控制在30ms/example. 想加速的话,明天争取写个教程

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

macanv commented 4 years ago

加班去了,没有写,不过和会争取快点写好。

caseware66 commented 4 years ago

谢谢!

---原始邮件--- 发件人: "MaCan"<notifications@github.com> 发送时间: 2020年1月14日(周二) 晚上8:07 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "caseware66"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

加班去了,没有写,不过和会争取快点写好。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

caseware66 commented 4 years ago

您的方法中是否albert替换bert,我目前在研究这个。

---原始邮件--- 发件人: "MaCan"<notifications@github.com> 发送时间: 2020年1月14日(周二) 晚上8:07 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "caseware66"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

加班去了,没有写,不过和会争取快点写好。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

yinyao commented 4 years ago

前不久刚测试过,albert_tiny推理速度大概有6、7倍左右的提升,但识别效果比bert_base要差不少,albert_base识别效果差一点,推理速度比bert_base还稍微慢一点。推理速度提升目前试出来的方法大概有使用GPU、减小max_seq_length、加大batch_size。期待作者大佬的教程。

caseware66 commented 4 years ago

albert_base的推理速度要比bert_base快吧。

---原始邮件--- 发件人: "yinyao"<notifications@github.com> 发送时间: 2020年2月5日(周三) 晚上10:24 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "caseware66"<157500647@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

前不久刚测试过,albert_tiny推理速度大概有6、7倍左右的提升,但识别效果比bert_base要差不少,albert_base识别效果差一点,推理速度比bert_base还稍微慢一点。推理速度提升目前试出来的方法大概有使用GPU、减小max_seq_length、加大batch_size。期待作者大佬的教程。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

yinyao commented 4 years ago

我测的albert_base训练比bert_base快很多,但推理速度并没有提升

macanv commented 4 years ago

@caseware66 https://blog.csdn.net/macanv/article/details/104194678

caseware66 commented 4 years ago

收到!

---原始邮件--- 发件人: "MaCan"<notifications@github.com> 发送时间: 2020年2月21日(周五) 晚上10:53 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "Mention"<mention@noreply.github.com>;"caseware66"<157500647@qq.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

@caseware66 https://blog.csdn.net/macanv/article/details/104194678

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

caseware66 commented 4 years ago

您好:        我在参考您的bert转化为albert的时候,出现了一个错误,麻烦您给看一下:

ValueError: Shape of variable bert/embeddings/LayerNorm/beta:0 ((128,)) doesn't match with shape of tensor bert/embeddings/LayerNorm/beta ([312]) from checkpoint reader.

------------------ 原始邮件 ------------------ 发件人: "MaCan"<notifications@github.com>; 发送时间: 2020年2月21日(星期五) 晚上10:53 收件人: "macanv/BERT-BiLSTM-CRF-NER"<BERT-BiLSTM-CRF-NER@noreply.github.com>; 抄送: "泡沫"<157500647@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [macanv/BERT-BiLSTM-CRF-NER] 推理速度 (#293)

@caseware66 https://blog.csdn.net/macanv/article/details/104194678

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

lvjianjin commented 4 years ago

作者服务端的实现方式是用bert-as-service+flask的搭建的,但是我用的过程中发现经常会报一些错误,可以采用这个方法,会稳定很多https://www.jianshu.com/p/383129b2bf7f