Answers.Body: <p>In your case you can use either RNN (especially BiLSTM with ELMo and attention mechanism for better accuracy) or Transformer based architectures (the best of them today is BERT). But for both cases you need data to train the model (i.e sequences of input/output like in your question).</p>
  
  <p>I believe the best choice in your case is BERT as it's achieving state of the art performance in most NLP tasks and is already pretrained so you don't need a massive data to retrain the model. Also, BERT is pretrained on "Next Sentence Prediction" and allows "2 separate sentences" as input which helps a lot in your case. The only drawback, compared to other methods, is that you need fine-tuning the model so it's not a completly "ready to use" model. </p>
  
  <p><em>For more information:</em></p>
  
  <p>Here is the github repository of BERT: <a href="https://github.com/google-research/bert" rel="nofollow noreferrer">BERT-repo</a>. For quick explanation check: <a href="http://jalammar.github.io/illustrated-bert/" rel="nofollow noreferrer">The Illustrated BERT</a>. For detailed explanation see BERT paper: <a href="https://arxiv.org/pdf/1810.04805.pdf" rel="nofollow noreferrer">BERT-paper</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-10T12:18:15.757Z
Answers.LastActivityDate: 2019-04-10T14:02:29.650Z
Answers.LastEditDate: 2019-04-10T14:02:29.650Z
Answers.UserDisplayName: HLeb
Answers.Body: <p>sounds like a job for Sequence-to-sequence or seq2seq</p>
  
  <p>for example <a href="https://google.github.io/seq2seq/" rel="nofollow noreferrer">tf-seq2seq </a></p>
  
  <p>you basically use an RNN as an encoder (reduces and sequence of words to a vector), and another RNN as a decoder (takes the encoded vector as in input to generation a new sequence of words).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-12T05:28:59.370Z
