How to get vector for a sentence from the word2vec of tokens in sentence

后端 未结 9 1869
鱼传尺愫
鱼传尺愫 2020-12-02 04:18

I have generated the vectors for a list of tokens from a large document using word2vec. Given a sentence, is it possible to get the vector of the sentence from the vector of

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 04:32

    let suppose this is current sentence

    import gensim 
    from gensim.models import Word2Vec
    from gensim import models
    model = gensim.models.KeyedVectors.load_word2vec_format('path of your trainig 
    dataset', binary=True)
    
    strr = 'i am'
    strr2 = strr.split()
    print(strr2)
    model[strr2] //this the the sentance embeddings.
    

提交回复
热议问题