Disentangling semantics in language through VAEs and a certain architectural choice

Ghazi Felhi, Joseph Le Roux, Djamé SeddaharXiv 2020

Abstract: We present an unsupervised method to obtain disentangled representations of sentences that single out semantic content. Using modified Transformers as building blocks, we train a Variational Autoencoder to translate the sentence to a fixed number of hierarchically structured latent variables. We study the influence of each latent variable in generation on the dependency structure of sentences, and on the predicate structure it yields when passed through an Open Information Extraction model. Our model could separate verbs, subjects, direct objects, and prepositional objects into latent variables we identified. We show that varying the corresponding latent variables results in varying these elements in sentences, and that swapping them between couples of sentences leads to the expected partial semantic swap.

Introduction

In deep learning, text is typically represented as a single, dense vector. While effective for many tasks, these representations are often "entangled," meaning semantic components like the subject, action, and location are inseparable within the vector space. This lack of transparency makes it difficult to manipulate specific semantic elements without affecting the entire sentence.

Disentanglement aims to separate these factors of variation. While successful in computer vision, it remains a significant challenge in Natural Language Processing (NLP) due to the discrete nature of language and complex syntax. Most existing methods rely on supervised labels; this work proposes an unsupervised approach to decompose sentences into disentangled latent variables corresponding to specific semantic roles.

Methodology

The proposed framework utilizes a Variational Autoencoder (VAE) with several architectural innovations designed to enforce disentanglement:

  1. Hierarchical Latent Variables: Latent variables ($z_1, z_2, z_3$) are arranged in a tree-like hierarchy to capture different levels of abstraction.
  2. Transformer-based "Slot" Encoding: The model uses a novel Transformer encoder-decoder architecture. The encoder maps a sentence to a fixed number of latent variables ($N=48$). This is achieved by feeding learnable vectors into the decoder portion of the encoder to act as placeholders for specific semantic "slots."
  3. Latent Variable Identifier: To distinguish between the 48 variables, each latent vector is concatenated with a unique, trainable ID vector before decoding.
  4. Inductive Bias and Objective: By leveraging diagonal Gaussians in the posterior, the model is pressured to make latent dimensions independent. To combat "posterior collapse," a modified Evidence Lower Bound (ELBO) with a mobile threshold is used to ensure information is distributed across the hierarchy.
The Transformer-based encoder architecture maps input sentences into specific latent variable slots using learnable embeddings and cross-attention.

Results and Analysis

The model was trained on the SNLI (Stanford Natural Language Inference) dataset, consisting of short, homogeneous sentences. Using Open Information Extraction (OpenIE) and dependency parsing, the researchers quantitatively verified the semantic roles assigned to specific latent variables (LVs).

Key identified variables include:

  • LV 10 (Root/Verb): Primarily controls the main verb and overall sentence structure.
  • LV 30 (Subject): Specifically influences nominal subjects (active or passive) and auxiliaries.
  • LV 35 (Direct Object): Specializes in the content of direct objects and conjunctions.
  • LV 43 (Prepositional Object): Controls content within prepositional phrases and adverbial modifiers.
Quantitative analysis showing the influence of specific latent variables (labeled by ID) on various dependency roles within generated sentences.

Qualitative experiments demonstrate the power of this disentanglement. For instance, by varying only LV 30 in the sentence "a girl is holding a ball," the model generates "a man is holding a ball" or "a kid is holding a ball," keeping the action and object perfectly intact while only altering the subject.

Conclusion

This research demonstrates that architectural choices in VAEs can lead to the emergent discovery of linguistic structures without explicit supervision. While the model currently struggles with posterior collapse and is limited to relatively simple sentence structures, it provides a promising path toward more interpretable and controllable language models. Future work will explore handling more complex, nested dependencies and refining the separation of syntax from semantics.

Summary updated

BibTeX
@misc{felhi2020disentangling,
  author = {Ghazi Felhi and Joseph Le Roux and Djamé Seddah},
  title = {{Disentangling semantics in language through VAEs and a certain architectural choice}},
  year = {2020},
  eprint = {2012.13031},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2012.13031},
}
Figure