bert-as-service安装
bert-as-service安装
之前做NLP任务的时候,比较喜欢用word2vec对词向量进行训练,然后作为神经网络的初始化输入。同事说你应该试试bert,bert效果可好了。对于这个领域的小白,我首先想到了bert-as-service,这里十分感谢肖涵博士。
bert-as-service安装很简单,直接pip install bert-serving-server; pip install bert-serving-client.这俩版本最好一致。
然后就是下载需要的已经训练好的语料,语料可以参考:
https://github.com/google-research/bert#pre-trained-models
以及:
https://github.com/ymcui/Chinese-BERT-wwm
bert-as service使用
上面两个步骤完成后,打开一个cmd窗口,输入:
bert-serving-start -model_dir E:\Papers\bert\chinese_L-12_H-768_A-12
其中E:\Papers\bert\chinese_L-12_H-768_A-12是下载的预训练语料的存储路径,这个chinese_L-12_H-768_A-12里面包括:
bert_config.json
bert_model.ckpt.data-00000-of-00001
bert_model.ckpt.index
bert_model.ckpt.meta
vocab.txt
即预训练的配置,模型以及单词和字母表。
然后你的cmd窗口中