Teacher forcing
Teacher forcing is a sequence-model training technique that supplies the ground-truth preceding output as input when predicting the next output.
Build AI Drug Discovery Pipelines
Teacher forcing is a sequence-model training method that supplies ground-truth previous tokens as decoder inputs instead of the model's own predictions.
- How it is used
- Stabilizes training while learning to reconstruct molecular SMILES sequences.
- How deep it goes
- Explains shifted input-target pairs and shows how decoder inputs pass through embeddings and a GRU.
- Examples
- Uses tokenized molecular SMILES strings and a variational autoencoder decoder to illustrate training.
- What you can do after
- Apply it in PyTorch by shifting token sequences and supplying correct decoder inputs.
Read how Build AI Drug Discovery Pipelines explains teacher forcing →
Inside Deep Learning: Math, Algorithms, Models
A training approach for sequence decoders that feeds the true previous token as the next input instead of the model's own prediction.
- How it is used
- Trains Seq2Seq decoders by supplying the correct previous token during decoding.
- How deep it goes
- Explains the input swap, its training benefit, and the training-versus-evaluation control flow in code.
- Examples
- Uses a decoder-step figure and a forward-pass code path that selects the next decoder input.
- What you can do after
- Apply it to train sequence decoders that learn faster while still supporting autoregressive prediction later.
Read how Inside Deep Learning: Math, Algorithms, Models explains teacher forcing →
Graph Neural Networks in Action
Teacher forcing is a sequential-model training technique that supplies the ground-truth previous output as input when predicting the next step.
- How it is used
- Trains sequential graph decoders while controlling whether each step receives ground-truth data or its preceding prediction.
- How deep it goes
- Explains the input-switching behavior and shows its decoder implementation, but does not discuss scheduling strategies or quantitative trade-offs.
- Examples
- Demonstrates teacher forcing with pose-graph frames and contrasts training-time ground-truth inputs with multi-step prediction using teacher_forcing=False.
- What you can do after
- Apply it via a PyTorch decoder’s teacher_forcing flag to train with real frames and forecast future graphs autoregressively.
Read how Graph Neural Networks in Action explains teacher forcing →
Also covered in
- Time Series Forecasting Using Foundation Models
- Build a DeepSeek Model (From Scratch)In early access (MEAP)
What to know first
- stateState is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- recurrent neural networkA recurrent neural network is a neural network that processes ordered inputs while carrying and updating an internal state across successive steps.
Related concepts
- exposure biasproduces · Exposure bias is the discrepancy between training with ground-truth sequence inputs and generation with the model's own predictions.
- multi-token predictionused by · Multi-token prediction is a language-model training or inference technique that predicts multiple future tokens rather than only the next token.
- T5used by · T5 is a family of encoder-decoder Transformer models that frames natural-language tasks as transformations from input text to output text.
- labeluses · A label is a target value, category, or reference annotation associated with an example for learning, prediction, or evaluation.
- recurrent neural networkuses · A recurrent neural network is a neural network that processes ordered inputs while carrying and updating an internal state across successive steps.
- tokenuses · A token is a discrete unit of text, such as a word, subword, punctuation mark, or symbol, produced by tokenization and processed by a language model.
Questions about teacher forcing
What is teacher forcing?
Teacher forcing is a sequence-model training technique that supplies the ground-truth preceding output as input when predicting the next output.
Which Manning books explain teacher forcing?
Build AI Drug Discovery Pipelines, Inside Deep Learning: Math, Algorithms, Models and Graph Neural Networks in Action.
What should I know before learning teacher forcing?
Manning books that teach teacher forcing usually introduce state and recurrent neural network first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


