Introduction to Bergamot Translator
Bergamot Translator is a groundbreaking project designed to enhance client-side machine translation capabilities within web browsers. By utilizing the robust Marian NMT framework, Bergamot Translator aims to provide efficient and seamless translation services. The project is an integral part of the broader Bergamot initiative, which is committed to advancing the field of machine translation directly on users' devices without the need for server-based operations.
Key Features
Bergamot Translator offers a unified API that leverages the Marian NMT framework, known for its advanced neural machine translation capabilities. This approach ensures that translations are not only accurate but also performed quickly and efficiently within a user's browser.
Building Bergamot Translator
Native Build
For those interested in building the Bergamot Translator natively, the process is straightforward. Developers can create a dedicated directory for the build artifacts, typically named build-native
, and use standard CMake and Make commands to compile the project:
mkdir build-native
cd build-native
cmake ../
make -j2
Building for WebAssembly (WASM)
WebAssembly is a key component of the Bergamot Translator, enabling translation operations to run efficiently within web environments like Firefox Nightly. Building for WASM requires the Emscripten toolchain, which can be set up with the following steps:
- Clone the Emscripten SDK:
git clone https://github.com/emscripten-core/emsdk.git cd emsdk
- Install and activate the SDK:
./emsdk install 3.1.8 ./emsdk activate 3.1.8 source ./emsdk_env.sh
Once the environment is set up, developers can compile the WASM version:
mkdir build-wasm
cd build-wasm
emcmake cmake -DCOMPILE_WASM=on ../
emmake make -j2
After building, it is essential to patch the generated artifacts to import the GEMM library from a separate WASM module using a provided script:
bash ../wasm/patch-artifacts-import-gemm-module.sh
Usage
Native Version
The native build of Bergamot Translator generates a library that can be seamlessly integrated into other projects. All necessary public header files are located in the src
folder, and an example of API utilization can be found in app/bergamot.cpp
.
WASM Version
For using Bergamot Translator in JavaScript, the user should refer to the README
document located within the wasm
folder of the project repository. This guide walks through the steps necessary to implement and utilize the translator in web development projects.
Bergamot Translator stands out as a significant advancement in the realm of web-based machine translation, paving the way for faster, more accurate translations directly within users' browsers. Its ease of integration and platform flexibility make it an appealing choice for developers looking to incorporate cutting-edge translation services into their applications.