X-Class

October 27, 2020 ยท View on GitHub

XClass: Text Classification with Extremely Weak Supervision

Our paper is available here.

Motivation

We propose the task: Text Classification with Extremely Weak Supervision, which is to classify documents to classes, with the plain class name as the only guidance.
Our method X-Class, breaks up this task into three modules

  • Class-oriented Document Representation
    • We estimate both the class representation (based on the given class names), and the document representation (guidede by the class representations).
  • Document-Class Alignment
    • We apply Gaussian Mixture Models to align the document representations into clusters. The GMM is initialized with a prior of every document assigned to its nearest class, and therefore, we know which cluster represents which class.
  • Text Classifier Training
    • We further select the confident document-class pairs from the previous step, and train a supervised text classifier (e.g. BERT) above it. This pipeline also illustrates our method.

Datasets

Since many previous weakly supervised text classification problem evaluated on different datasets, we try to collect a unified benchmark for this problem. We try our best to cover different text source (news & reviews), and different types of classes (topics, sentiment, and locations). We present some statistics of them in the table below (Imbalance is the ratio between the largest class size and the smalles class size).

AGNews20NewsNYT-SmallNYT-TopicNYT-LocationYelpDBpedia
Corpus DomainNewsNewsNewsNewsNewsReviewsWikipedia
Class CriterionTopicsTopicsTopicsTopicsLocationssentimentOntology
# of Classes455910214
# of Documents120,00017,87113,08131,99731,99738,000560,000
Imbalance1.02.0216.6527.0915.841.01.0

It is worth mentioning that NYT-Topic and NYT-Location is the same underlying corpus, but annotated with two different type of class. We defer some special handling of each dataset (e.g. mapping a class name phrase to a single word) to each specific dataset's folder.

Performance

ModelsAGNews20NewsNYT-SmallNYT-TopicNYT-LocationYelpDBpedia
Supervised93.99/93.9996.45/96.4297.95/95.4694.29/89.9095.99/94.9995.7/95.798.96/98.96
WeSTClass (+keywords)82.3/82.171.28/69.9091.2/83.768.26/57.0263.15/53.2281.6/81.681.1/ N/A
ConWea (+keywords)74.6/74.275.73/73.2695.23/90.7981.67/71.5485.31/83.8171.4/71.2N/A
LOTClass86.89/86.8273.78/72.5378.12/56.0567.11/43.5858.49/58.9687.75/87.6886.66/85.98
X-Class84.8/84.6581.36/80.696.67/92.9880.6/69.9290.5/89.8188.36/88.3291.33/91.14

Scripts

Environment

We used python=3.6, torch-1.4.0, cudatoolkit=10.0. Other packages can be installed via pip install -r requirements.txt.

Reproduce

  1. Follow the guidance in data/datasets and download the specific dataset.
  2. Create an environment, and make sure there is a gpu available. For the final BERT text classifer training step, around 16GB GPU memory is required. Reducing the batch size and sequence length can effectively reduce memory requirement.
  3. In the scripts folder, run ./run.sh GPU_INDEX DATASET_NAME, where GPU_INDEX is the index of the free gpu (e.g. 0), and DATASET_NAME is the name of the dataset in data/datasets folder (e.g. agnews).

New Dataset

Our method can be easily applied to new datasets, to do that:

  1. Place the new dataset in data/datasets folder, following the instructions.
  2. Follow the reproduce steps.

Intermediate Data

All our intermediate data are stored in data/intermediate_data/DATASET_NAME/, it contains information such as document representations, clusters, etc.

Citation

Please cite the following paper if you found our dataset or framework useful. Thanks!

Zihan Wang, Dheeraj Mekala, and Jingbo Shang. "X-Class: Text Classification with Extremely Weak Supervision." arXiv preprint arXiv:2010.12794 (2020).

@misc{wang2020xclass,
      title={X-Class: Text Classification with Extremely Weak Supervision}, 
      author={Zihan Wang and Dheeraj Mekala and Jingbo Shang},
      year={2020},
      eprint={2010.12794},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}