Re:Writing Python inside Rust
by djohnston on Friday April 17, 2020 @10:01PM
(#22904732)
Maybe interfacing w an ml lib like pytorch or something?
[ Parent
| on HN ]
I suppose you could, but I believe that there are direct bindings from Rust to Pytorch at https://github.com/LaurentMazare/tch-rs. I haven't used it personally, but I've heard fairly good things about it's correctness and responsive maintainer.
I have written a transformer-based (BERT, XLM-RoBERTa) sequence labeler/lemmatizer/dependency parser in Rust with tch-rs [1] and it is great! Some parts do not feel rusty. E.g. dynamic typing of tensors, you get a Tensor rather than Tensor<f32>, but that's more due to how libtorch itself works. But it's a very straightforward API that exposes most of libtorch. The maintainer is also very nice and responsive.
I was also amazed how much is implemented in libtorch itself as opposed to the Python wrapper, which makes much of the Torch functionality available to other languages.
[1] https://github.com/stickeritis/sticker2 https://github.com/stickeritis/sticker-transformers
Re:Writing Python inside Rust
by random32840 on Saturday April 18, 2020 @05:19AM
(#22906395)
Someone might have jumped that hurdle but the point is it circumvents that class of hurdle. What about the next framework which doesn't have bindings? What about leveraging existing Pytorch code that's written in Python?
Re:Writing Python inside Rust
by RcouF1uZ4gsC on Friday April 17, 2020 @10:19PM
(#22904817)
For pytorch it would probably be easier to do something based off the pytorch C++ interface.