You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for Machine Translation model (microsoft#1482)
This pull request introduces the Marian example for machine translation,
adds support for encoder-specific configurations, and enhances the
handling of decoder inputs. Key changes include updates to the build
system, new Marian examples in both C++ and Python, and modifications to
the configuration and input handling for encoder-decoder models.
### Marian Example Addition:
*
[`examples/c/CMakeLists.txt`](diffhunk://#diff-53132a16068a4beab79c0d0b3165704244a0ea790e4975b42c0e8573427a65baR13):
Added the Marian example to the build options and defined its
executable.
[[1]](diffhunk://#diff-53132a16068a4beab79c0d0b3165704244a0ea790e4975b42c0e8573427a65baR13)
[[2]](diffhunk://#diff-53132a16068a4beab79c0d0b3165704244a0ea790e4975b42c0e8573427a65baR88-R92)
*
[`examples/c/src/marian.cpp`](diffhunk://#diff-bb987f6b4967383e87bf6e42bbe081e3269c0ecce61314deff2e6a06d5be59beR1-R115):
Introduced a new C++ implementation for the Marian example, showcasing
token generation using the ONNX runtime.
*
[`examples/python/marian.py`](diffhunk://#diff-bdd0d4e08a0fe5b1b45141a29a780776e2cb352a9653099184892853be384ccfR1-R93):
Added a Python implementation of the Marian example, supporting
interactive and non-interactive modes for token generation.
### Configuration Enhancements:
* `src/config.h` and `src/config.cpp`: Replaced `EncoderDecoderInit`
with a more detailed `Encoder` structure, adding fields for
encoder-specific configurations such as `hidden_size`,
`num_attention_heads`, and input/output names. Updated JSON parsing to
handle these new fields.
[[1]](diffhunk://#diff-c24f78b3519d763901eb9f67b864f01d802d803df1b24faaf154019cf812bf95R46-R53)
[[2]](diffhunk://#diff-c24f78b3519d763901eb9f67b864f01d802d803df1b24faaf154019cf812bf95L93-R121)
[[3]](diffhunk://#diff-c24f78b3519d763901eb9f67b864f01d802d803df1b24faaf154019cf812bf95R199-R203)
[[4]](diffhunk://#diff-c24f78b3519d763901eb9f67b864f01d802d803df1b24faaf154019cf812bf95R212)
[[5]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385L166-R194)
[[6]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385R225-R232)
[[7]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385R257-R258)
[[8]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385R379-R418)
[[9]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385L616-R684)
[[10]](diffhunk://#diff-6b2f0a449fdefd8930e23ef0dcd752beec69242e1303d77653f047c5e0766385L636-R703)
### Decoder Input Handling:
* `src/models/input_ids.cpp` and `src/models/input_ids.h`: Introduced
`DecoderInputIDs` and `DecoderInputs` to handle decoder-specific input
IDs, including methods for adding and updating decoder inputs.
[[1]](diffhunk://#diff-68f9fc6a35c9a61872d9a22f44c0c311a8670fa6e26eb081077924d088d72decR36-R45)
[[2]](diffhunk://#diff-68f9fc6a35c9a61872d9a22f44c0c311a8670fa6e26eb081077924d088d72decR60-R69)
[[3]](diffhunk://#diff-68f9fc6a35c9a61872d9a22f44c0c311a8670fa6e26eb081077924d088d72decR126-R146)
[[4]](diffhunk://#diff-9a2a38a53d0254d94c54591e1fd05c321b3ce5c3d38bb23123427dc3ffdf96c8R12-R18)
### Model updates:
* Added marian model changes which includes encoder and decoder specific
configurations
* Updated logits logic to reuse most of the code for RNN and
transformer-based models (Tested both encoder-decoder and decoder only
models)
0 commit comments