Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
Go to file
Nikolay Bogoychev d82e01eda4
Full windows support with ssplit from browsermt, not a fork (#109)
* Update marian-dev to the newest mac version

* Attempt windows workflow

* force workflow rerun

* Separate id

* Attempt 3 at github action

* Marian dev submodule now compiles with apple clang

* Updated ssplit version to something more recent

* Attempt to fix compile on wasm

* Do not compile subproject tests

* Fix emscripten compilation on Mac

* 99% on the way to windows compile

* Try with a different generator

* Build release not debug

* Revert CMakeLists.txt hacks

* Fix sse2 compilation failure

* MSVC settings for WIN32

* Add nodefaultlib LIBCMT

* Do not compile ssplit.cpp as it contains sys/mman.h

* Revert ab56b9aa4f

* Update paths

* Set the build type to release if not set previously

* Attempt to build release with the windows workflow

* Attempt 5 at VS studio release build

* Attempt 6 at getting release build on MSVC generator

* The windows build is debug at the moment...

* fix ssplit for ubuntu 16.04

* Fix compilation with clang

* Compile on ubuntu16.04

* Explain what is going on

* Updated ssplit and workflow
2021-05-01 00:29:23 +01:00
.github/workflows Full windows support with ssplit from browsermt, not a fork (#109) 2021-05-01 00:29:23 +01:00
3rd_party Full windows support with ssplit from browsermt, not a fork (#109) 2021-05-01 00:29:23 +01:00
app Cleanup API: Refactor request on-complete transition (#80) 2021-04-27 15:56:39 +01:00
bergamot-translator-tests@3771001720 Moving small tests to GitHub CI (#93) 2021-04-16 11:58:53 +01:00
doc Marian submodule update (#74) 2021-04-01 16:29:02 +01:00
src Full windows support with ssplit from browsermt, not a fork (#109) 2021-05-01 00:29:23 +01:00
wasm Better error logging for wasm test page 2021-04-30 09:09:41 +02:00
.gitignore Merge remote-tracking branch 'origin/wasm-integration' into jp/absorb-batch-translator 2021-02-17 13:08:58 +00:00
.gitmodules Moving small tests to GitHub CI (#93) 2021-04-16 11:58:53 +01:00
BERGAMOT_VERSION Marian compatible documentation tooling (#67) 2021-03-24 17:00:53 +00:00
CMakeLists.txt Full windows support with ssplit from browsermt, not a fork (#109) 2021-05-01 00:29:23 +01:00
Doxyfile.in Marian compatible documentation tooling (#67) 2021-03-24 17:00:53 +00:00
LICENSE Initial commit 2020-10-19 13:49:38 +02:00
README.md Patch WASM artifacts to run optimized (wormhole enabled) inference (#68) 2021-03-24 17:10:42 +01:00

Bergamot Translator

Bergamot translator provides a unified API for (Marian NMT framework based) neural machine translation functionality in accordance with the Bergamot project that focuses on improving client-side machine translation in a web browser.

Build Instructions

Build Natively

  1. Clone the repository using these instructions:

    git clone https://github.com/browsermt/bergamot-translator
    cd bergamot-translator
    
  2. Compile

    Create a folder where you want to build all the artifacts (build-native in this case) and compile in that folder

    mkdir build-native
    cd build-native
    cmake ../
    make -j
    

Build WASM

Compiling for the first time

  1. Download and Install Emscripten using following instructions

    • Get the latest sdk: git clone https://github.com/emscripten-core/emsdk.git
    • Enter the cloned directory: cd emsdk
    • Install the lastest sdk tools: ./emsdk install latest
    • Activate the latest sdk tools: ./emsdk activate latest
    • Activate path variables: source ./emsdk_env.sh
  2. Clone the repository using these instructions:

    git clone https://github.com/browsermt/bergamot-translator
    cd bergamot-translator
    
  3. Download files (only required if you want to package files in wasm binary)

    This step is only required if you want to package files (e.g. models, vocabularies etc.) into wasm binary. If you don't then just skip this step.

    The build preloads the files in Emscriptens virtual file system.

    If you want to package bergamot project specific models, please follow these instructions:

    mkdir models
    git clone --depth 1 --branch main --single-branch https://github.com/mozilla-applied-ml/bergamot-models
    cp -rf bergamot-models/prod/* models
    gunzip models/*/*
    
  4. Compile

    1. Create a folder where you want to build all the artefacts (build-wasm in this case)

      mkdir build-wasm
      cd build-wasm
      
    2. Compile the artefacts

      • If you want to package files into wasm binary then execute following commands (Replace FILES_TO_PACKAGE with the path of the directory containing the files to be packaged in wasm binary)

        emcmake cmake -DCOMPILE_WASM=on -DPACKAGE_DIR=FILES_TO_PACKAGE ../
        emmake make -j
        

        e.g. If you want to package bergamot project specific models (downloaded using step 3 above) then replace FILES_TO_PACKAGE with ../models

      • If you don't want to package any file into wasm binary then execute following commands:

        emcmake cmake -DCOMPILE_WASM=on ../
        emmake make -j
        

      The wasm artifacts (.js and .wasm files) will be available in wasm folder of build directory ("build-wasm" in this case).

    3. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts

      bash ../wasm/patch-artifacts-enable-wormhole.sh
      

Recompiling

As long as you don't update any submodule, just follow steps in 4.ii and 4.iii to recompile.
If you update a submodule, execute following command before executing steps in 4.ii and 4.iii to recompile.

git submodule update --init --recursive

How to use

Using Native version

The builds generate library that can be integrated to any project. All the public header files are specified in src folder.
A short example of how to use the APIs is provided in app/main.cpp file.

Using WASM version

Please follow the README inside the wasm folder of this repository that demonstrates how to use the translator in JavaScript.