Repurposing Pre-trained LLMs as High Fidelity Continuous Text Autoencoders
Organizations: University of California, Irvine
Abstract
Next-token prediction has enabled highly fluent autoregressive language models, but it represents global structure only indirectly through sequential factorization. In contrast, high-fidelity autoencoders have become a standard primitive in image generation, enabling generative models to operate over continuous latent spaces; text lacks a comparably faithful continuous representation. We propose LLMAE, a method for repurposing a pretrained decoder-only language model as a continuous text autoencoder by exposing an intermediate fixed-length latent bottleneck within its internal activations. Instantiated with a parameter-efficient 270M Gemma 3 model, LLMAE uses structured attention masks, LoRA adaptation, and KL regularization to learn an autoencoding interface that leverages the generative prior of the original LLM. We train LLMAE to reconstruct text sequences up to 1024 tokens, significantly improving on this task to achieve near-perfect reconstruction. Furthermore, we demonstrate the downstream utility of this representation by training a latent text diffusion model for detailed image captioning using the learned LLMAE autoencoder. By mapping text into a fixed-length continuous latent space, our approach provides an effective substrate for downstream adaptation while benefiting from the fluency of the original LLM.
Figures & tables
| C4-News-Stratified | OpenWebText | CreationMMBench | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | Latent Dim | #Params | BLEU | PPL | BERT | BLEU | PPL | BERT | BLEU | PPL | BERT |
| Source Text | – | – | – | 30.8 | – | – | 27.5 | – | – | 16.9 | – |
| ICAE Ge et al. (2023) | 7.46B | 0.831 | 36.8 | 0.981 | 0.711 | 30.0 | 0.963 | 0.859 | 17.7 | 0.983 | |
| COSMOS Meshchaninov et al. (2025) | 356.5M | 0.783 | 66.9 | 0.979 | 0.773 | 32.6 | 0.982 | 0.712 | 23.3 | 0.951 | |
| LLMAE (Ours) | 278.8M | 0.999 | 30.9 | 0.999 | 0.995 | 27.6 | 0.999 | 0.994 | 17.1 | 0.998 | |
| Source Text | – | – | – | 24.1 | – | – | 21.9 | – | – | 13.3 | – |
| Ablation | Mean | Std | Max | ( ) | BLEU ( ) | PPL ( ) | BERT ( ) |
|---|---|---|---|---|---|---|---|
| NTP Loss Only | 7.068 | 277.61 | 7296.0 | 38556.03 | 0.978 | 25.5 | 0.997 |
| + KL | 0.164 | 8.58 | 1328.0 | 35.36 | 0.967 | 26.9 | 0.993 |
| + KL + Codec | -0.038 | 5.08 | 236.0 | 11.69 | 0.995 | 24.4 | 0.999 |
| Method | # Params | Length | VLM ( ) | CapArena-Auto ( ) | RefCLIP ( ) | PPL ( ) |
|---|---|---|---|---|---|---|
| Autoregressive Baselines | ||||||
| Gemini-1.5-Pro Team et al. (2024) | – | 166.5 | 5.90 | 56.17 | 0.454 | 19.8 |
| LLaVA-1.5-7B Liu et al. (2024) | 7.1B | 74.7 | 2.89 | -94.00 | 0.439 | 10.9 |
| Qwen2-VL-2B Wang et al. (2024) | 2.2B | 117.4 | 4.64 | -48.67 | 0.454 | 14.0 |
| VLV Zhang et al. (2025) | 4.2B | 217.6 | 4.30 | -38.17 | 0.452 | 9.6 |
| Share-Captioner Chen et al. (2024) | 8.4B | 176.5 | 3.34 | -74.83 | 0.439 | 10.6 |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Block (Layers) | Query | Key: Input | Key: Embed | Key: Output |
|---|---|---|---|---|
| Input Layer | Output | Masked | Visible | Visible |
| (Layer 0) | Embed | Visible | Visible | Masked |
| Encoder Block | Output | Masked | Masked | Visible |
| (Layers 1 to D) | Embed | Visible | Visible | Masked |
| Decoder Block | Output | Masked | Visible | Visible |
| (Layers to ) | Embed | Masked | Visible | Masked |
| Noise | BLEU ( ) | PPL ( ) | BERT ( ) |
|---|---|---|---|
| 0 | 0.995 | 24.4 | 0.999 |
| 0.1 | 0.995 | 24.5 | 0.999 |
| 0.25 | 0.991 | 24.7 | 0.998 |
| 0.5 | 0.927 | 31.2 | 0.993 |
| Pair | Decoded midpoint | ||
|---|---|---|---|
| Entity and object swap | A tired tabby cat stretched across the warm windowsill while rain tapped against the glass and a half-finished cup of tea cooled beside an open novel. | A tired golden retriever stretched across the warm windowsill while rain tapped against the glass and a half-finished cup of coffee cooled beside an open newspaper. | A tired golden cat stretched across the warm windowsill while rain tapped against the glass and a half-finished cup of coffee cooled beside an open novel . |
| Action and scene swap | The young violinist stood beneath the theater lights, closed her eyes, and played a slow melody while the audience listened in complete silence. | The young magician stood beneath the theater lights, raised his hands, and released a cloud of silver confetti while the audience cheered in surprise. | The young violinist stood beneath the theater lights, raised his hands , and released a slow melody while confetti while the audience complete silence surprise . |
| Scientific domain swap | During the biology lab, the students carefully observed yeast cells under a microscope, recorded changes in their growth, and argued that temperature was affecting the culture. | During the astronomy workshop, the students carefully observed distant galaxies through a telescope, recorded changes in their brightness, and argued that dust was affecting the measurement. | During the astronomy lab , the students carefully observed distant galaxies under a telescope , recorded changes in their brightness , and argued that temperature was affecting the measurement . |
| Opposing policy claims | The city should expand protected bike lanes because safer streets reduce traffic injuries, encourage commuting without cars, and make neighborhoods easier to navigate. | The city should remove protected bike lanes because narrower roads slow emergency vehicles, frustrate local businesses, and make neighborhoods harder to navigate. | The city should expand protected bike lanes because safer roads slow emergency injuries , frustrate commuting without cars , make make harder to navigate . |
| Different domains, similar tone | After years of drought, the farmer knelt in the cracked field, pressed a handful of dry soil between his fingers, and wondered whether the next storm would arrive in time. | After years of training, the astronaut floated beside the station window, watched Earth turn silently below her, and wondered whether the next signal would arrive in time. | After years of training , the astronaut floated beside the station window , pressed Earth turn of dry her between his fingers , the next signal would arrive in time arrive in time. |
| Completely different texts | A legal memorandum explains that the contract cannot be enforced because the signature was forged, the deadline had expired, and the witness testimony contradicted the filing. | A fairy-tale paragraph describes a child following a blue firefly through an enchanted forest, discovering a hidden door in an oak tree, and hearing music from an invisible castle. | A legal memorandum explains paragraph describes contract cannot be enforced because firefly through forged enchanted forest , discovering a hidden door in witness testimony contradicted the filing. music from an invisible castle . |
| # Tokens | Curriculum Learning | BLEU ( ) | PPL ( ) | BERT ( ) |
|---|---|---|---|---|
| 256 | No | 0.014 | 10.4 | 0.785 |
| 256 | Yes | 0.087 | 267410 | 0.801 |
| 512 | Yes | 0.393 | 204.1 | 0.922 |
| Parameter | Value |
|---|---|
| Base Model Architecture | Gemma-3-270M |
| Input text length | 1024 tokens |
| Latent tokens | 256 |
| Latent layer | 11 (12 of 18) |
| LoRA | |
| Rank | 8 |
| Parameter | Value |
|---|---|
| Score network | |
| Hidden size layers heads | |
| FFN intermediate size | 2560 |
| Image conditioning | |
| Vision encoder | SigLIP SO400M patch14-384 (frozen, 428M params) |
| Encoder output | 729 patches 1152 dims |