In the Sequence-to-Sequence models, we often see that the START (e.g. <s>
) and END (e.g. </s>
) symbols are added to the inputs and outputs before training the model and before inference/decoding unseen data.
E.g. http://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html
SOS_token = 0
EOS_token = 1
class Lang:
def __init__(self, name):
self.name = name
self.word2index = {}
self.word2count = {}
self.index2word = {0: "SOS", 1: "EOS"}
self.n_words = 2 # Count SOS and EOS
def addSentence(self, sentence):
for word in sentence.split(' '):
self.addWord(word)
def addWord(self, word):
if word not in self.word2index:
self.word2index[word] = self.n_words
self.word2count[word] = 1
self.index2word[self.n_words] = word
self.n_words += 1
else:
self.word2count[word] += 1
Is there a technical definition or academic explanation of why that is necessary?
Or does that need to add the END symbol only applies to Natural Language Processing task where the sentence generation needs to end?
But what does the START symbol do? Other than to take the initial state where the trained network will start inferrring.