Harvard's EBFT Beats RLVR on Coding Without a Reward Model
A new fine-tuning method matches ground-truth feature statistics of model rollouts, beating SFT on cross-entropy and rivaling RLVR without a verifier.
ProTakeaways
- EBFT fine-tunes LMs by matching feature statistics of rollouts to ground-truth completions in embedding space.
- Matches RLVR on downstream accuracy without a verifier or reward model, and beats SFT everywhere.
- Achieves lower validation cross-entropy than SFT, despite not directly optimizing token likelihood.
- Uses a frozen copy of the base model as feature network, pulling activations from layers at 25%, 50%, 75% depth.
- Strided block-parallel rollouts and feature whitening make the REINFORCE-style training tractable.
- Code available at sjelassi/ebft_openrlhf; roughly 36h per epoch on H100 for 1.5B models.
A group of researchers from Harvard's Kempner Institute, MBZUAI, and Microsoft Research have proposed a fine-tuning objective that sits somewhere between supervised fine-tuning and reinforcement learning with verifiable rewards. It's called Energy-Based Fine-Tuning (EBFT), and it trains language models by matching the feature statistics of on-policy rollouts to those of ground-truth completions, instead of matching tokens or optimizing a scalar reward.
The result is a method that consistently outperforms SFT and matches RLVR on downstream accuracy across coding and translation, while achieving lower validation cross-entropy than both. And it needs no verifier, no reward model, and no preference labels.
The problem with token-level supervision
The core issue EBFT targets is the mismatch between how language models are trained and how they generate. Cross-entropy training under teacher forcing is the standard approach for pre-training, continued/mid-training, and supervised fine-tuning of large language models. But this creates a well-known distribution shift: during training, the model conditions on ground-truth prefixes, while at deployment time, it must condition on its own generations. Errors early in a rollout push subsequent tokens into distributions the model has rarely seen.
You can measure this drift. Low perplexity measures one-step prediction accuracy on ground-truth prefixes but does not guarantee well-calibrated behavior over longer generations. The model may match the data distribution locally while diverging from it at the sequence level.
RLVR, the current fix, has its own problems. It needs a reliable verifier (unit tests, BLEU, math checkers), and even when one exists, RLVR improves downstream performance at the cost of worsening both the validation cross-entropy and the feature-matching loss. In other words, reward-driven optimization can sharpen behavior on a benchmark while eroding the model's underlying language modeling quality.
Matching moments in embedding space
EBFT replaces token-level supervision with a sequence-level objective. For each training context, the model generates multiple completions and a frozen feature network embeds both the rollouts and the ground-truth completion. The training signal is the squared error between the mean feature embedding of the rollouts and the embedding of the ground-truth completion.
The feature network itself is just a frozen copy of the base model. Given a concatenated sequence, they take the concatenation of intermediate activations at different depths of the feature network, normalize each block to unit L2 norm, and concatenate them to form the feature vector. In all experiments, they use layers at depths 25%, 50%, and 75%, on the intuition that earlier layers capture low-level information, final layers are biased toward next-token prediction, and middle layers carry semantic and structural information.
Under a KL-regularized view, this objective has a clean theoretical interpretation: the feature-matching objective implicitly defines an energy function over sequences, with the optimal policy taking the form of an exponential tilt of the base model. Hence the name.
How one training step actually works
Each EBFT iteration follows this loop:
- Sample
nrollouts of lengthGfrom the generator conditioned on contextc. - Run each concatenated prompt-plus-completion through the frozen feature network to get embeddings.
- Compute a per-rollout reward: an alignment term (dot product with the ground-truth embedding) minus a diversity term (average dot product with the other rollouts).
- Apply a REINFORCE update using a leave-one-out baseline adjusted for the fact that the reward itself depends on the other samples.
Two engineering tricks make this tractable. The first is strided block-parallel rollouts, borrowed from Quiet-STaR: instead of treating a training sequence as a single supervision point, they carve out many nested prefixes and sample completions from all of them in one forward pass using a custom attention mask. The second is feature whitening, where features are premultiplied by the pseudo-inverse square root of the empirical second-moment matrix. This corresponds to a relaxation of the local chi-squared divergence and, because KL and chi-squared coincide locally, whitened feature matching approximates a sequence-level cross-entropy when the model is already close to the data distribution.
What the numbers say
The team ran three tasks: Q&A coding on OpenCodeInstruct, unstructured code continuation on SwallowCode, and translation on ALMA-Human-Parallel. Base models were Qwen2.5-1.5B for code and Llama3.2-1B for translation, trained for two epochs.
| Method | HumanEval greedy | pass@16 | Val CE | FM loss |
|---|---|---|---|---|
| Base | 0.484 | 0.715 | 0.338 | 0.361 |
| SFT | 0.483 | 0.728 | 0.289 | 0.315 |
| RLVR | 0.535 | 0.752 | 0.774 | 0.442 |
| EBFT | 0.548 | 0.771 | 0.207 | 0.258 |
A few things stand out:
- EBFT beats SFT at SFT's own game. Validation cross-entropy drops from 0.289 to 0.207 on Q&A coding, despite EBFT never explicitly optimizing token likelihood. EBFT with whitening approximately optimizing a relaxation of the chi-squared divergence, which is locally equivalent to the KL divergence when the model is close to the data distribution, explains why.
- RLVR trades calibration for accuracy. Cross-entropy climbs to 0.774 (worse than the base model at 0.338) and the feature-matching loss actively degrades during training.
- EBFT works where RLVR can't. When training on raw code scraped from GitHub, EBFT yields substantial gains over SFT, boosting pass@1 from 0.467 to 0.524. There's no verifier for raw code continuation, so RLVR is inapplicable.
- Gains extend beyond the training horizon. Despite training with a rollout horizon of only 8 tokens, EBFT's gains persist and grow at longer completions.
- Better out-of-distribution transfer. On MultiPL-E (non-Python languages), SFT actually degrades below the base model (0.465 vs 0.506 greedy), while EBFT improves to 0.524.
The real breakthrough
The headline result is that EBFT matches RLVR without a verifier. But the more interesting finding is that feature matching and cross-entropy are not in tension. Even at gamma=0 (pure feature matching, no CE regularization), EBFT reduces validation CE faster than SFT does. This suggests that optimizing feature matching naturally drives the cross-entropy down as well, because both objectives share the same minimizer (the ground-truth distribution) but land in different loss landscapes.
The qualitative behaviors are also telling. SFT tends to produce structurally reasonable outputs that miss subtle prompt requirements. RLVR generates plausible logic that fails at execution (calling is_prime without defining it, or drifting into multilingual tag lists like appending Português: and truncating mid-word). EBFT avoids both failure modes, producing self-contained executable code and clean single-sentence translations.
Caveats and when to use it
EBFT isn't free. EBFT is rollout-based and therefore slower per update than standard SFT, making it most suitable as a fine-tuning stage applied after cross-entropy training. Their own timing: a single epoch of SFT takes about 30 minutes on one H100, while an epoch of EBFT takes roughly 36 hours on the current implementation. Scaling was tested up to 7B parameters with short (8-token) rollout horizons.
Ablations show that whitening and last-token pooling matter most. Interestingly, replacing the 1.5B feature network with a frozen Qwen2.5-7B produces similar results, so naively scaling the feature network doesn't help. Random weights for the feature network only hurt modestly, suggesting pre-trained representations are helpful but not essential.
The code is available on GitHub, built on top of the OpenRLHF framework. If you're fine-tuning on data without a clean verifier, or if you've noticed your RL-tuned models getting sharper on benchmarks while their raw language modeling quality quietly degrades, this is a method worth trying.