MIND-Lab / OCTIS

OCTIS: Comparing Topic Models is Simple! A python package to optimize and evaluate topic models (accepted at EACL2021 demo track)
MIT License
734 stars 106 forks source link

AttributeError: 'WordEmbeddingsCentroidSimilarity' object has no attribute 'binary' #41

Closed rsimd closed 3 years ago

rsimd commented 3 years ago

Description

I'm not familiar with Github, so I may be rude. Thank you for publishing such a great works.

It seems that the constructors of WardEmbeddingsPairwiseSimilarity and WardEmbeddingsCentroidSimilarity did not have self.binary. Therefore, I could not use any pretrained word embeddings other than the default.

What I Did

In [2]: from octis.evaluation_metrics import similarity_metrics

In [3]: dummy_kv_path = "/workdir/dummy_kv.txt"

In [4]: similarity_metrics.WordEmbeddingsPairwiseSimilarity(word2vec_path=dummy_kv_path)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-c02dac4f77ab> in <module>
----> 1 similarity_metrics.WordEmbeddingsPairwiseSimilarity(word2vec_path=dummy_kv_path)

~/.cache/pypoetry/virtualenvs/sktopic-L2WRRFYm-py3.9/lib/python3.9/site-packages/octis/evaluation_metrics/similarity_metrics.py in __init__(self, word2vec_path, topk)
     71             self.wv = api.load('word2vec-google-news-300')
     72         else:
---> 73             self.wv = KeyedVectors.load_word2vec_format( word2vec_path, binary=self.binary)
     74 
     75         self.topk = topk

AttributeError: 'WordEmbeddingsPairwiseSimilarity' object has no attribute 'binary'

In [5]: similarity_metrics.WordEmbeddingsCentroidSimilarity(word2vec_path=dummy_kv_path)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-1f1c772b67de> in <module>
----> 1 similarity_metrics.WordEmbeddingsCentroidSimilarity(word2vec_path=dummy_kv_path)

~/.cache/pypoetry/virtualenvs/sktopic-L2WRRFYm-py3.9/lib/python3.9/site-packages/octis/evaluation_metrics/similarity_metrics.py in __init__(self, word2vec_path, topk)
    115             self.wv = api.load('word2vec-google-news-300')
    116         else:
--> 117             self.wv = KeyedVectors.load_word2vec_format(word2vec_path, binary=self.binary)
    118         self.topk = topk
    119 

AttributeError: 'WordEmbeddingsCentroidSimilarity' object has no attribute 'binary'
silviatti commented 3 years ago

Hi! Thanks for reporting the issue.

I have just released a new version of OCTIS that handles this problem (v 1.10.0). You can run pip install -U octis to download the latest version. Feel free to reopen the issue if you still have problems.

Silvia

rsimd commented 3 years ago

Thank you. I'll try it.