word2vec:
就是将单词或句子映射到高维空间,得到一组向量。 如果最近遇到任务,则必须为特定语句key提取相应的value。
例如,根据身份证ocr结果,输入名字得到对应的人的名字
这样想的话,要从名字这个短语box中得到人名box的结果,不仅是相对的位置,语言之间的关联性不也是一个起点吗?
谷歌在官方的github上面登载了预训练模式。 利用预训练模式进行词语嵌入是一件很简单的事情:
预培训模式下载:链接: https://github.com/Google-research/Bert # pre-trained-models
我在用BERT-Base,Chinese
解压缩安装软件包: pipinstalltensorflow-GPU==1.15 pip install-ubert-serving-server Bert-serving-client启动: Bert-serving-cent : from Bert-serving.clientimportbertclient (client=Bert client ) ) vectors=client.encode ) [ 'man相似度的计算: from som ert客户端) ) def cosine(a ) a,b ) :returna.dot(b )/(NP.Lina LG.norm ) a ) NP.Lina LG.norm (b ) ) vectors
['First do it ',' then do it right'] : 0.92645866