KeyGen2Vec: Learning Document Embedding via Multi-label Keyword Generation in Question-Answering

Iftitahu Ni'mah, Samaneh Khoshrou, Vlado Menkovski, Mykola PechenizkiyarXiv 2023 · DOI

Abstract

Document embedding is a fundamental task in Natural Language Processing, often caught between the low cost of unsupervised methods and the high performance of supervised ones. We present KeyGen2Vec, a framework that leverages keyword generation as a proxy task. By training a Sequence-to-Sequence (Seq2Seq) model to predict sequences of keywords, KeyGen2Vec captures complex label dependencies, resulting in document embeddings that are significantly more robust and semantically rich than those from standard unsupervised or independent multi-label classification models. Our evaluation on community Question-Answering (cQA) datasets demonstrates that KeyGen2Vec bridges the gap between unsupervised and supervised learning, offering a scalable solution for high-quality document representation.

Introduction

In modern NLP, representing documents as high-dimensional vectors (embeddings) is essential for downstream tasks like clustering, retrieval, and recommendation. Currently, researchers face a trade-off: unsupervised methods like Doc2Vec are computationally efficient but often fail to capture domain-specific semantic structures. Conversely, supervised methods produce superior embeddings but require expensive, human-annotated topic labels.

KeyGen2Vec identifies a middle ground by utilizing keywords. Keywords are easier to obtain—often extracted automatically via TfIdf or TextRank—yet they contain rich semantic information. Unlike traditional models that treat keywords as independent labels, KeyGen2Vec treats keyword assignment as a generation task, forcing the model to learn the underlying relationships between tags.

Methodology: Keyword Generation as a Proxy Task

The core of the KeyGen2Vec framework is a standard Sequence-to-Sequence (Seq2Seq) architecture consisting of an Encoder and a Decoder with an Attention mechanism.

The KeyGen2Vec architecture uses a Seq2Seq model to map source text to a sequence of target keywords, extracting the document embedding from the bottleneck layer.

The Encoder and Decoder

  • The Encoder: A bidirectional Gated Recurrent Unit (GRU) processes the input document. The final hidden state is compressed into a context vector $c$, which serves as the document embedding.
  • The Decoder: Instead of a simple classification layer, the decoder is trained to "write out" a sequence of keywords.

Label Dependency

By employing a Seq2Seq approach with a Softmax output, the model implicitly learns label dependency. In a standard multi-label classifier, the model predicts each tag independently. In KeyGen2Vec, the probability of generating a subsequent keyword depends on the previous ones. This autoregressive nature forces the encoder to capture a deeper, more structured representation of the document's meaning to satisfy the decoder's sequential requirements.

Experimental Setup

The researchers evaluated KeyGen2Vec across three datasets of varying complexity:

  1. Toy Data: 1,448 clean sentence-keyword-topic pairs from WikiAnswer.
  2. 5-T Yahoo! cQA: A noisy dataset with 5 topic categories and 120 unique keywords.
  3. 11-T Yahoo! cQA: A complex version with 11 topics and 179 keywords.

Baselines included unsupervised models (Doc2Vec, S-BERT) and supervised multi-class classifiers trained on ground-truth topic labels.

Results and Discussion

KeyGen2Vec demonstrated significant improvements in embedding quality, particularly in noisy environments. The model outperformed standard multi-label classifiers by up to 14.7% across metrics such as Purity, Normalized Mutual Information (NMI), and F1-Score.

Visualizing the Latent Space

t-SNE projections highlight the stark difference between unsupervised representations and those learned via KeyGen2Vec. While unsupervised clusters often appear as overlapping "rainbows" of points, KeyGen2Vec produces distinct, separable clusters that align closely with human-defined topics.

t-SNE visualizations comparing (a) Doc2Vec clusters, which show significant overlap, with (c) supervised/KeyGen2Vec-style clusters that exhibit clear separation.

Robustness to Noise

Unsupervised models performed well on clean data but struggled with the informal language of cQA sites. KeyGen2Vec maintained high performance, suggesting that learning from "sub-structures" (keywords) naturally helps the model organize documents into broader "super-structures" (topics), even without explicit topic supervision.

Conclusion

KeyGen2Vec offers a powerful alternative for document embedding by reframing multi-label classification as a generation task. While the model's performance depends on keyword quality and involves higher computational overhead than simple classifiers, its ability to capture label dependencies makes it highly effective for noisy, real-world datasets. Future work may explore Transformer-based decoders to further enhance embedding expressiveness.

Summary updated

BibTeX
@misc{nimah2023keygen,
  author = {Iftitahu Ni'mah and Samaneh Khoshrou and Vlado Menkovski and Mykola Pechenizkiy},
  title = {{KeyGen2Vec: Learning Document Embedding via Multi-label Keyword Generation in Question-Answering}},
  year = {2023},
  eprint = {2310.19650},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.19650},
}
Figure