Incorporating Hierarchy into Text Encoder: a Contrastive Learning Approach for Hierarchical Text Classification

Zihan Wang, Peiyi Wang, Lianzhe Huang, Xin Sun, Houfeng Wang
3/8/2022
cs.CL
contrastive-ssl

Official code: wzh9969/contrastive-htc (141 stars, Python, MIT, last commit 2024-05-14).

Abstract

Hierarchical text classification is a challenging subtask of multi-label classification due to its complex label hierarchy. Existing methods encode text and label hierarchy separately and mix their representations for classification, where the hierarchy remains unchanged for all input text.

Show full abstract

Instead of modeling them separately, in this work, we propose Hierarchy-guided Contrastive Learning (HGCLR) to directly embed the hierarchy into a text encoder. During training, HGCLR constructs positive samples for input text under the guidance of the label hierarchy. By pulling together the input text and its positive sample, the text encoder can learn to generate the hierarchy-aware text representation independently. Therefore, after training, the HGCLR enhanced text encoder can dispense with the redundant hierarchy. Extensive experiments on three benchmark datasets verify the effectiveness of HGCLR.

View on arXivView PDF

Code Implementations(1)

MIT

This repository implements a contrastive learning model for hierarchical text classification. This work has been accepted as the long paper "Incorporating Hierarchy into Text Encoder: a Contrastive Learning Approach for Hierarchical Text Classification" in ACL 2022.

14133PythonMar 4, 20222 years agoMIT

Similar Papers

Cite this paper

@article{wang2022incorporating,
  title  = {Incorporating Hierarchy into Text Encoder: a Contrastive Learning Approach for Hierarchical Text Classification},
  author = {Zihan Wang and Peiyi Wang and Lianzhe Huang and Xin Sun and Houfeng Wang},
  year   = {2022},
  eprint = {2203.03825},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.03825}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.03825.svg)](https://codeofpaper.com/paper/2203.03825)

Discussion