Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: load_word2vec_format() got an unexpected keyword argument 'no_header' #44

Closed
cayaluke opened this issue Nov 26, 2021 · 2 comments

Comments

@cayaluke
Copy link

  • OCTIS version: 1.10.0
  • Python version: 3.6.13
  • Operating System: Windows 10

Description

Hi @lffloyd and @silviatti

I tried to run the ETM with pre-trained embeddings after the recent upgrade, and it returned this error.

TypeError: load_word2vec_format() got an unexpected keyword argument 'no_header'.

Please advise if I made an error on my end.

My commands and traceback are provided below.

Thank you so much!
Luke

What I Did

model = ETM(num_topics=40, num_epochs=1, use_partitions=False, train_embeddings=False,
            embeddings_type='word2vec', embeddings_path=r'my/path/to/embedding/skipgram_emb_300d.txt', binary_embeddings=False, headerless_embeddings=True)

output= model.train_model(dataset)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
d:\01MRes_ubuntu\OCTIS\fomcNoPartitionsPreTrained\EtmRunModelPreTrained300.py in <module>
----> 26 output_fomc_etm = model.train_model(dataset)

~\anaconda3\envs\lda_env36\lib\site-packages\octis\models\ETM.py in train_model(self, dataset, hyperparameters, top_words)
     74         if hyperparameters is None:
     75             hyperparameters = {}
---> 76         self.set_model(dataset, hyperparameters)
     77         self.top_word = top_words
     78         self.early_stopping = EarlyStopping(patience=5, verbose=True)

~\anaconda3\envs\lda_env36\lib\site-packages\octis\models\ETM.py in set_model(self, dataset, hyperparameters)
    119 
    120         self.set_default_hyperparameters(hyperparameters)
--> 121         self.load_embeddings()
    122         ## define model and optimizer
    123         self.model = etm.ETM(num_topics=self.hyperparameters['num_topics'], vocab_size=len(self.vocab.keys()),

~\anaconda3\envs\lda_env36\lib\site-packages\octis\models\base_etm.py in load_embeddings(self)
     52                                         self.hyperparameters['embeddings_type'],
     53                                         self.hyperparameters['binary_embeddings'],
---> 54                                         self.hyperparameters['headerless_embeddings'])
     55         embeddings = np.zeros((len(self.vocab.keys()), self.hyperparameters['embedding_size']))
     56         for i, word in enumerate(self.vocab.values()):

~\anaconda3\envs\lda_env36\lib\site-packages\octis\models\base_etm.py in _load_word_vectors(self, embeddings_path, embeddings_type, binary_embeddings, headerless_embeddings)
     85                 embeddings_path,
     86                 binary=binary_embeddings,
---> 87                 no_header=headerless_embeddings)
     88 
     89         vectors = {}

TypeError: load_word2vec_format() got an unexpected keyword argument 'no_header'
@lfmatosm
Copy link
Contributor

Hi @cayaluke!

First, how are you using octis? You've cloned the repository or installed the library? Can you confirm which version of gensim is in use by your environment?

This seems to be related to a mismatch in the gensim version. The package needs gensim>=4.0.0, which supports the no_header argument as stated here. However, previous versions might not support this. I gave a glance at gensim's 3.8.3 docs, and this isn't supported there.

@cayaluke
Copy link
Author

Hello @lffloyd, thank you for your response.

  1. I can confirm that my version of gensim is 3.8.3.

I have since upgraded gensim to 4.1.2 and she worked perfectly!

@lffloyd and @silviatti thank you again for your hard work.

Best
Luke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants