Introduction
Large Language Models (LLMs) have revolutionized text generation, yet precise control over their output remains a challenge, often relegated to the trial-and-error of prompt engineering. While Variational Autoencoders (VAEs) offer a structured approach by mapping sentences into a continuous, navigable latent space, previous implementations relied on older architectures like BERT and GPT-2. LlaMaVAE bridges this gap by integrating the Llama-7B model into a VAE framework, providing a "map" for the semantic wilderness of language generation.
Architecture: The Sandwich Model
LlaMaVAE employs a "sandwich" architecture designed to distill the semantic essence of a sentence into a low-dimensional vector ($z$).
The system consists of three primary components:
- Encoder: A pre-trained sentenceT5 (sT5) model that processes input text into a latent distribution.
- Bottleneck: A continuous latent space ($z$) representing the core meaning of the sentence.
- Decoder: A Llama-7B model. To ensure the decoder adheres to the latent representation, the authors implement a "memory" mechanism where the latent vector is transformed into additional keys and values for Llama’s self-attention layers.
Conditional Guidance via Invertibility
A key innovation of this work is the Invertible CVAE framework, which addresses tasks requiring tight coupling between specific inputs and generated text, such as definition modeling.
By utilizing Invertible Neural Networks (INNs), the model can map word embeddings to the sentence latent space and back again. Because INNs are mathematically bijective, they minimize information loss during these transitions. This allows for a dual-track approach: "Track 1" for definition modeling (generating text from embeddings) and "Track 2" for the reversed dictionary task (mapping definitions back to word embeddings).
Experimental Evaluation
The model was rigorously tested across several benchmarks, including Semantic Textual Similarity (STS), the SentEval toolkit for linguistic probing, and the CODWOE shared task for definition modeling.
Key Results
- Semantic Consistency: LlaMaVAE achieved a Spearman correlation of 62.50 on the STS-B benchmark, significantly outperforming the previous state-of-the-art Optimus (50.61).
- Definition Modeling: In the CODWOE task, the Invertible CVAE framework achieved a Sense-BLEU of 0.1935 on the Electra dataset—nearly six times the performance of the baseline (0.0315).
- Geometric Properties: Interpolation experiments demonstrated that LlaMaVAE’s latent space is more "elastic." Moving between two distinct sentence vectors produces intermediate sentences that are semantically coherent and logically transitional.
Conclusion
LlaMaVAE demonstrates that modern LLMs not only generate higher-quality text but also create superior semantic clusters when used within a VAE framework. By decoupling the decoder’s dependency on specific inputs through invertible mappings, the authors provide a robust method for steered generation. Future work will explore scaling these benefits to larger models and applying the controllable latent space to high-precision tasks like automated fact-checking.
Summary updated