Skip to content
 
 

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rl-for-topic-models

Reinforcement Learning for Topic Models

Code accompanying the paper Reinforcement Learning for Topic Models in Findings of the Association for Computational Linguistics: ACL 2023.

Table of Contents

INSTALL

conda create -n rl-for-topic-models python=3.9
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
pip install -r requirements.txt

TRAINING

  • update the configs in model/decoder_network.py and trainer/config.py with your training settings.
  • run python train.py /path/to/data/pickle
    • add --test if your data has a test subset

DATA

Pre-training is a Hot Topic

Tweets 2011

Stack Overflow

Google News

Wiki 20k

  • get data from https://github.com/vinid/data
  • put dbpedia_sample_abstract_20k_unprep.txt in the data/raw/texts folder
  • run python data/dataset.py wiki20k

20 Newsgroups

  • run python data/dataset.py 20ng

Other Comparison Papers

New York Times

Contrastive Learning for Neural Topic Model

Benchmarking Neural Topic Models

Our Experiments

20 Newsgroups

  • run python data/dataset.py 20ng --mwl 3

Custom Data

  • run python data/dataset.py custom --train_file /path/to/train/file --save_name /path/to/save/name
    • other arguments can be found at the bottom of data/dataset.py

EXPERIMENTS

  • update search_dict in run_experiments.py with your hyperparameter search values.
  • run python run_experiments.py experiment_name num_seeds --meta_seed meta_seed
    • meta seed will be randomly chosen from random.randint(0, 2 ** 32) if not included as argument

EVALUATIONS

Compute Metrics

  • run python -m evals.compute_metrics topk num_experiments num_seeds /path/to/data/pickle /path/to/experiment

Dataset Statistics

  • run python -m evals.dataset_stats /path/to/data/pickle

Dropout Sweep

  • run experiment with hyperparameters from paper
  • run python -m evals.dropout_sweep /path/to/dropout/experiment

Benchmarking Neural Topic Models Plot

  • run empirical_studies/examine_models.py from https://github.com/smutahoang/ntm with top_ks = [10]
  • move the run.*.pkl files into the ntm_runs folder
  • run experiments with hyperparameters from paper
    • call them ntm_20news_sweep, ntm_snippets_sweep, ntm_w2e_sweep, and ntm_w2e_text_sweep
  • run python -m evals.plot_ntm_results

Saving Topic Words

  • run python -m evals.save_topic_words topk /path/to/data/pickle /path/to/experiment/experiment_num/seeds/seed_num/seed_num_plotting_arrays.pkl

About

Reinforcement Learning for Topic Models

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages