---
title: Focused Hierarchical RNNs (FHE)
url: https://www.emergentmind.com/topics/focused-hierarchical-rnns-fhe
type: topic
---

# Focused Hierarchical RNNs (FHE)

Focused Hierarchical RNNs, introduced as the Focused Hierarchical Encoder (FHE), are a mechanism for conditional sequence processing in which a recurrent encoder does not propagate every token uniformly through a stacked hierarchy. Instead, a multi-layer conditional sequence encoder reads one token at a time and makes a discrete, question- or context-conditioned decision about whether the current token is relevant enough to update a higher recurrent layer. In the formulation reported in "Focused Hierarchical RNNs for Conditional Sequence Processing," the resulting hierarchy is intended to concentrate computation and attention on key parts of the input, yielding a compact concept-level representation of long sequences while reducing memory and attention-search cost [1806.04342].

## 1. Problem formulation and conceptual position

The model is motivated by a limitation of standard attention-based recurrent encoders: many such architectures use an encoder with attention that looks over the entire sequence and assigns a weight to each token independently. FHE reformulates this setting by introducing a conditional hierarchy in which the encoder itself is focused before downstream attention is applied. The conditioning signal is the question or context embedding, and the central decision variable is whether the current token should trigger an update in the upper recurrent layer [1806.04342].

Within this formulation, the hierarchy is not merely a conventional stacked RNN. The lower layer processes every token, whereas the upper layer updates only when a learned discrete boundary gate opens. This distinction is operationally important because the comparison baselines include both a single-layer model, equivalent to gates always closed, and a two-layer model with always open gates. FHE differs from both by making sequence compression input- and query-dependent rather than structurally fixed.

A plausible implication is that FHE shifts part of the burden of relevance estimation from post hoc attention to online segmentation. The paper states this directly in functional terms: focusing via learned, question-conditioned gates induces a compact, concept-level summary of long passages, reduces the burden on the attention mechanism, and improves long-horizon generalization [1806.04342].

## 2. Encoder architecture and discrete boundary mechanism

The encoder is a two-layer LSTM. The lower, token-level layer processes every input token $x_t$ sequentially, producing hidden and cell states
$$
h_t^l, c_t^l = \mathrm{LSTM}_l(x_t, h_{t-1}^l, c_{t-1}^l).
$$

The upper, focused-concept layer is updated conditionally. When the boundary gate is closed, it carries over its previous state:
$$
h_t^u = h_{t-1}^u,\qquad c_t^u = c_{t-1}^u.
$$
At the end of encoding, the model has
$$
H^l = \{h_1^l,\ldots,h_n^l\},\qquad H^u = \{h_1^u,\ldots,h_n^u\},
$$
but only $k \approx \sum_t \hat g_t$ of the upper-layer states are unique updates. Downstream attention and decoding attend only over $H^u$, not over the full token-level sequence, which reduces both memory and attention-search cost [1806.04342].

The boundary-gate mechanism is discrete. At each time step $t$, a scalar gate-opening probability is computed as
$$
b_t = \sigma\!\left(w_b^\top\, \mathrm{LReLU}(W_b z_t + b_b)\right),
$$
where $z_t$ concatenates features conditioned on the question/context $q$ and the lower-layer state $h_t^l$. In the simplest QA setup,
$$
z_t = [\, q \odot h_t^l;\ h_t^l;\ q \,].
$$
A Bernoulli sample then determines whether the upper LSTM updates:
$$
\hat g_t \sim \mathrm{Bernoulli}(b_t).
$$
If $\hat g_t = 1$,
$$
\tilde h_t^u, \tilde c_t^u = \mathrm{LSTM}_u(h_t^l, h_{t-1}^u, c_{t-1}^u),\qquad
h_t^u = \tilde h_t^u,\ c_t^u = \tilde c_t^u.
$$
If $\hat g_t = 0$,
$$
h_t^u = h_{t-1}^u,\qquad c_t^u = c_{t-1}^u.
$$

