---
title: Dual Orthogonal Guidance in HTG
url: https://www.emergentmind.com/topics/dual-orthogonal-guidance-dog
type: topic
---

# Dual Orthogonal Guidance in HTG

Dual Orthogonal Guidance (DOG) is a sampling guidance strategy for diffusion-based handwritten text generation (HTG) that replaces the unconditional branch of standard Classifier-Free Guidance (CFG) with an orthogonalized negative-prompt direction. In the formulation introduced for HTG, DOG constructs a negatively perturbed version of the content and style condition, predicts its noise, removes the component parallel to the positive prediction, and then injects the resulting direction through a time-dependent triangular schedule during denoising. The method is presented as a plug-and-play, test-time scheme requiring no retraining, and is reported to improve content clarity, reduce artifacts, and increase style variability on DiffusionPen and One-DM, including for out-of-vocabulary words and challenging or unseen handwriting styles [2508.17017].

## 1. Problem formulation in diffusion-based handwritten text generation

DOG is motivated by failure modes observed in diffusion HTG systems. Diffusion-based HTG approaches are described as achieving strong results on frequent, in-vocabulary words observed at training time and on regular styles, while remaining prone to memorizing training samples and struggling with style variability and generation clarity. Standard diffusion models are further described as tending to produce artifacts or distortions that harm readability, especially when the target style is difficult to produce [2508.17017].

Within this setting, the conditioning signal is split into desired content and style embeddings, written as $c = (c_t, c_s)$. DOG is designed for the denoising phase rather than the training objective: it modifies sampling so that generation is steered away from artifact-inducing directions while preserving intended textual content. The paper’s summary characterizes the method through three coupled elements: a structured negative prompt, orthogonalization against the clean prediction, and a triangular guidance schedule. A common misunderstanding is to treat DOG as merely a variant of negative prompting; the formulation instead depends on the interaction of all three components, with ablations indicating that removing orthogonal projection or scheduling degrades generation quality [2508.17017].

## 2. Mathematical construction of the DOG direction

Let $x_t$ denote the current noisy latent at diffusion timestep $t$, and let the model’s noise predictor under the true prompt be

$$
\epsilon_p = \epsilon_\theta(x_t, t, c_t, c_s).
$$

DOG then forms a negative prompt by stochastically corrupting both content and style embeddings:

$$
\tilde c_t = c_t \odot m_t + \lambda_t \cdot n_t,\qquad m_t \sim \mathrm{Bernoulli}(p),\quad n_t \sim \mathcal{N}(0, I),
$$

$$
\tilde c_s = c_s \odot m_s + \lambda_s \cdot n_s,\qquad m_s \sim \mathrm{Bernoulli}(p),\quad n_s \sim \mathcal{N}(0, I),
$$

and evaluates the corresponding prediction

$$
\epsilon_n = \epsilon_\theta(x_t, t, \tilde c_t, \tilde c_s).
$$

Before projection, the norm of $\epsilon_n$ is clipped to a threshold $\tau$. DOG then isolates only the orthogonal component of $\epsilon_n$ with respect to $\epsilon_p$:

$$
\mathrm{proj}_{\epsilon_p}(\epsilon_n) = \frac{\langle \epsilon_n, \epsilon_p \rangle}{\|\epsilon_p\|^2} \cdot \epsilon_p,
$$

$$
\epsilon^\* = \epsilon_n - \mathrm{proj}_{\epsilon_p}(\epsilon_n).
$$

The paper also gives an equivalent expression in terms of $p^+ = \epsilon_p$ and $p^- = \epsilon_n$:

$$
\Delta_{\mathrm{north}} = (p^- - p^+) - \frac{(p^- - p^+)^T p^+}{\|p^+\|^2} p^+.
$$

The final guided noise prediction is

$$
\hat \epsilon_t = \epsilon_p + g(t)\cdot(\epsilon_p - \epsilon^\*).
$$

This construction is explicitly positioned as a disentangled latent-space direction: the parallel component of the negative prediction is removed, so the guidance acts only through the orthogonal remainder. In the comparison given in the paper, this is framed as content-preserving because “we never push parallel to $\epsilon_p$” [2508.17017].

## 3. Triangular scheduling across the denoising trajectory

DOG does not apply a constant guidance scale at every timestep. Instead, it uses a triangular schedule that is weak at early and late steps and peaks in the middle of denoising. If $T$ is the total number of denoising steps and $u_T \in [1,T]$ is a designated peak timestep, then

$$
\gamma(t) =
\begin{cases}
t / u_T, & 1 \le t \le u_T,\\
1 - (t - u_T)/(T - u_T), & u_T < t \le T,
\end{cases}
$$

and

$$
g(t) = gs \cdot \gamma(t),
$$

where $gs$ is the base guidance scale.

The stated intuition is threefold. For $t \ll u_T$, guidance remains minimal while the sample is still mostly noise. For $t \approx u_T$, guidance is strongest when coarse structure forms. For $t \gg u_T$, guidance tapers off so that fine refinement can proceed without over-conditioning. The paper’s ablations report that removing scheduling causes images to become noisy at high guidance scales, and that a peak near mid-denoising, specifically $u_T \approx 700$, gives the best balance, whereas peaks that are too early or too late harm quality [2508.17017].

