albert 中文使用

最近Google 设计了一个【精简版的BERT】ALBERT,预测性能和bert相比大大提高,自己尝试直接调用其开源代码:https://github.com/google-research/ALBERT 未能直接跑通,自己调试成功的代码地址如下:https://github.com/HappyYuanFang/albert_demo.git ,该代码可直接在windows  pycharm中跑通

使用方式如下参考 hello_bert.py

from albert.extract_feature import BertVector
pooling_strategy = "REDUCE_MEAN"
# pooling_strategy = "NONE"
bc = BertVector(pooling_strategy=pooling_strategy, max_seq_len=80)
s1 = '谢谢你,每一个平凡的中国人'
v = bc.encode([s1])
v1 = v["encodes"][0]
print(v1)

调试结果如下: 

发布了50 篇原创文章 · 获赞 16 · 访问量 4万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章