Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Tensorflow API to use for Seq2Seq

Tags:

tensorflow

This year Google produced 5 different packages for seq2seq:

  • seq2seq (claimed to be general purpose but inactive)
  • nmt (active but supposed to be just about NMT probably)
  • legacy_seq2seq (clearly legacy)
  • contrib/seq2seq (not complete probably)
  • tensor2tensor (similar purpose, also active development)

Which package is actually worth to use for the implementation? It seems they are all different approaches but none of them stable enough.

like image 327
Nikolay Shmyrev Avatar asked Nov 03 '17 16:11

Nikolay Shmyrev


1 Answers

I've had too a headache about some issue, which framework to choose? I want to implement OCR using Encoder-Decoder with attention. I've been trying to implement it using legacy_seq2seq (it was main library that time), but it was hard to understand all that process, for sure it should not be used any more.

  • https://github.com/google/seq2seq: for me it looks like trying to making a command line training script with not writing own code. If you want to learn Translation model, this should work but in other case it may not (like for my OCR), because there is not enough of documentation and too little number of users

  • https://github.com/tensorflow/tensor2tensor: this is very similar to above implementation but it is maintained and you can add more of own code for ex. reading own dataset. The basic usage is again Translation. But it also enable such task like Image Caption, which is nice. So if you want to try ready to use library and your problem is txt->txt or image->txt then you could try this. It should also work for OCR. I'm just not sure it there is enough documentation for each case (like using CNN at feature extractor)

  • https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/seq2seq: apart from above, this is just pure library, which can be useful when you want to create a seq2seq by yourself using TF. It have a function to add Attention, Sequence Loss etc. In my case I chose that option as then I have much more freedom of choosing the each step of framework. I can choose CNN architecture, RNN cell type, Bi or Uni RNN, type of decoder etc. But then you will need to spend some time to get familiar with all the idea behind it.

  • https://github.com/tensorflow/nmt : another translation framework, based on tf.contrib.seq2seq library

From my perspective you have two option:

  1. If you want to check the idea very fast and be sure that you are using very efficient code, use tensor2tensor library. It should help you to get early results or even very good final model.
  2. If you want to make a research, not being sure how exactly the pipeline should look like or want to learn about idea of seq2seq, use library from tf.contrib.seq2seq.
like image 126
melgor89 Avatar answered Sep 28 '22 06:09

melgor89