---
title: 'RhymeRL: Dual RL Systems for Poetry and LLM Optimization'
url: https://www.emergentmind.com/topics/rhymerl
type: topic
---

# RhymeRL: Dual RL Systems for Poetry and LLM Optimization

RhymeRL is a name used for two distinct reinforcement-learning systems in arXiv literature. In neural poetry, it denotes a generate-and-revise framework that models poem revision as a Markov decision process and optimizes a revision policy with Proximal Policy Optimization so that generated quatrains satisfy a target rhyming scheme without explicit supervision about which words create the rhymes [2102.04114]. In large language model reinforcement learning, it denotes a systems framework for accelerating disaggregated rollout–reward–train pipelines by exploiting similarity across adjacent training epochs through historical speculative decoding and distribution-aware rollout scheduling, while reporting no degradation in training accuracy and no modification of the RL paradigm [2508.18588]. The shared nomenclature suggests a common emphasis on iterative reuse of prior text or prior trajectories, although the two systems operate at very different levels of abstraction.

## 1. Nomenclature and research scope

A common source of confusion is that “RhymeRL” does not refer to a single method family. The 2021 work addresses symbolic and neural revision of poems under rhyme constraints, whereas the 2025 work addresses systems-level acceleration of RL training for LLMs.

| Usage | Domain | Core mechanism |
|---|---|---|
| RhymeRL in "Generate and Revise: Reinforcement Learning in Neural Poetry" [2102.04114] | Neural poetry generation | Generate a draft, then revise words with PPO to match a target rhyme scheme |
| RhymeRL in "History Rhymes: Accelerating LLM Reinforcement Learning with RhymeRL" [2508.18588] | LLM RL systems | Reuse historical rollouts via HistoSpec and HistoPipe |

The earlier usage is centered on text quality under formal poetic constraints. The later usage is centered on throughput, GPU utilization, and rollout efficiency in production-scale RL. The overlap is therefore nominal rather than architectural: one is an RL policy over edit positions in a poem, the other is an RL infrastructure for accelerating rollout generation and balancing rollout workloads.

## 2. Markov decision process and model design in neural poetry

In the neural-poetry formulation, each state $S_t$ is a tuple $(o_t, a, r)$, where $o_t=(w_1,\ldots,w_N)$ is the current $N$-word draft of the poem, $a$ is the author ID, and $r$ is the target rhyme-scheme. The action space consists of selecting an index $i\in\{1,\ldots,N\}$ corresponding to the word position to edit, together with an implicit “do-nothing” action at terminal. After the agent chooses $i$, a prompter module samples a replacement word $w' \sim p(w' \mid o_t \setminus \{w_i\}, a, r)$, and the environment returns the updated state in which $w_i$ is replaced by $w'$. Because the prompter sampling is stochastic, the transition dynamics are probabilistic [2102.04114].

The policy network, called the “Detector,” receives the full poem $o_t$ encoded by a character-aware bi-LSTM, producing per-word vectors $H_o=\{h_1,\ldots,h_N\}$. A learned attention mechanism, $\mathrm{attn}_{det}([a;r], H_o)$, produces a fixed-size context vector $c_t$ that fuses the author embedding $e_a$, the rhyme embedding $e_r$, and the poem representation. A one-hidden-layer MLP of size $512$ then outputs a softmax over the $N$ positions,
$$
\pi_\theta(i \mid o_t, a, r) = \mathrm{MLP}_i(c_t).
$$

The prompter network is context2vec-style and bidirectional around the chosen position $i$, omitting $w_i$ itself. Left and right LSTMs produce $[\overleftarrow{h}_{i-1}; \overrightarrow{h}_{i+1}]$, which are concatenated with $e_a$ and $e_r$, then linearly projected and passed through a softmax over $|V|$. The generator network is a conditional sequence-to-sequence language model that produces the initial draft $o_0$. Its encoder is a char-aware bi-LSTM over any given prefix verses; its decoder is an LSTM over the previous word together with $e_a$ and $e_r$, followed by a GRU with attention over the encoder, and final softmax sampling with nucleus sampling at top-$p=0.9$ [2102.04114].

