title: Either one of corpus_file or corpus_iterable value must be provided while training the word2vec model python
body: <p>I have just started with word2vec model and I want to make different cluster from my questions data.</p>
  <p>So to make clusters what I got is, I have to</p>
  <p>Create word embedding model
  Get the word vector from the model
  Create sentence vector from word vector
  Using Kmeans cluster the questions data</p>
  <p>So to get the word2vec word vector, <a href="https://www.kaggle.com/chewzy/tutorial-how-to-train-your-custom-word-embedding" rel="nofollow noreferrer">one of the article says</a></p>
  <pre><code>def get_word2vec(tokenized_sentences):
      print(&quot;Getting word2vec model...&quot;)
      model = Word2Vec(tokenized_sentences, min_count=1)
      return model.wv
  </code></pre>
  <p>and then just create sentence vector and the Kmeans.</p>
  <p><a href="https://github.com/aravindmanoharan/Word2Vec-Using-Gensim/blob/master/word2vec.ipynb" rel="nofollow noreferrer">and other article says</a>, after getting the word2vec model I have to build the vocab and then need to train the model. And then create sentence vector and then Kmeans/</p>
  <pre><code>def get_word2vec_model(tokenized_sentences):
      start_time = time.time()
      print(&quot;Getting word2vec model...&quot;)
      model = Word2Vec(tokenized_sentences, sg=1, window=window_size,vector_size=size, min_count=min_count, workers=workers, epochs=epochs, sample=0.01)
      log_total_time(start_time)
      return model 
  
  
  def get_word2vec_model_vector(model):
      start_time = time.time()
      print(&quot;Training...&quot;)
  #     model = Word2Vec(tokenized_sentences, min_count=1)
      model.build_vocab(sentences=shuffle_corpus(tokenized_sentences), update=True)
      # Training the model
      for i in tqdm(range(5)):
          model.train(sentences=shuffle_corpus(tokenized_sentences), epochs=50, total_examples=model.corpus_count)
      log_total_time(start_time)
      return model.wv
  
  def shuffle_corpus(sentences):
      shuffled = list(sentences)
      random.shuffle(shuffled)
      return shuffled
  </code></pre>
  <p>and this is how my tokenized_sentences look like</p>
  <pre><code>8857                                     [, , , year, old]
  11487     [, , birthday, canada, cant, share, job, friend]
  20471                       [, , chat, people, also, talk]
  5877                                           [, , found]
  </code></pre>
  <p><strong>Q1)</strong> the second approach gives the following error</p>
  <pre><code>---&gt; 54     model.build_vocab(sentences=shuffle_corpus(tokenized_sentences), update=True)
       55     # Training the model
       56     for i in tqdm(range(5)):
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\word2vec.py in build_vocab(self, corpus_iterable, corpus_file, update, progress_per, keep_raw_vocab, trim_rule, **kwargs)
      477 
      478         &quot;&quot;&quot;
  --&gt; 479         self._check_corpus_sanity(corpus_iterable=corpus_iterable, corpus_file=corpus_file, passes=1)
      480         total_words, corpus_count = self.scan_vocab(
      481             corpus_iterable=corpus_iterable, corpus_file=corpus_file, progress_per=progress_per, trim_rule=trim_rule)
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\word2vec.py in _check_corpus_sanity(self, corpus_iterable, corpus_file, passes)
     1484         &quot;&quot;&quot;Checks whether the corpus parameters make sense.&quot;&quot;&quot;
     1485         if corpus_file is None and corpus_iterable is None:
  -&gt; 1486             raise TypeError(&quot;Either one of corpus_file or corpus_iterable value must be provided&quot;)
     1487         if corpus_file is not None and corpus_iterable is not None:
     1488             raise TypeError(&quot;Both corpus_file and corpus_iterable must not be provided at the same time&quot;)
  
  TypeError: Either one of corpus_file or corpus_iterable value must be provided
  </code></pre>
  <p>and</p>
  <p><strong>Q2)</strong> Is is necessary build the vocab and then train the data? or getting model is the only thing i need to do?</p>