liveBook · Manning

Guided attention

As explained in Machine Learning System Design

Guided attention is a training technique that adds a penalty encouraging an attention matrix to follow a desired alignment pattern.

Guided attention adds an auxiliary loss that penalizes attention matrices deviating from an expected alignment pattern. In text-to-speech, it encodes the assumption that text positions align closely with audio over time. section 9.2.2

Use the technique as a practical training and diagnosis loop:

  • Plot attention activations between audio frames and characters, then check whether the pattern approaches a diagonal. section 9.2.2
  • Penalize substantial deviations from the diagonal to accelerate training and steer the model toward meaningful alignments. section 9.2.2
  • Interpret moderate deviations as timing variation and large residuals as sounds or character combinations the model struggles to learn. section 9.2.2

Text-to-speech alignment

Compare attention plots during training with and without guided-attention loss. The guided version should move more directly toward a near-diagonal alignment, exposing remaining difficult sounds for later data collection. section 9.2.2

Figure 9.12 Attention plot evolution through training without (left) and with (right) guided attention loss
figure

Compare attention-plot evolution without and with guided-attention loss. section 9.2.2

How Machine Learning System Design covers it

How deep it goes
Explains the auxiliary penalty, diagonal diagnostic, and residual interpretation, while deferring attention-module architecture details.
Examples
Uses audio-frame-versus-character attention plots, diagonal alignment, training comparisons, and difficult-sound diagnosis.
What it assumes
Starts from the assumption that text position aligns closely with the audio being spoken.
What you can do after
Diagnose alignment failures with attention plots and guide training toward meaningful text-to-speech solutions.
How it connects
Connects attention modules, sequence-to-sequence tasks, text-to-speech, auxiliary loss, and residual analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.