What to use for the target input in the decoder for autoregressive usage
I want to use a transformer (encoder and decoder) and use it for the seq 2 seq modeling.I like to use it as autoregressive model during the inference time.I know that I should use the targets to the decoder during the training, but then the issue is that when I do it my model overfits and performed well only if I have good targets as the input of the decoder.I was wondering if there is a trick or rule on how should I select the target for the decoder?my second question is if the target inputs to the decoder should be exactly similar to the target outputs of the decoder or it is kinda an art to choose the right target input for the decoder?
2021-09-16T08:39:25Z
Encoder-decoder (seq2seq2) models like T5, BART and PEGASUS are trained using what is called “teacher forcing”, this just means supervised learning, i.e. the model needs to produce the target sentence given the source text.Normally, if your dataset is diverse enough, it will also perform well at inference time, when usingmodel.generate(). Using decoding techniques such as beam search and top-k sampling, you can get good results, even on unseen inputs.
2021-09-16T11:09:40Z
I feel the need to clarify this. Teacher forcing is something very specific in such models, not simply the task of “producing the target sentence givensourcetext”. I think that what you mean is correct, but it is written a bit ambiguously.In teacher forcing in an autoregressive decoder you give the decoder the correct previousoutputtokens. So for instance, in machine translation during decoding, you would “guide” it by giving it the correct previous token for the prediction of each next token.I am not sure about the models that you list, but in MT implementations it is common to randomly apply teacher forcing for different batches to ensure that the model generalizes better and is less prone to exposure bias.
2021-09-16T11:22:37Z
@BramVanroyoh thanks, I actually did not know this. So usually, one applies teacher forcing on all training examples when fine-tuning models like T5 and BART, right?
2021-09-16T11:54:29Z
Sorry, I am not sure about those specific models and I do not have the time to go into it in detail. I can find that the fairseq datasets for MT by default include a shifted version of the golden targets for teacher forcing.github.compytorch/fairseq/blob/1bba712622b8ae4efb3eb793a8a40da386fe11d0/fairseq/data/language_pair_dataset.py#L182-L183input_feeding (bool, optional): create a shifted version of the targetsto be passed into the model for teacher forcing (default: True).I am not sure about the implementation/training/finetuning of all these models.But, considering that one of the advantages of teacher forcing is faster convergence, fine-tuning (on limited data) with teacher forcing seems a good idea.
2021-09-16T15:30:12Z
thank you for the information. I will look into the teaching forcing methods then to get more information on that