areejokaili / topic_labelling

22 stars 6 forks source link

Automatic Generation of Topic labels

This repository contains the source code and data used for the paper:

Automatic Generation of Topic Labels (2020) Areej Alokaili, Nikolaos Aletras and Mark Stevenson in Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval(SIGIR ’20), July 25–30, 2020, Virtual Event, China. https://doi.org/10.1145/3397271.3401185 Pre-print

(A) Install required libraries

Python 3.6.9 is used.

  1. TensorFlow V2
  2. NumPy
  3. scikit-learn
  4. ipykernel

below libraries needed for evaluation only. You can skip if you want to do different evaluation metric other than BERTScore

  1. sentencepiece
  2. transformers
  3. bert-score
  4. matplotlib
  5. pandas

use pip install -r requirements.txt to install all needed libraries

(B) Training

To run the model (data are processed and ready, only training is needed):

(C) Inference (generate titles/labels)

  1. Generate TITLES for a subset of wikipedia articles (1000 articles)

    python test_tf.py -m 'bigru_bahdanau_attention' -s 1000 -d 'wiki_tfidf' --load 'NAME_OF_CHECKPOINT'

    *replace NAME_OF_CHECKPOINT with the name of your checkpoint. For example, python test_tf.py -d 'wiki_tfidf' -m 'bigru_bahdanau_attention' --load bigru_bahdanau_attention_e_1_valloss2.19-2

  2. Generate LABELS for bhatia_topics python test_tf.py -m 'bigru_bahdanau_attention' -s 1000 -d 'wiki_tfidf' --load 'NAME_OF_CHECKPOINT' -te 'bhatia_topics'

  3. Generate LABELS for bhatia_topics_tfidf python test_tf.py -m 'bigru_bahdanau_attention' -s 1000 -d 'wiki_tfidf' --load 'NAME_OF_CHECKPOINT' -te 'bhatia_topics_tfidf'

  4. Predictions, golds, and topics will be stored at results/data_name/ as

    • [model_name]_pred.out
    • [model_name]_gold.out
    • [model_name]_topics.out.

      (D) Evaluation

  5. To measure the similarity between predicted and gold labels, python compute_bertscore.py -g results/path_to_gold_file.out -p results/path_to_predict_file.out

  6. Output includes precision (P), recall (R) and f-score (F).

Repository hierarchy