This architecture decomposes drafting and revision into separate modules. The generator produces a plausible initial poem, the detector learns where revision is useful, and the prompter learns how to alter a local position coherently under author and rhyme conditioning. The paper’s framing is explicitly human-inspired: poems are not produced in “just one breath” but are repeatedly revisited and corrected.

## 3. Reward shaping, optimization, and empirical behavior in poem revision

Rhyme detection uses the Pronouncing library to map each word $w$ to a rhyming class $\rho(w)$ based on the final phoneme sequence. The instantaneous reward at timestep $t$ is
$$
R_{t+1} =
\begin{cases}
+1 & \text{if } o_{t+1} \text{ matches scheme } r \\
-1 & \text{otherwise,}
\end{cases}
$$
where matching means that for every pair of lines $(i,j)$ with the same rhyme label in $r$, $\rho(w_i)=\rho(w_j)$. The cumulative undiscounted return is
$$
G_0 = \sum_{k=0}^{T-1} R_{k+1},
$$
with $T \le 30$, terminating either when the rhyme scheme is satisfied or when the maximum revision length is reached [2102.04114].

The policy is optimized with PPO using the clipped surrogate objective
$$
L^{CLIP}(\theta) = \mathbb{E}_t \left[\min\left(\rho_t \hat{A}_t, \mathrm{clip}(\rho_t, 1-\epsilon, 1+\epsilon)\hat{A}_t\right)\right],
$$
where $\rho_t = \pi_\theta(A_t\mid S_t)/\pi_{\theta_{old}}(A_t\mid S_t)$ and $\epsilon=0.2$. Advantage estimation uses GAE,
$$
\hat{A}_t = \sum_{l=0}^{T-t-1} (\gamma\lambda)^l \delta_{t+l}, \qquad
\delta_t = R_{t+1} + \gamma V(S_{t+1}) - V(S_t),
$$
with $\gamma \approx 1$ and $\lambda$ tuned in $[0.95,1]$. The implementation may attach a separate value head $V_\phi(S)$ to the detector and can add an entropy bonus; PPO epochs are early-stopped when the KL divergence exceeds a trust-region threshold [2102.04114].

Training proceeds through on-policy sample collection in “volleys.” Start states are sampled from the generator as $o_0 \sim p_{LM}(\cdot \mid a,r)$. In experiments with a fixed number of poems, the procedure cycles through a fixed set of $N$ distinct generated drafts; in the “dynamic” setting, fresh drafts are sampled each episode. Episodes run for at most $30$ revision steps. After collecting $M$ episodes—$M=10\,000$ for $N=10$ poems and $M=100\,000$ for $N\ge 100$—the method computes normalized per-batch advantages, then performs $K$ PPO epochs with mini-batches of size approximately $512$, clipping with $\epsilon=0.2$ and early-stopping on KL. Training spans $V=10$ volleys, with the average episode return per volley as the monitored quantity [2102.04114].

The dataset comprises $757\,891$ quatrains from Project Gutenberg, restricted to English and automatic rhyme annotation; each quatrain has $4$ lines and a maximum of $50$ tokens per line. The vocabulary size is $50\,000$, the embedding size is $300$, the number of author IDs is $768$, and the number of rhyme-scheme types is $50$. The conditional generator improves over the vanilla generator from validation/test perplexity $52.98/59.78$ to $51.40/54.86$, and the conditional prompter improves from $14.09/14.78$ to $12.90/13.40$. In the “poem reconstruction” ablation with a perfect prompter oracle, PPO average total return improves from approximately $-8 \rightarrow 0$ for $1$–$10$ poems and from $-8 \rightarrow -6$ for $100$ poems. In the full generate-and-revise setting, PPO steadily improves average return per volley, while Vanilla Policy Gradient is unstable; for $N=100$, PPO moves from $-15.6 \rightarrow -5.2$, whereas VPG remains near random performance at $-19.4 \rightarrow -19.3$ [2102.04114].

