Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
Go to file
2024-05-12 09:51:02 +01:00
.circleci Remove wormhole references (#459) 2023-08-14 15:22:54 +01:00
.github Fix MKL key URL 2023-12-07 12:10:50 -05:00
3rd_party Update submodule 2024-05-12 09:51:02 +01:00
app Streamline memory-bundle loads (#307) 2022-01-19 16:36:48 +00:00
bergamot-translator-tests@a04432d792 Bump bergamot-translator-tests from 7984d14 to a04432d (#455) 2023-07-31 15:54:53 +01:00
bindings fix downloading of models in the python binding (#472) 2024-04-19 23:17:45 +01:00
cmake CMake fixes: Generate project.h in binary dir, fix GetVersionFromFile for use as submodule. (#193) 2021-06-09 10:12:00 +01:00
doc Docs: Pin Jinja2 to last known working version (#389) 2022-03-24 19:26:20 +00:00
examples model url update in example script (#470) 2024-03-23 20:21:46 +00:00
patches Batteries included python package (#310) 2022-01-26 20:33:43 +00:00
src Enables model ensembles (#450) 2023-08-01 19:35:11 +01:00
wasm Remove wormhole references (#459) 2023-08-14 15:22:54 +01:00
.clang-format Adding clang-format and updating existing sources to adhere (#151) 2021-05-19 21:50:21 +01:00
.clang-format-ignore Adding clang-format and updating existing sources to adhere (#151) 2021-05-19 21:50:21 +01:00
.clang-tidy Add a clang-tidy run (#214) 2021-08-13 16:26:44 +01:00
.gitignore Add more things to the gitignore that are not being ignored (#462) 2023-08-16 15:35:26 +01:00
.gitmodules Batteries included python package (#310) 2022-01-26 20:33:43 +00:00
BERGAMOT_VERSION Bump version to 0.4.5 (#427) 2022-06-21 17:49:07 +01:00
build-wasm.sh Report the wasm size on builds (#460) 2023-08-17 07:55:49 +01:00
CMakeLists.txt Generate a compile_commands.json by default with cmake (#461) 2023-08-16 16:14:56 +01:00
Doxyfile.in QualityEstimation: Preliminary Implementation (#197) 2021-09-16 16:28:40 +01:00
LICENSE Initial commit 2020-10-19 13:49:38 +02:00
MANIFEST.in Batteries included python package (#310) 2022-01-26 20:33:43 +00:00
README.md Remove wormhole references (#459) 2023-08-14 15:22:54 +01:00
run-clang-format.py Adding clang-format and updating existing sources to adhere (#151) 2021-05-19 21:50:21 +01:00
setup.py Fix Python formatting (Black) (#453) 2023-07-31 15:27:24 +01:00

Bergamot Translator

CircleCI badge

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 -j2

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 sdk: ./emsdk install 3.1.8
  • Activate the sdk: ./emsdk activate 3.1.8
  • Activate path variables: source ./emsdk_env.sh

Compile

To build a version that translates with higher speeds on Firefox Nightly browser, follow these instructions:

  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 -j2
    

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

  2. Patch generated artifacts to import GEMM library from a separate wasm module

    bash ../wasm/patch-artifacts-import-gemm-module.sh
    

To build a version that runs on all browsers (including Firefox Nightly) but translates slowly, follow these instructions:

  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 -j2
    
  2. Patch generated artifacts to import GEMM library from a separate wasm module

    bash ../wasm/patch-artifacts-import-gemm-module.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/bergamot.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.