Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


C++ implementation of word2vec, bivec, and paragraph vector.


Monolingual model

  • Most of word2vec's features [1, 6]
  • Evaluation on the analogical reasoning task (multithreaded version of word2vec's compute-accuracy)
  • Batch and online paragraph vector [2]
  • Save & load full model, including configuration and vocabulary
  • Python wrapper

Bilingual model

  • Bivec-like training with a parallel corpus [3, 7]
  • Save & load full model
  • Trains two monolingual models, which can be exported and used by MultiVec
  • Python wrapper


  • G++ 4.4+
  • CMake 2.6+
  • Cython and NumPy for the Python wrapper


git clone
mkdir multivec/build
cd multivec/build
cmake ..
cd ..

The bin directory should now contain 4 binaries:

  • multivec-mono which is used to generate monolingual models;
  • multivec-bi to generate bilingual models;
  • word2vec which is a modified version of word2vec that matches our user interface;
  • compute-accuracy to evaluate word embeddings on the analogical reasoning task (multithreaded version of word2vec's compute-accuracy program).

Usage examples

First create two directories data and models at the root of the project, where you will put the text corpora and trained models. The script scripts/ can be used to pre-process a corpus (punctuation normalization, tokenization, etc.)

mkdir data
mkdir models
wget -P data
tar xzf data/training-parallel-nc-v9.tgz -C data
scripts/ data/training/ data/news-commentary fr en --tokenize --normalize-punk

To train a monolingual model using text corpus data/news-commentary.en (use -v option to see the training progress):

bin/multivec-mono --train data/news-commentary.en --save models/news-commentary.en.bin --threads 16

To train a bilingual model using parallel corpus data/ and data/news-commentary.en:

bin/multivec-bi --train-src data/ --train-trg data/news-commentary.en --save models/ --threads 16

To load a bilingual model and export it to source and target monolingual models:

bin/multivec-bi --load models/ --save-src models/ --save-trg models/

To evaluate a trained English model on the analogical reasoning task, first export it to the word2vec format, then use compute-accuracy:

bin/multivec-mono --load models/news-commentary.en.bin --save-vectors models/vectors.txt
bin/compute-accuracy models/vectors.txt 0 < word2vec/questions-words.txt

With this example, you should obtain results similar to these:

Vocabulary size: 25298
Embeddings size: 100
Total accuracy: 13.2%
Syntactic accuracy: 12.8%, Semantic accuracy: 33.3%
Questions seen: 6792/19544, 34.8%

Python wrapper

cd cython

Use and train models with Python ( must be in the PYTHONPATH, e.g. working directory):

>>> from multivec import MonolingualModel, BilingualModel
>>> model = BilingualModel('../models/')
>>> model.trg_model
<multivec.MonolingualModel at 0x7fcfe0d59870>
>>> model.trg_model.word_vec('France')
array([ 0.2600708 ,  0.72489363, ...,  1.00654161,  0.38837495])
>>> new_model = BilingualModel(dimension=300, threads=16)
>>> new_model.train('../data/', '../data/news-commentary.en')
>>> help(BilingualModel)  # all the help you need


  • paragraph vector: DBOW model (similar to skip-gram)
  • paragraph vector: option to concatenate, sum or average with word vectors on projection layer.
  • GIZA alignment for bilingual model
  • bilingual paragraph vector training


This toolkit is part of the project KEHATH ( funded by the French National Research Agency.

LREC Paper

When you use this toolkit, please cite:

Title                    = {{MultiVec: a Multilingual and Multilevel Representation Learning Toolkit for NLP}},
Author                   = {Alexandre Bérard and Christophe Servan and Olivier Pietquin and Laurent Besacier},
Booktitle                = {The 10th edition of the Language Resources and Evaluation Conference (LREC 2016)},
Year                     = {2016},
Month                    = {May}


  1. Distributed Representations of Words and Phrases and their Compositionality, Mikolov et al. (2013)
  2. Distributed Representations of Sentences and Documents, Le and Mikolov (2014)
  3. Bilingual Word Representations with Monolingual Quality in Mind, Luong et al. (2015)
  4. Learning Distributed Representations for Multilingual Text Sequences, Pham et al. (2015)
  5. BilBOWA: Fast Bilingual Distributed Representations without Word Alignments, Gouws et al. (2014)
  6. Word2vec project
  7. Bivec project


A Multilingual and Multilevel Representation Learning Toolkit for NLP




No releases published


No packages published

Contributors 4