Search code examples
pythongensimword2vec

How to view word2vec model


I just want to be able to see the values in my word2vec model.

I have a very small corpus. I just want to see exactly what happens in each step for this particular corpus.

A section of my code is below.

word2vec = Word2Vec(corpus, min_count=1)
word_vectors = word2vec.wv 

termsim_index = WordEmbeddingSimilarityIndex(word_vectors)


dictionary = corpora.Dictionary(food)
bow_corpus = [dictionary.doc2bow(doc) for doc in food]


similarity_matrix = SparseTermSimilarityMatrix(termsim_index, dictionary)  
docsim_index = SoftCosineSimilarity(bow_corpus, similarity_matrix, num_best=10)

So I want to see what exactly is in word_vectors,termsim_index,similarity_matrix , docsim_index


Solution

  • To see more of what's happening during each function, you should enable logging at the INFO level.

    But then, each of your created objects have documented properties you can freely examine – either by looking at the gensim docs per class, or using generic Python operations – like those described in other SO questions, such as Is there a built-in function to print all the current properties and values of an object?.

    To give more specific suggestions, you'd have to explain more what exactly you "want to see".