Parallel (asynchronous) sparse coding implementation for obtaining sparse overcomplete word vectors
C++ Makefile
Latest commit abe0f7d Jun 9, 2015 Manaal Faruqui renamed Vector length to Input vector length

Sparse Coding

Manaal Faruqui,

This tool implements sparse coding for converting dense word vector representations to highly sparse vectors. The implementation can be run on multiple cores in parallel with asynchronous updates. The sparsity is introduced in the word vectors using L1 regularization. For technical details please refer to Faruqui et al (2015).

Data you need

Word Vector File. Each vector file should have one word vector per line as follows (space delimited):-

the -1.0 2.4 -0.3 ...


You need to download the latest Eigen stable release from here:

Unzip the folder and provide its path in the makefile: INCLUDES = -I PATH_TO_EIGEN

After this just execute the following command:

For sparse coding: make

For non-negative sparse coding: make nonneg

Running the executable

For sparse coding: sparse.o

For non-negative sparse coding: nonneg.o

Usage: ./sparse.o vec_corpus factor l1_reg l2_reg num_cores outfilename

Example: ./sparse.o sample_vecs.txt 10 0.5 1e-5 1 out_vecs.txt

This example would expand the vectors in sample_vecs.txt to 10 times their original length.


  author    = {Faruqui, Manaal and Tsvetkov, Yulia and Yogatama, Dani and Dyer, Chris and Smith, Noah A.},
  title     = {Sparse Overcomplete Word Vector Representations},
  booktitle = {Proceedings of ACL},
  year      = {2015},