This architecture makes the upper representation sparse in time. In effect, the lower layer remains token-synchronous, while the upper layer becomes event-synchronous, where events are defined by learned, question-conditioned boundaries.

## 3. Optimization, policy gradient, and sparsity control

The training objective maximizes the log-likelihood of the answer $A$ given passage $P$ and question $Q$:
$$
R = \log p(A\mid Q,P).
$$
Because the gate decisions are discrete, the model uses a policy-gradient estimator. For the gate policy $\pi_b(\hat g_1 \ldots \hat g_n)$,
$$
\nabla_\theta \, \mathbb{E}_{\hat g \sim \pi_b}[R]
=
\mathbb{E}_{\hat g}\!\left[
\sum_t \nabla_\theta \log \pi_b(\hat g_t \mid z_t)\cdot (R - b_t^b)
\right],
$$
where $b_t^b$ is a control-variate baseline used to reduce variance. In practice, the reward is
$$
R = \log p(A\mid Q,P,\hat g),
$$
and a small entropy bonus $\alpha H(\pi_b)$ is added to encourage exploration, with $\alpha \approx 10^{-3}$ in QA [1806.04342].

The model also introduces explicit sparsity regularization to avoid the degenerate solution in which all gates open:
$$
G(\hat g) = \mathrm{ReLU}\!\left(\sum_t \hat g_t - \gamma T\right),
$$
$$
L = -R + \beta G(\hat g).
$$
Here, $\gamma \in [0,1)$ specifies the allowed fraction of opens without penalty and $\beta > 0$ controls the penalty strength.

The paper concludes that policy-gradient training with a sparse-opening penalty $(\beta,\gamma)$ yields a controllable trade-off between accuracy and number of opens. This is significant because it makes the compression ratio not merely an emergent property but a tunable aspect of the model. At the same time, the reported limitations note that training discrete gates remains more complex than fully-differentiable soft gating [1806.04342].

## 4. Synthetic tasks and generalization behavior

The synthetic evaluations were designed to probe generalization and gate behavior in controlled settings. The first task, the "Picking Task," uses a random digit sequence of length $n$ and a question $k$ asking which digit is most frequent among the first $k$ tokens, with ties broken by choosing the largest digit. The baselines are LSTM1, a single-layer model equivalent to gates always closed, and LSTM2, a two-layer model with always open gates.

With fixed hyper-parameters $\beta = 1$ and $\gamma = 10\%$, FHE achieves the following accuracies on the Picking Task [1806.04342]:

| Setting | LSTM1 / LSTM2 / FHE |
|---|---|
| $n=100$ | 99.4% / 99.7% / 99.5% |
| $n=200$ | 97.0% / 99.2% / 99.4% |
| $n=400$ | 92.9% / 97.5% / 96.9% |

The more consequential result is out-of-distribution length generalization. When trained on $n=200$, $k \leq 200$, and tested up to $n=10\,000$, the reported accuracies are:

| Test length | LSTM1 / LSTM2 / FHE |
|---|---|
| $n=1600$ | $\sim 29.5\%$ / $\sim 28.6\%$ / $\sim 93.3\%$ |
| $n=10\,000$ | $\sim 18.5\%$ / $\sim 14.8\%$ / $\sim 66.8\%$ |

The paper attributes this to boundary behavior: FHE learns to open gates approximately only at $t \approx k$, after which attention focuses on that single upper-state. This observation is central to the model’s interpretation. Rather than maintaining a uniformly dense temporal abstraction, the upper layer appears to localize the decisive computation around the query-dependent boundary.

A second controlled task treats each MNIST image as a sequence of 784 pixels and asks a binary question of the form "is this digit $D$?". On validation, the reported accuracies are LSTM1 97.3%, LSTM2 98.4%, and FHE-fixed, with $\beta = 10^{-4}$ and $\gamma = 50\%$, 99.1% [1806.04342]. The gate visualization shows that gates open mostly around the white foreground pixels of the digit. This suggests that the learned boundaries can align with semantically informative structure even when the input is a rasterized sequence rather than text.

