Distributed Word Embedding (DWE)
The DWE tool is a parallelization of the Word2Vec algorithm on top of our DMTK parameter server. It provides an efficient "scaling to industry size" solution for word embedding.
The DWE tool runs in the following manner:
On the client side (running on multiple nodes): three local training steps are executed repeatedly:
1. Get the latest parameters from the DMTK parameter server
2. Run the CBOW/Skip-gram algorithm to generate updates to the current parameters
3. Send the parameter updates to the DMTK parameter server
On the server side, the DMTK parameter server acts as below:
1. Pack the requested parameters and send them to clients
2. Aggregate parameter updates from different clients and merge them into the global parameters
The DWE tool is highly scalable and efficient,thus can be used to train very large scale word embedding.This is powered by the DMTK framework:
The DMTK parameter server stores the parameters in a distributed way, which means that each machine just holds a partition of the entire parameter set. This allows the entire embedding vector to be very large. For example, in our experiment on the ClueWeb data, the vocabulary size is 21 Million, and the parameter size reaches 6 Billion, which is the largest word embedding model ever reported in the literature,as far as we know.
The training process in the clients is conducted in a streaming manner and is automatically pipelined. Specifically, during the training, the data are processed block by block. For each block, the client software will go three the three step as aforementioned. The parameter request and model training steps in successive data blocks are pipelined so as to hide the delay caused by the network communication. Furthermore, in this way, the clients just need to hold the parameters for several data blocks simultaneously,corresponding to very economic memory usage.
To download the source codes of DWE, please run
$ git clone http://github.com/Microsoft/WordEmbedding
Please note that Distributed WordEmbedding is implemented in C++ for performance consideration.
DWE is built on top of the DMTK parameter sever, therefore please download and build this project first.
- Download and build the dependence
- Open sln/WordEmbedding.sln using Visual Studio 2013 and build all the projects
Ubuntu(Test on Ubuntu 12.04)
- Download and build the dependence by running $ sh script/install_dep.sh
- Modify the include and lib path in Makefile
- Run $ make all -j4
Training on a single machine
- Initialize the settings in the run.bat according to your preference
- Run run.bat in the solution directory
Training with distributed setting
- Create a host.txt file containing all the machines to be used for training
- Split your dataset into several parts and store them into the same directory of these machines
- Distribute the same executable file into the same directory of these machines
- Run the command line "smpd.exe -d -p port" in every machine
- Run run.bat in one of the machines with host.txt as its argument
- Compile the library of the DMTK parameter server, by specifying the communication mode to be ZMQ
- Compile the project Multverso.Sever, and you will get the executable Multiverso.Sever.exe
- Prepare a configuration file end_points.txt to describe the sever endpoints
- Add a parameter setting in run.bat, e.g.,'set _endpoint_file=config.txt'
- Start Multiverso.Sever.exe in each sever machine with appropriate command line arguments (please use Multiverso.Sever.exe -help for further information)
- Execute run.bat in one of the machines with end_points.txt as its argument
For the word embedding algorithms,we have implemented both CBOW and Skip-gram. For the output layer,we support both negative sampling and hierarchical softmax.Users can specify their desired setting by setting the parameters in run.bat.
For the distributed training,users can configure the size of the data block, the mechanism for parameter update (such as ASP - Asynchronous Parallel, SSP - Stale Synchronous Parallel, BSP - Bulk Synchronous Parallel, and MA - Model Average), by setting the parameters in run.bat. For more details, please refer to the document of the DMTK parameter server.
We report the performance of the DWE tool on the English versions of Wiki2014  and Clueweb09 . The statistics* of these datasets and the performances of DWE are given as follows. The experiments are run on 20 cores of Intel Xeon E5-2670 CPU on each machine.
|Dataset||Token#||Vocabulary size||Embedding dimension||Machine#||Traning time cost/epoch(seconds)||Accuracy on analogical reasoning task||Spearman's Rank Correlation on word similarity 353(ws353) dataset|
* The dataset statistics are got after data preprocessing.
- All the above experiments were run with the configuration of CBOW + negative sampling. For DWE, ASP was used as the mechanism for parameter update and the data block size is set as 1GB.
- Given that the Clueweb09 dataset is very large, we only went through the data once during the training process (one training epoch). For the Wiki2014 dataset, the results were obtained by going through 20 epochs.
- The results clearly show that DWE can achieve good speed up by leveraging the DMTK framework as compared to the original Word2Vec algorithm.
 Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean.Efficient Estimation of Word Representations in Vector Space.In Proceedings of Workshop at ICLR, 2013.
 Word similarity task
 Wiki2014 dataset
 Clueweb09 dataset