Within a DDIM sampling loop, DOG is introduced by replacing CFG’s unconditional branch with the negative-prompt prediction, clipping its norm, orthogonalizing it, computing the triangularly scheduled scale, and using the resulting $\hat \epsilon$ in the usual DDIM update. The hyperparameters listed for this process are $gs$, $u_T$, $\tau$, $p$, $\lambda_t$, and $\lambda_s$ [2508.17017].

## 4. Relation to classifier-free and projected guidance methods

The paper contrasts DOG most directly with standard CFG. In the notation given there, CFG combines conditional and unconditional predictions as

$$
\hat \epsilon_{\mathrm{CFG}} = (1+gs)\cdot \epsilon(x \mid c) - gs \cdot \epsilon(x \mid \varnothing).
$$

At high $gs$, this is described as often oversaturating or injecting artifacts. DOG replaces $\epsilon(x \mid \varnothing)$ with an orthogonalized negative-prompt direction, yielding a guidance vector that is described as disentangled from the core signal, more stable at large guidance scales because of scheduling, and content-preserving because the parallel component to the positive prediction is removed [2508.17017].

The comparison extends to APG (“Adaptive Projected Guidance”). Empirically, DOG is reported to achieve lower Character Error Rates (CER) and fewer visual artifacts than both CFG and APG, especially when $gs \gg 1$. A related evaluation caveat is explicitly noted: FID is stated to be unreliable for HTG, because DOG can produce visually cleaner samples despite higher FID. This matters because the method is aimed at readability, stylistic fidelity, and text correctness rather than optimization against a single image-distribution metric [2508.17017].

## 5. Reported empirical results on IAM and GNHK

DOG was evaluated on two HTG backbones, DiffusionPen and One-DM, using IAM and GNHK. The reported quantitative highlights span out-of-vocabulary generation, downstream handwriting recognition augmentation, standard generation metrics, and ablations [2508.17017].

| Setting | Comparator(s) | Reported DOG result |
|---|---|---|
| HTG\_OOV CER on $\sim 18.6$K OOV samples | No guidance: 22.8%; CFG (best $gs \approx 10$): 19.9%; APG (best $gs \approx 2$): 20.8% | 18.1% with DOG (best $gs \approx 10$) |
| HTR training on IAM + synthetic data | Real IAM only: 3.58% val, 4.92% test; + DiffusionPen generated: 2.43% val, 4.17% test | 2.27% val, 3.99% test with DOG-guided generation |
| IAM test metrics for $gs \in \{2,10,20,30\}$ | CFG and APG degrade beyond $gs \approx 10$ | DOG always achieves lowest CER, approximately 7–7.8% |

The ablation findings are central to interpreting the method. Removing orthogonal projection is reported to cause generation collapse under noise. Removing scheduling makes images noisy at high $gs$. For the negative prompt itself, using unconditional $\epsilon(x \mid \varnothing)$ is less effective than directly corrupting style or content. The reported best balance occurs near mid-denoising with $u_T \approx 700$ [2508.17017].

Qualitatively, DOG is described as greatly reducing speckle-like artifacts, producing diverse variants of the same word-style pair under repeated sampling with fresh noise, and maintaining readability together with stylistic fidelity on truly unseen styles in GNHK, where baseline samplers struggle. These observations align with the method’s stated objective of combining clarity with controlled diversity rather than forcing a single deterministic rendering [2508.17017].

## 6. Interpretation, scope, and related orthogonal-guidance formulations

DOG is specific to diffusion-based HTG and operates entirely at test time. It is therefore best understood as a sampler-side control mechanism rather than a training-time architecture change. The summary states that implementing it requires no retraining and that it is plug-and-play with existing HTG diffusion models. This suggests that its practical value lies in modifying guidance geometry without changing the underlying denoiser, which is relevant for systems already trained on datasets such as IAM or GNHK [2508.17017].

A broader methodological context is provided by related orthogonal-guidance ideas outside HTG. In flow-matching robot policies, the method "POTR" introduces a prior-corrected orthogonal trust-region guidance that decomposes a guidance vector into components parallel and perpendicular to the denoising velocity and constrains the perpendicular component within a trust region. In that setting, the prior-corrected weight provides stronger intermediate-time correction, while the orthogonal trust region improves stability; on LIBERO with $\pi_{0.5}$, POTR improves success rate and reduces chunk-boundary discontinuity, acceleration, and jerk relative to RTC [2605.24433]. This suggests that projection-based control of transverse perturbations has broader relevance, but the HTG formulation of DOG and the robotics formulation of POTR act on different latent objects, with different schedules, constraints, and evaluation targets.

Within HTG itself, the most important interpretive caution is that DOG should not be reduced to a simple “stronger CFG.” Its defining components are the structured negative prompt, orthogonal decomposition, and triangular scheduling taken together. The reported improvements in OOV CER, readability, and style variability, alongside the ablations showing collapse without orthogonal projection and noise without scheduling, indicate that the method’s contribution is geometric and temporal rather than merely scalar rescaling of guidance [2508.17017].

Source: https://www.emergentmind.com/topics/dual-orthogonal-guidance-dog