marian icon indicating copy to clipboard operation
marian copied to clipboard

Provide Python 3 bindings

Open filips123 opened this issue 5 years ago • 14 comments

Can you provide Python 3 bindings?

From existing issues, I see that they were existing previously, but there isn't any documentation for them. So, if they were removed, please add them back. If they are still present, but without documentation, please provide better documentation.

filips123 avatar Dec 07 '19 12:12 filips123

Which issues are you referring to? Amun, which used to be a part of Marian, has Python bindings. I don't think there are any plans for Python bindings for Marian.

snukky avatar Dec 07 '19 12:12 snukky

Issues that GitHub provides as similar when creating issue. I think that you can see them if you search for "python" or "bindings".

What is the difference between Marian and Amin and why they are now separated?

Is it then possible to use training and translation from Python?

filips123 avatar Dec 07 '19 13:12 filips123

I see, old issues mentioning Python relate to Amun. Amun is a decoder for specific RNN-based NMT models, so it can be used for translation from Python, but models need to be trained with Marian using a command-line tool.

snukky avatar Dec 07 '19 16:12 snukky

Ah, ok.

What is then the difference between Amun and Marian and why they are now separated? Is Amun just a library that uses models and Marian is for creating/training them?

So Python library can use Amun for translation? Are there any more details or documentation how to do this?

filips123 avatar Dec 07 '19 16:12 filips123

Amun was just a translation tool (README) and it was created first. Marian is now a more mature toolkit for training and translation with its own decoder, supporting more NMT architectures. Amun as a project is inactive. As for bindings, I found only a demo script: amun.py.

snukky avatar Dec 07 '19 17:12 snukky

Thank you for more details.

Are there any plans to resume Amun development or add bindings for Marian? As Marian provides quite many features, bindings for other languages would be very useful.

And regarding that demo script, are there any details how to build libamunmt with Python support? Can you create PyPI package that would build it and make it usable as normal Python package?

Also, from docs, I can see that Marian provides WebSocket server. Is this how it is expected to use it from Python?

filips123 avatar Dec 07 '19 17:12 filips123

AFAIK, currently there is no plans to add python bindings to Marian. Yes, Marian can be used from python via marian-server (client_example.py) or by wrapping a shell command. Amun bindings weren't providing much more functionalities.

snukky avatar Dec 09 '19 11:12 snukky

Are you looking for high-level bindings e.g. to load a model and use it for translation, or low-level bindings that allow you to define your models on operator level in Python?

frankseide avatar Dec 09 '19 15:12 frankseide

Mostly high-level bindings. Some low-level would still be nice but aren't so important for me.

Actually, as there is already marian-server, binding aren't needed so much.

filips123 avatar Dec 09 '19 15:12 filips123

I am also extending marian-server right now to understand JSON queries and send back JSON n-best lists etc. This should become a lot more useful soon.

emjotde avatar Dec 09 '19 21:12 emjotde

Does marian-server only support WebScokets or also classic HTTP queries?

filips123 avatar Dec 09 '19 21:12 filips123

WebSocket for now. It's more of a demo than anything else. I think @ugermann is working on a full-blown server implementation?

emjotde avatar Dec 09 '19 21:12 emjotde

I am also extending marian-server right now to understand JSON queries and send back JSON n-best lists etc. This should become a lot more useful soon.

Please coordinate this with me to avoid duplicate work. My current working version of Marian-as-a-service (currently branch ug-marian-aas3 in the marian-dev repo; this may change) currently implements an http server (via crow) that can handle json requests (via rapidjson). There will be some changes to the API (for purposes of integration with the European Language Grid (https://www.european-language-grid.eu/) and the REST server back-end library (switching from http (via crow) to http2 (via libnghttp2)).

ugermann avatar Dec 14 '19 02:12 ugermann

@ugermann I am happy to just use yours. I will have a look soon. Mine was very early and very experimental. How is the server going, is there an ETA?

emjotde avatar Dec 15 '19 22:12 emjotde