python - 使用 BERT 进行独特词的特征提取

标签 python tensorflow nlp language-model

我正在使用 BERT 对给定文本出现的单词进行特征提取,但目前在 bert 官方 github ( https://github.com/google-research/bert ) 中的实现似乎只能计算文本中所有单词的特征,这使得它消耗太多的资源。是否可以为此目的对其进行调整?谢谢!!

最佳答案

BERT 不是上下文无关转换器,这意味着您不想像使用 word2vec 那样将它用于单个单词。这真的很重要——您想将您的输入置于上下文中。我的意思是你可以输入一个单词的句子,但为什么不直接使用 word2vec。

README 是这样说的:

Pre-trained representations can also either be context-free or contextual, and contextual representations can further be unidirectional or bidirectional. Context-free models such as word2vec or GloVe generate a single "word embedding" representation for each word in the vocabulary, so bank would have the same representation in bank deposit and river bank. Contextual models instead generate a representation of each word that is based on the other words in the sentence.

希望这是有道理的:-)

关于python - 使用 BERT 进行独特词的特征提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55575681/

相关文章:

Python获取文件路径

python - tensorflow 中的多个 gpus 和 AdamOptimizer

ubuntu - 如何更新 Protobuf 运行时库?

java - NLP for java,我应该使用哪个工具包?

java - 在运行时更改 CoreNLP 设置

python - 从Python中的字符串中提取日期

python - 使用 pyodbc 将 SQL Server 中的数据读取到 pandas

python - 在 Python 中清除所有 lru_cache

python - keras 'multi output' 中 'raw' 与 'flow_from_dataframe' 之间的区别 0x104567910

java - 句子之间的语义相似度