简体   繁体   English

在 tensorflow 中训练一个 Bert 词嵌入模型

[英]Training a Bert word embedding model in tensorflow

I have my own corpus of plain text.我有自己的纯文本语料库。 I want to train a Bert model in TensorFlow, similar to gensim's word2vec to get the embedding vectors for each word.我想在TensorFlow中训练一个Bert模型,类似于gensim的word2vec来获取每个词的嵌入向量。

What I have found is that all the examples are related to any downstream NLP tasks like classification.我发现所有示例都与任何下游 NLP 任务(如分类)相关。 But, I want to train a Bert model with my custom corpus after which I can get the embedding vectors for a given word.但是,我想用我的自定义语料库训练一个 Bert 模型,之后我可以获得给定单词的嵌入向量。

Any lead will be helpful.任何线索都会有所帮助。

If you have access to the required hardware, you can dig into NVIDIA's training scripts for BERT using TensorFlow.如果您可以访问所需的硬件,则可以使用 TensorFlow 深入了解 NVIDIA 的 BERT 训练脚本。 The repo is here .回购在这里 From the medium article :来自 媒体文章

BERT-large can be pre-trained in 3.3 days on four DGX-2H nodes (a total of 64 Volta GPUs). BERT-large 可以在 3.3 天内在四个 DGX-2H 节点(总共 64 个 Volta GPU)上进行预训练。

If you don't have an enormous corpus, you will probably have better results fine-tuning an available model.如果您没有庞大的语料库,则对可用模型进行微调可能会获得更好的结果。 If you would like to do so, you can look into huggingface's transformers .如果你想这样做,你可以研究一下拥抱脸的变形金刚

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM