Skip to content

LogicalSpark/marian

 
 

Repository files navigation

Marian

CUDABuild Status CPU Build Status Twitter

Marian (formerly known as AmuNMT) is an efficient Neural Machine Translation framework written in pure C++ with minimal dependencies. It has mainly been developed at the Adam Mickiewicz University in Poznań (AMU) and at the University of Edinburgh.

It is currently being deployed in multiple European projects and is the main translation and training engine behind the neural MT launch at the World Intellectual Property Organization.

Main features:

  • Fast multi-gpu training and translation
  • Compatible with Nematus and DL4MT
  • Efficient pure C++ implementation
  • Permissive open source license (MIT)
  • more details...

If you use this, please cite:

Marcin Junczys-Dowmunt , Roman Grundkiewicz, Tomasz Dwojak, Hieu Hoang, Kenneth Heafield, Tom Neckermann, Frank Seide, Ulrich Germann, Alham Fikri Aji, Nikolay Bogoychev, André F. T. Martins, Alexandra Birch (2018). Marian: Fast Neural Machine Translation in C++ (https://arxiv.org/abs/1804.00344)

@article{junczys2018marian,
  title={Marian: Fast Neural Machine Translation in C++},
  author={Marcin Junczys-Dowmunt and Roman Grundkiewicz and Tomasz Dwojak and Hieu Hoang and Kenneth Heafield and Tom Neckermann and Frank Seide and Ulrich Germann and Alham Fikri Aji and Nikolay Bogoychev and André F. T. Martins and Alexandra Birch},
  journal={arXiv preprint arXiv:1804.00344},
  url={https://arxiv.org/abs/1804.00344}
  year={2018}
}

Website:

More information on https://marian-nmt.github.io

Recommended software

GPU version

Ubuntu 16.04 LTS (tested and recommended). For Ubuntu 16.04 the standard packages should work. On newer versions of Ubuntu, e.g. 16.10, there may be problems due to incompatibilities of the default g++ compiler and CUDA.

  • CMake 3.5.1 (default)
  • GCC/G++ 5.4 (default)
  • Boost 1.58 (default)
  • CUDA 8.0

Ubuntu 14.04 LTS. A newer CMake version than the default version is required and can be installed from source.

  • CMake 3.5.1 (due to CUDA related bugs in earlier versions)
  • GCC/G++ 4.9
  • Boost 1.54
  • CUDA 8.0

CPU version

The CPU-only version will automatically be compiled if CUDA cannot be detected by CMake. Only the translator will be compiled, the training framework is strictily GPU-based.

Tested on different machines and distributions:

  • CMake 3.5.1
  • The CPU version should be a lot more forgiving concerning GCC/G++ or Boost versions.

macOS

To be able to make the CPU version on macOS, first install brew and then run:

brew install cmake boost

# Python 2 default
brew install boost-python

# Python 3
brew install boost-python --with-python3

Then, proceed to the next section.

Download and Compilation

Clone a fresh copy from github:

git clone https://github.com/marian-nmt/marian.git

The project is a standard CMake out-of-source build:

cd marian
mkdir build && cd build
cmake ..
make -j

If run for the first time, this will also download Marian -- the training framework for Marian.

Other cmake options:

  • Build the CPU-only version of amun (training is GPU-only)

    cmake .. -DCUDA=off
    
  • Adding debugging symbols (for use with gdb, etc)

    cmake .. -DCMAKE_BUILD_TYPE=Debug
    
  • Specifying Python version to compile against

     # Linux
     cmake .. -DPYTHON_VERSION=2.7
     cmake .. -DPYTHON_VERSION=3.5
     cmake .. -DPYTHON_VERSION=3.6
    
     # macOS
     cmake .. -DPYTHON_VERSION=2
     cmake .. -DPYTHON_VERSION=3
    

Compile Python bindings

In order to compile the Python library, after running make as in the previous section, do:

make python

This will generate a libamunmt.dylib or libamunmt.so in your build/src/ directory, which can be imported from Python.

Running Marian

Training

Assuming corpus.en and corpus.ro are corresponding and preprocessed files of a English-Romanian parallel corpus, the following command will create a Nematus-compatible neural machine translation model.

./marian/build/marian \
  --train-sets corpus.en corpus.ro \
  --vocabs vocab.en vocab.ro \
  --model model.npz

See the documentation for a full list of command line options or the examples for a full example of how to train a WMT-grade model.

Translating

If a trained model is available, run:

./marian/build/amun -m model.npz -s vocab.en -t vocab.ro <<< "This is a test ."

See the documentation for a full list of command line options or the examples for a full example of how to use Edinburgh's WMT models for translation.

Example usage

Acknowledgements

The development of Marian received funding from the European Union's Horizon 2020 Research and Innovation Programme under grant agreements 688139 (SUMMA; 2016-2019), 645487 (Modern MT; 2015-2017), 644333 (TraMOOC; 2015-2017), 644402 (HiML; 2015-2017), the Amazon Academic Research Awards program, the World Intellectual Property Organization, and is based upon work supported in part by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via contract #FA8650-17-C-9117.

This software contains source code provided by NVIDIA Corporation.

About

Fast Neural Machine Translation in C++

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 59.6%
  • Cuda 16.0%
  • TeX 11.0%
  • Jupyter Notebook 5.3%
  • C 2.5%
  • CMake 2.0%
  • Other 3.6%