Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
Go to file
Abhishek Aggarwal 6c063c607e Updated CMakeLists.txt to remove packaging steps for wasm compilation
- Removed PACKAGE_DIR cmake option
 - Removed Workerfs, FORCE_FILESYSTEM=1 in wasm builds
   -- File system support is not needed any more (since model,
     shortlist and vocabs are being passed as bytes now)
2021-05-12 16:23:09 +02:00
.github/workflows Making bytearray a commandline switch (#127) 2021-05-06 00:26:03 +01:00
3rd_party Change USE_WASM_COMPATIBLE_SOURCE =OFF by default on native, force on for WASM (#138) 2021-05-10 12:28:37 +02:00
app Enable vocabs pass as byte arrays (#122) 2021-05-07 14:54:48 +01:00
bergamot-translator-tests@9209aa51e7 Faithful to source-structure translation (#115) 2021-05-06 16:19:27 +01:00
doc Marian submodule update (#74) 2021-04-01 16:29:02 +01:00
src Remove unused used types TokenRanges, SentenceTokenRanges, UPtr (#137) 2021-05-09 13:42:57 +01:00
wasm Updated CMakeLists.txt to remove packaging steps for wasm compilation 2021-05-12 16:23:09 +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 Updated CMakeLists.txt to remove packaging steps for wasm compilation 2021-05-12 16:23:09 +02: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 Updated README to remove packaging steps for wasm compilation 2021-05-12 16:23:09 +02: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

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

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

Build WASM

Prerequisite

Building on wasm requires Emscripten toolchain. It can be downloaded and installed 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

Compile

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

    mkdir build-wasm
    cd build-wasm
    emcmake cmake -DCOMPILE_WASM=on ../
    emmake make -j3
    

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

  2. 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 Compile steps.
If you update a submodule, execute following command in repository root folder before executing Compile steps.

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.