# 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 '20 at 13:22

## 1 Answer

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}$$.

Recall that supervised learning can also be thought of as learning with a teacher. Hence the expression "teacher forcing", i.e. you force the predictions to be based on correct histories (the teacher's labels).

Of course, intuitively, teacher forcing should help to stabilize training, given that the predictions are not based on noisy or wrong histories.

See also the blog post What is Teacher Forcing for Recurrent Neural Networks? by Jason Brownlee.