Can Unconditional Language Models Recover Arbitrary Sentences?

Nishant Subramani, Samuel R. Bowman, Kyunghyun Cho

Can a frozen, pretrained language model be "steered" to generate any arbitrary sentence just by finding the right input vector? This paper demonstrates that for sufficiently large models, the answer is a resounding yes. By optimizing a continuous representation (a "sentence vector") to act as a bias at each time step, researchers found they could recover nearly any sentence perfectly without modifying a single parameter of the original model.

The Quest for a Universal Decoder

In the NLP world, pretrained models like BERT or ELMo have long served as fantastic "universal encoders"—turning text into rich mathematical representations for various classification tasks. But can they function as "universal decoders"?

Ideally, a single, fixed language model (LM) could be used for translation, summarization, or image captioning without needing task-specific fine-tuning. For this to work, there must exist a continuous representation (a point in space) that, when fed into the LM, forces it to output a specific target sentence. The authors set out to answer a fundamental prerequisite question: Do these representations even exist? If a model cannot be forced to reproduce a sentence it has already seen, it has no hope of acting as a general-purpose decoder.

Mapping the Reparametrized Sentence Space

To investigate this, the authors propose a framework to map sentences into and out of a reparametrized sentence space ($Z$):

  1. Conditioning Mechanism: Instead of just feeding a vector at the start of generation, they add a learned bias vector ($z$) to the hidden and cell states of a recurrent language model (LSTM) at every time step.
  2. Forward Estimation ($X \to Z$): To find the vector $z$ for a specific sentence, they freeze the language model's weights and use a nonlinear conjugate gradient optimizer. This finds the $z$ that maximizes the likelihood of the target sentence.
  3. Backward Estimation ($Z \to X$): To verify if the vector actually "holds" the sentence, they perform standard beam search decoding using the optimized $z$ to see if the model reconstructs the original text.
  4. Scaling the Space: They experimented with different dimensions for $z$ ($d'$), ranging from 128 to over 32,000, to determine how much "room" is needed to store a sentence.

Key Findings on Sentence Recovery

The experiments, conducted primarily on the English Gigaword corpus, revealed several critical insights about model capacity and sequence length.

Sentence recovery performance across model sizes and dimensions
  • Near-Perfect Recovery: The "Large" model (1024D hidden states) achieved an Exact Match (EM) score of over 99% for sentences when the representation space was sufficiently large ($d' = 4096$).
  • The "Capacity" Threshold: Recoverability isn't just about the vector size; it is fundamentally tied to the model size. Recoverability plateaus once the dimension of the sentence vector ($d'$) reaches the dimension of the model's hidden state. Interestingly, increasing the dimension too far beyond the "sweet spot" (like 4096 for the Large model) led to slight performance degradation, likely due to optimization difficulties in higher-dimensional spaces.
  • The "Left-to-Right" Decay: As seen in the charts, recoverability is negatively correlated with sentence length. If an autoregressive model makes a mistake early in a sentence, it almost never recovers, confirming the compounding error problem.

Domain Robustness and Linguistic Priors

To ensure the model wasn't simply memorizing its training data, the authors tested it on IWSLT16 (out-of-domain TED talk transcripts) and sequences of random words.

Recovery performance on out-of-domain (IWSLT) and random sequences
  • Robustness to Domain: Even on the IWSLT data, which the model never saw during training, the medium and large models achieved nearly perfect BLEU scores. This proves that the "decoder" capability is somewhat universal and not strictly limited to the training distribution.
  • Linguistic Priors Matter: The model is not just acting as a random memory bank. It is significantly easier for the model to recover real English sentences than random strings of words. This suggests the model actively leverages its learned knowledge of language syntax and semantics to help reconstruct the target.

Limitations and Future Work

While the paper proves these recoverable vectors exist, finding them currently requires an expensive, sentence-specific optimization process. Standard optimizers like Adam fail here, requiring more sophisticated second-order-like methods to navigate the highly non-convex landscape. In a real-world application, a separate "encoder" network would be needed to predict these vectors instantly.

Furthermore, the method struggles with very long sentences (30+ tokens) as the fixed-length representation eventually runs out of capacity. Future work should focus on regularizing this sentence space to make it more continuous, easing the burden on future encoders, and exploring whether these same recovery properties hold for modern attention-based Transformer architectures.

Summary updated

BibTeX
@inproceedings{subramani2019can,
  author = {Nishant Subramani and Samuel R. Bowman and Kyunghyun Cho},
  title = {{Can Unconditional Language Models Recover Arbitrary Sentences?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=ho4vKXmd5L9},
}
Figure