OpenNMT-py
OpenNMT-py copied to clipboard
Retrieve NMT Encoder's output
Hi,
Assuming that I've trained a NMT with OpenNMT, how coud I retrieve the representation vector of new sequences ?
More precisely, If I trained a NMT to translate from French to English, if I want to predict the output sequence for a new French sentence, how could I also retrieve the output vector of the encoder ?
Thank you !
Hi there, This is quite similar to this post. It is not handled "as is" but it should not be too difficult to add it if you're willing to dive a bit in the code.
Thank you for your answer, I'll post here If I manage to do it !
hi, do you manage to do it? @brash6
Hello, not really, If you have any idea how to do it, I am interested !
Hi,
Did anybody had any success in getting the encoder representation from the trained model?
This should not be very difficult guys, if you're willing to dive a bit in the code. You can start by printing / torch.save what's happening here, after the encoder forward: https://github.com/OpenNMT/OpenNMT-py/blob/8b073fb2a047509ff590839b1194a155ec1a50bf/onmt/models/model.py#L45
Then, it's just plumbing to retrieve this at the translator level.
Thanks for your reply.
I have mainly used it's command line tool only. Have not used the torch api. Any reference to building a transformer translation model with its pytorch api?
Pardon if I am missing anything obvious here.
On Thu, Oct 8, 2020, 1:59 PM François Hernandez [email protected] wrote:
This should not be very difficult guys, if you're willing to dive a bit in the code. You can start by printing / torch.save what's happening here, after the encoder forward:
https://github.com/OpenNMT/OpenNMT-py/blob/8b073fb2a047509ff590839b1194a155ec1a50bf/onmt/models/model.py#L45
Then, it's just plumbing to retrieve this at the translator level.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OpenNMT/OpenNMT-py/issues/1811#issuecomment-705416630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5VTOB6KRTPNAMYAH5MCNLSJVZ7TANCNFSM4NZGBKTQ .
You don't need to rebuild everything just to retrieve some representations. You can just edit the code and run the scripts.
Thank you for your prompt response.
I have one more doubt. Please pardon me if my doubts appear naive.
The installed scripts will invoke the code from the installed location, right?
How do I ensure that the scripts call the changes I make in the onmt codebases' model?
Easiest is probably to git clone
the repo in the location you'd like and work from there.
Hi @francoishernandez! Is anyone working on this issue? I want to contribute.