This repository serves as a minimal example of a CMake project with a marian dependency. The dependency to Marian is facilitated by a submodule to marian-dev.
Acquiring a copy of this repository can be done with the "Use this template" button, which generates a new repository with the same structure and content.
Alternatively, you can clone it locally via
git clone https://github.com/marian-nmt/marian-example-library
cd marian-example-library
mkdir build
cd build
cmake ..
cmake --build .
./example
The code in src/main.cpp builds a simple expression graph using Marian. It mirrors the example found in Marian's developer documentation.
The expression graph represents z = x*y + sin(x)
, with an absolute-error applied to z
as a loss function. It performs a forward and backward evaluation of the graph, and a single update of the graph parameters from a Stochastic Gradient Descent
optimizer. Following the example, x
takes the place of a learnable parameter.
After the parameter update, the graph parameters are saved to example-model.npz
. You can inspect its contents with script/read-npz.py
.
Please refer to the marian project for further documentation.
There are example CI builds available for
- Ubuntu
- MacOS
- Windows
These compile and run the example executable.
Additionally, the Marian submodule is updatable via dependabot.
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), 825303 (Bergamot; 2019-2021), the European Union's Connecting Europe Facility project 2019-EU-IA-0045 (User-focused Marian; 2020-2022), 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.