Answers.LastActivityDate: 2019-04-12T05:28:59.370Z
Answers.UserDisplayName: j314erre
Body: <p>I am new to NLP realm. If you have an input text "The price of orange has increased" and output text "Increase the production of orange". Can we make our RNN model to predict the output text? Or what algorithm should I use?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-09T07:07:08.957Z
Comments.Text: 2 ways really, both involve converting the input to a 1-hot input. Either convert each character to a 1 hot input (eg, of size 27, 26 in the alphabet, 1 for spaces), or convert each word to a 1 hot vector of the RNN's vocabulary,
Comments.UserDisplayName: Recessive
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-06T07:28:46.533Z
Comments.Text: @Recessive Old comment, I know, but: No, those are not the only ways. Another method that is extremely common is to segment text into subwords. Also, you are implying that this tasks needs to be solved with an RNN - which is not the case.
Comments.UserDisplayName: Mathias Müller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-06T17:28:08.440Z
Comments.Text: @MathiasMüller I fail to see where I implied only an RNN could be used, I only responded to the question on how to input the text to an RNN. When you say segment the text into subwords, would those subwords not be encoded in a 1-hot vector? How do you propose inputting ascii characters into a network that deosn't involve 1-hot encoding?
Comments.UserDisplayName: Recessive
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-06T18:04:30.323Z
Comments.Text: @Recessive "I fail to see where I implied only an RNN could be used" - you are right, I'm sorry about this! "How do you propose inputting ascii characters into a network that deosn't involve 1-hot encoding?" - my view is as follows: all you have to do is map characters/words/subwords to vocabulary indexes. Then those indexes can be replaced with their word embeddings, without constructing one-hot vectors.
Comments.UserDisplayName: Mathias Müller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-07T03:00:33.053Z
Comments.Text: @MathiasMüller From what I understand, you're saying that the input and output should be an individual number representing the index in the vocabulary? In that case the network would have to use regression to learn, which in my experience has always performed poorly compared to an equivalent solution using classification
Comments.UserDisplayName: Recessive
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-07T06:47:54.437Z
Comments.Text: @Recessive I am saying that in most NLP tasks, RNNs are not reading text directly, but get to see _embeddings_ as inputs. For instance, the inputs to an RNN word-level language model are embeddings. The outputs are distributions over the vocabulary. See here for an example: https://github.com/pytorch/examples/tree/master/word_language_model.
Comments.UserDisplayName: Mathias Müller
Tags: <machine-learning><natural-language-processing><recurrent-neural-networks>
Title: Which algorithm should I use to map an input sentence to an output sentence?
UserDisplayName: ReInvent_IO
ThreadText: # Which algorithm should I use to map an input sentence to an output sentence?
  
  (Asked by: username_0 on 2019-04-05)
  
  I am new to NLP realm. If you have an input text "The price of orange has increased" and output text "Increase the production of orange". Can we make our RNN model to predict the output text? Or what algorithm should I use?
  
  **Tags:** machine-learning, natural-language-processing, recurrent-neural-networks
  > **Comments:**
  > **username_1**: 2 ways really, both involve converting the input to a 1-hot input. Either convert each character to a 1 hot input (eg, of size 27, 26 in the alphabet, 1 for spaces), or convert each word to a 1 hot vector of the RNN's vocabulary,  
  > **username_2**: @Recessive Old comment, I know, but: No, those are not the only ways. Another method that is extremely common is to segment text into subwords. Also, you are implying that this tasks needs to be solved with an RNN - which is not the case.  
  > **username_1**: @MathiasMüller I fail to see where I implied only an RNN could be used, I only responded to the question on how to input the text to an RNN. When you say segment the text into subwords, would those subwords not be encoded in a 1-hot vector? How do you propose inputting ascii characters into a network that deosn't involve 1-hot encoding?  
  > **username_2**: @Recessive "I fail to see where I implied only an RNN could be used" - you are right, I'm sorry about this! "How do you propose inputting ascii characters into a network that deosn't involve 1-hot encoding?" - my view is as follows: all you have to do is map characters/words/subwords to vocabulary indexes. Then those indexes can be replaced with their word embeddings, without constructing one-hot vectors.  
  > **username_1**: @MathiasMüller From what I understand, you're saying that the input and output should be an individual number representing the index in the vocabulary? In that case the network would have to use regression to learn, which in my experience has always performed poorly compared to an equivalent solution using classification  
  > **username_2**: @Recessive I am saying that in most NLP tasks, RNNs are not reading text directly, but get to see _embeddings_ as inputs. For instance, the inputs to an RNN word-level language model are embeddings. The outputs are distributions over the vocabulary. See here for an example: https://github.com/pytorch/examples/tree/master/word_language_model.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2019-04-10. Score: 1
  
  In your case you can use either RNN (especially BiLSTM with ELMo and attention mechanism for better accuracy) or Transformer based architectures (the best of them today is BERT). But for both cases you need data to train the model (i.e sequences of input/output like in your question).
  
  I believe the best choice in your case is BERT as it's achieving state of the art performance in most NLP tasks and is already pretrained so you don't need a massive data to retrain the model. Also, BERT is pretrained on "Next Sentence Prediction" and allows "2 separate sentences" as input which helps a lot in your case. The only drawback, compared to other methods, is that you need fine-tuning the model so it's not a completly "ready to use" model.
  
  *For more information:*
  
  Here is the github repository of BERT: [BERT-repo](https://github.com/google-research/bert). For quick explanation check: [The Illustrated BERT](http://jalammar.github.io/illustrated-bert/). For detailed explanation see BERT paper: [BERT-paper](https://arxiv.org/pdf/1810.04805.pdf).
  
  
  ---
  
  ### Answer by username_4 on 2019-04-12. Score: 0
  
  sounds like a job for Sequence-to-sequence or seq2seq
  
  for example [tf-seq2seq](https://google.github.io/seq2seq/)
  
  you basically use an RNN as an encoder (reduces and sequence of words to a vector), and another RNN as a decoder (takes the encoded vector as in input to generation a new sequence of words).
  
  
  ---
  
  