一行代码使用BERT生成句向量,BERT做文本分类、文本相似度计算
Go to file
2019-01-29 18:31:51 +08:00
data 添加代码 2019-01-29 18:31:51 +08:00
__init__.py 添加代码 2019-01-29 18:31:51 +08:00
args.py 添加代码 2019-01-29 18:31:51 +08:00
extract_feature.py 添加代码 2019-01-29 18:31:51 +08:00
extract_features_or.py 添加代码 2019-01-29 18:31:51 +08:00
graph.py 添加代码 2019-01-29 18:31:51 +08:00
modeling.py 添加代码 2019-01-29 18:31:51 +08:00
optimization.py 添加代码 2019-01-29 18:31:51 +08:00
README.md 添加代码 2019-01-29 18:31:51 +08:00
requirements.txt 添加代码 2019-01-29 18:31:51 +08:00
similarity.py 添加代码 2019-01-29 18:31:51 +08:00
tokenization.py 添加代码 2019-01-29 18:31:51 +08:00

bert_feature

how to use Bert generate the sentence vector

1、download the model

model path: https://storage.googleapis.com/bert_models/2018_11_03/chinese_L-12_H-768_A-12.zip

2、Move the model in the same directory

3、init BertVector object and invokes the encode method, the param must be list

from bert.extrac_feature import BertVector
bv = BertVector()
bv.encode(['你好'])