Qualitative examples with AABB and ABBB schemes show that the model learns to concentrate edits on line-end words despite not being told explicitly to do so, and it often alters interior words to preserve fluency around newly introduced rhymes. The paper presents this as evidence that shortest-path revision under sparse rhyme feedback is feasible without direct supervision over which tokens “should rhyme.”

## 4. Systems architecture of RhymeRL for LLM reinforcement learning

The 2025 RhymeRL is a systems framework rather than a poem-editing policy. It inherits the disaggregated rollout–reward–train pipeline of modern LLM RL systems such as veRL. Rollout workers perform LLM inference to generate reasoning chains and use HistoSpec during decoding; reward workers score completed rollouts with rule-based or learned reward models and forward $(\text{prompt}, \text{response}, \text{reward})$ tuples to the replay buffer; train workers sample from the replay buffer, perform policy optimization such as GRPO or DAPO, and publish updated model weights to rollout workers’ weight buffers [2508.18588].

A central controller assigns prompt sub-batches to rollout workers in a streaming fashion, using historical length-rank data to invoke HistoPipe. CPU-side history workers maintain suffix-tree indexes of past rollouts together with the length rankings used by rollout-time scheduling; these workers run opportunistically on idle CPUs and ingest completed rollouts asynchronously. Weight updates, prompt dispatch, rollouts, reward scoring, and training therefore proceed in a pipelined fashion with high overlap [2508.18588].

The motivating systems problem is GPU underutilization in LLM RL. The paper identifies two primary causes: the dominance of rollout time because of test-time scaling, and “GPU bubbles” induced by imbalances in rollout lengths within a batch. Earlier mitigations such as asynchronous execution and truncation are described as offering partial relief while potentially compromising training accuracy for efficiency. RhymeRL addresses these two bottlenecks through two modules: HistoSpec for accelerating rollout generation, and HistoPipe for balancing rollout workloads [2508.18588].

This formulation relocates the use of RL from the object level to the infrastructure level. The underlying policy optimization algorithm may still be GRPO or DAPO, but the contribution lies in how rollouts are generated, scheduled, and synchronized across workers.

## 5. Historical reuse mechanisms: HistoSpec and HistoPipe

HistoSpec is motivated by an empirical observation: in RLHF, when the same prompt is rolled out repeatedly across adjacent epochs with small clipped model updates, $75$–$95\%$ of tokens in a rollout at epoch $k$ appear as contiguous subsequences in the previous epoch’s rollout for that prompt. The system therefore reuses historical token sequences as speculative drafts. At each decoding step for prompt $p$, it takes the last $m$ decoded tokens as a prefix, queries a suffix-tree index for matching nodes, extracts up to $W$ speculative continuation tokens, verifies the draft in a single LLM forward pass through the KV-cache, accepts the longest verified prefix, appends accepted tokens, and repeats [2508.18588].

Each prompt maintains a suffix tree $T_p$ built over all rollouts from the last epoch. Nodes correspond to substrings, edges represent one or more tokens, and each node stores a priority equal to the sum of reward scores of all rollouts containing that substring as a suffix. This priority guides branch selection when several suffix continuations are available. History workers build the index asynchronously in $O(n)$ time and memory per epoch, where $n$ is the total number of tokens [2508.18588].

The speculation window uses an AIMD-like policy. The system initializes $W \leftarrow 2$; after full acceptance of a $W$-token draft, it updates $W \leftarrow \min(W+2, W_{max})$ with default $W_{max}=32$; after any rejection, it resets $W \leftarrow 2$. The prefix length is similarly reduced from $7$ toward $3$ if no suffix-tree match exists. The corresponding recurrence is
$$
W_{k+1} =
\begin{cases}
W_k + \Delta & \text{if all } W_k \text{ tokens are accepted} \\
W_{min} & \text{otherwise,}
\end{cases}
$$
with $\Delta=2$, $W_{min}=2$, and $W_{max}=32$ [2508.18588].

