Skip to content

Building word2vec

aborkar-ibm edited this page Aug 9, 2022 · 12 revisions

Building word2vec

The instructions provided below specify the steps to build word2vec version 0.1c on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9, 8.4, 8.6, 9.0)
  • SLES (12 SP5, 15 SP3, 15 SP4)
  • Ubuntu (18.04, 20.04, 22.04)

General notes:

  • When following the steps below please use a standard permission user unless otherwise specified.

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Build word2vec

  1. Install standard utilities, packages and platform specific dependencies
  • RHEL (7.8, 7.9, 8.4, 8.6, 9.0)

     sudo yum install -y gcc make wget tar unzip
  • SLES (12 SP5, 15 SP3, 15 SP4)

     sudo zypper install -y gcc make wget tar unzip
  • Ubuntu (18.04, 20.04, 22.04)

     sudo apt-get update
     sudo apt-get install -y gcc make wget tar unzip
  1. Create a working directory and download word2vec source code

     cd $SOURCE_ROOT
     wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/word2vec/source-archive.zip
     unzip source-archive.zip
    
  2. Build word2vec

     cd word2vec/trunk
     make CFLAGS="-lm -pthread -O3 -Wall -funroll-loops"
    
  3. Set environment variables

     export PATH=$PATH:$SOURCE_ROOT/word2vec/trunk
    
  4. Test word2vec using demo scripts

     ./demo-word.sh
     ./demo-phrases.sh
    

    Note: Enter test corpus as input and get word vectors as output, e.g. Input=france

  5. Run word2vec binary

     word2vec
    

    Note: The word2vec tool takes a text corpus as input and produces the word vectors as output.

References:

Clone this wiki locally