## 5. Large-scale question answering benchmarks

The model is also evaluated on SearchQA and MS MARCO, both described as large-scale QA tasks. On SearchQA, which uses a Jeopardy! question with approximately 50 snippets, the metrics are Exact Match (EM) for single-word answers and F1 for multi-word answers. The reported validation and test results are as follows [1806.04342]:

| Model | Validation F1 \| EM | Test F1 \| EM |
|---|---|---|
| LSTM1+PtrSoftmax | 52.8 \| 41.9 | 48.7 \| 39.7 |
| LSTM2+PtrSoftmax | 55.3 \| 44.7 | 51.9 \| 41.7 |
| FHE | 56.7 \| 49.6 | 53.4 \| 46.8 |
| Prior AQA model [Buck ‘18] | 47.7 \| 40.5 | 45.6 \| 38.7 |

On MS MARCO, described as web queries with passages and human answers, the generative models are evaluated with BLEU-1 and ROUGE-L. The reported validation and test results are:

| Model | Validation BLEU-1 \| ROUGE-L | Test BLEU-1 \| ROUGE-L |
|---|---|---|
| Seq2Seq (Nguyen ‘16) | – \| 8.9 | – \| – |
| Memory Net (Nguyen ‘16) | – \| 11.9 | – \| – |
| LSTM1+PtrSoftmax | 24.8 \| 26.5 | 28 \| 28 |
| LSTM2+PtrSoftmax | 24.3 \| 23.3 | 27 \| 28 |
| FHE | 27.3 \| 26.7 | 30 \| 30 |

The validation ablations on MS MARCO identify three components as consequential. Removing the elementwise product between $q$ and $h^l$ yields 18.5 \| 19.3, removing pointer-softmax yields 20.5 \| 18.7, and removing learned boundaries yields 23.5 \| 24.0 [1806.04342]. These ablations indicate that the gains are not attributable to a single isolated modification; rather, the conditional gating, the multiplicative conditioning term, and the output mechanism all contribute to performance.

Across both benchmarks, the paper reports consistent improvements over prior work and over the recurrent baselines. In that sense, the large-scale QA results complement the synthetic findings: the same mechanism that improves long-horizon generalization in controlled settings also improves benchmark accuracy in realistic QA.

## 6. Interpretation, limitations, and relation to adjacent design choices

The principal interpretive claim made for FHE is that learned, question-conditioned focusing induces a compact summary of long passages at the concept level. In the reported experiments, this has two stated consequences: it reduces the burden on the attention mechanism and improves long-horizon generalization [1806.04342]. The synthetic gate visualizations support this interpretation by showing targeted opens at decisive positions, while the MNIST experiment suggests that the learned boundaries may align with task-relevant structure outside textual data.

FHE should therefore be distinguished from a standard stacked recurrent encoder with attention. The LSTM2 baseline demonstrates that simply adding an upper recurrent layer with always open gates does not reproduce the same behavior. The critical operation is conditional updating under a discrete gate, not depth alone. This is an important architectural distinction because it locates the model’s compression mechanism in learned temporal sparsification rather than in post-encoding attention weights.

The paper also states several limitations and future directions. Training discrete gates remains more complex than fully-differentiable soft gating. Extending the architecture to deeper hierarchies, self-supervised boundary pretraining, or adaptive $\gamma$ may further improve performance. Integration with span-based mechanisms could combine generative flexibility with pointer accuracy [1806.04342]. These statements delimit the contribution carefully: FHE is presented not as a universal replacement for attention-based sequence models, but as a specific recurrent design in which discrete, query-conditioned boundaries improve both efficiency-relevant representation structure and empirical QA performance.

A plausible implication is that FHE occupies an intermediate position between token-level encoding and explicit segment-level modeling. It does not require externally supplied segmentation, yet it does produce an upper representation whose unique states correspond to learned update points. That property is the defining feature of Focused Hierarchical RNNs as formulated in the original work.

Source: https://www.emergentmind.com/topics/focused-hierarchical-rnns-fhe