HistoPipe is motivated by a second empirical regularity: when prompts are ranked by rollout length in epoch $k-1$, $96$–$98\%$ of prompts remain in or near their previous rank in epoch $k$. The system partitions prompts into $N$ equally sized ranking groups sorted by increasing historical length. Tier 1 alternates ascending and descending group assignment across steps: on odd steps, worker $0$ is assigned to group $0$, worker $1$ to group $1$, and so forth; on even steps, worker $0$ is assigned to group $N-1$, worker $1$ to group $N-2$, and so forth. This creates inter-step complementarity between short and long rollouts [2508.18588].

Tier 2 reshapes GPU allocation because equal GPU counts per group still leave residual bubbles under long-tailed length distributions. The system solves
$$
\min d
$$
subject to
$$
\mathrm{exec\_time}(\mathrm{group}_i; w_i) \le t_0 + i\cdot d, \qquad \sum_i w_i = W_{total},
$$
where $\tau(\ell, w)$ is obtained by pre-profiling and represents expected rollout time for length $\ell$ with data-parallel width $w$. A binary search over $d$ finds the minimal allocation plan $w_i$ satisfying these constraints. Additional migration-based rebalancing handles anomalously long outliers through intra-step reassignment of the last $\alpha\%$ of tasks in a group when their length exceeds $\beta \times$ the historic maximum, and through inter-step deferral of very long rollouts [2508.18588].

Two misconceptions are directly addressed in this design. One is that speculative decoding necessarily changes the model’s sampling distribution; the paper states that speculative decoding preserves the exact output distribution because the historical drafts are only verified, not imposed. The other is that efficiency must be purchased by increasing off-policyness; RhymeRL states that it strictly limits off-policyness to one RL step, matching veRL’s one-step stale-weights paradigm [2508.18588].

## 6. Experimental results, correctness claims, and interpretive context

The LLM-systems evaluation uses a $16$-node cluster, each node containing $8\times$ NVIDIA H100 GPUs, dual-socket Sapphire Rapids with $96$ cores, $1.9$ TB DRAM, and InfiniBand. The evaluated models are Qwen3-8B, Qwen3-14B, and Qwen2.5-32B; the RL algorithms are GRPO by default and DAPO; rollout group size is $16$ samples per prompt. Baselines are veRL v0.4.1 and AReaL with off-policyness $=1$ and $=8$ [2508.18588].

Against these baselines, RhymeRL reports up to $2.6\times$ throughput improvement over veRL, with average $1.9\times$ at $8$K token maximum and $2.3\times$ at $16$K; up to $2.1\times$ over AReaL with off-policyness $=1$, with average $1.6\times$ at $8$K and $1.8\times$ at $16$K; and up to $1.6\times$ over AReaL with off-policyness $=8$. In ablations, the hybrid rollout pipeline contributes a $1.43\times$ performance boost, two-tier scheduling contributes a further $1.10\times$, and speculative decoding contributes a further $1.50\times$. HistoSpec alone yields up to $1.86\times$ per-step rollout speedups, the speculation rate grows to approximately $80\%$, and the acceptance rate remains between $65$ and $79\%$. HistoPipe shortens $10$-step training time by up to $1.68\times$, with two-tier scheduling yielding up to $1.14\times$ further improvement; only approximately $2$–$5\%$ of samples are migrated as outliers [2508.18588].

On accuracy, reward-curve trajectories for Math and Code tasks on $14$B models are reported to nearly overlap with veRL, and off-policyness $=1$ is stated to be strictly preserved, with no degradation in training accuracy. The correctness argument for HistoSpec is that verifying speculative drafts in bundle preserves the exact autoregressive distribution, since historical drafts only reorder inference calls and do not alter logits. The scheduling argument is that the observed rank stability across epochs is sufficiently high to support bounded bubble time under mild assumptions on rollout-length drift [2508.18588].

Taken together, the two RhymeRL lines of work illustrate two different uses of reinforcement learning over structured textual processes. The 2021 framework treats revision itself as the decision problem, with actions over edit positions and rewards defined by rhyme satisfaction. The 2025 framework treats rollout generation history and rollout-length history as reusable signals for systems optimization. This suggests a broader interpretation of “history rhymes” across both usages: prior textual structure can serve either as the object of control, as in poem revision, or as a systems prior for accelerating repeated RL computation.

Source: https://www.emergentmind.com/topics/rhymerl