我试着关注 this.
但有些是我浪费了很多时间,结果却没有任何用处。
我只想训练一个 GloVe
在我自己的语料库上建模(~900Mb corpus.txt 文件)。
我下载了上面链接中提供的文件并使用 cygwin
编译它(编辑 demo.sh 文件并将其更改为 VOCAB_FILE=corpus.txt
后。我应该保持 CORPUS=text8
不变吗?)
输出是:
我如何使用这些文件将其加载为
GloVe
python上的模型?
最佳答案
You can do it using GloVe library:
安装它:pip install glove_python
然后:
from glove import Corpus, Glove
#Creating a corpus object
corpus = Corpus()
#Training the corpus to generate the co occurence matrix which is used in GloVe
corpus.fit(lines, window=10)
glove = Glove(no_components=5, learning_rate=0.05)
glove.fit(corpus.matrix, epochs=30, no_threads=4, verbose=True)
glove.add_dictionary(corpus.dictionary)
glove.save('glove.model')
引用:word vectorization using glove
关于nlp - 如何在我自己的语料库上训练 GloVe 算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48962171/