# What is teacher forcing?

In the paper Neural Programmer-Interpreters, the authors use the teacher forcing technique, but what exactly is it?

• I've asked and answered this question after having seen this comment, where the user doesn't know what teacher forcing is. – nbro Feb 13 at 13:22

Consider the task of sequence prediction, so you want to predict the next element of a sequence $$e_t$$ given the previous elements of this sequence $$e_{t-1}, e_{t-2}, \dots, e_{1} = e_{t-1:1}$$. Teacher forcing is about forcing the predictions to be based on correct histories (i.e. the correct sequence of past elements) rather than predicted history (which may not be correct). To be more concrete, let $$\hat{e}_{i}$$ denote the $$i$$th predicted element of the sequence and let $$e_{i}$$ be the corresponding ground-truth. Then, if you use teacher forcing, to predict $$e_{t}$$, rather than using $$\hat{e}_{t-1:1}$$, you would use $$e_{t-1:1}$$.