How to Utilize Fast Abstractive Summarization with Reinforce-Selected Sentence Rewriting

Sep 24, 2020 | Data Science

Welcome to the world of fast abstractive summarization! In this guide, we will walk you through the steps to utilize the code from the ACL 2018 paper on Fast Abstractive Summarization. Whether you’re looking to evaluate generated summaries, decode from a pretrained model, or even train your own model, we’ve got you covered.

Getting Started: Dependencies

Before you begin, make sure you have the necessary dependencies installed. You will need:

You can use pip or conda to install these packages, and the code has been tested on Linux operating systems.

Evaluating the Output Summaries

To evaluate the summaries, start by downloading the output summaries here. Here’s how you can assess the ROUGE and METEOR scores:

  1. Download and set up the official ROUGE and METEOR packages.
  2. Install pyrouge using the command pip install pyrouge.
  3. Since the original ROUGE website is down, you can find an alternative here.
  4. Set the environment variables for ROUGE and METEOR:
    • For ROUGE: export ROUGE=[path_to_rouge_directory]
    • For METEOR: export METEOR=[path_to_meteor_jar]
  5. Run the command: python eval_acl.py --[rouge|meteor] --decode_dir=[path_to_decoded_files]

Decoding Summaries from the Pretrained Model

To decode summaries from a pretrained model, download the pretrained models here. You will also need a preprocessed version of the CNN Daily Mail dataset. Follow the instructions here for this. Here’s how to proceed:

  1. Set the path to your data files: export DATA=[path_to_decompressed_data]
  2. Choose one of the pretrained models to reproduce results.
  3. Decode using the following command:

    python decode_full_model.py --path=[path_to_save_decoded_files] --model_dir=[path_to_pretrained] --beam=[beam_size] [--test|--val]
  4. Depending on the beam size selected, different results can be obtained

Training Your Own Models

Ready to create your own models? Here’s a step-by-step guide:

  1. Download and preprocess the CNN Daily Mail dataset as mentioned earlier.
  2. Set the path of data files: export DATA=[path_to_decompressed_data]
  3. Pretrain a Word2Vec embedding:
    python train_word2vec.py --path=[path_to_word2vec]
  4. Create pseudo-labels:
    python make_extraction_labels.py
  5. Train both the abstractor and extractor:
    • python train_abstractor.py --path=[path_to_abstractor_model] --w2v=[path_to_word2vec/word2vec.128d.226k.bin]
    • python train_extractor_ml.py --path=[path_to_extractor_model] --w2v=[path_to_word2vec/word2vec.128d.226k.bin]
  6. Finally, train the full RL model:
    python train_full_rl.py --path=[path_to_save_model] --abs_dir=[path_to_abstractor_model] --ext_dir=[path_to_extractor_model]

Troubleshooting

If you encounter any issues during the process, consider the following troubleshooting tips:

  • Ensure all dependencies are correctly installed and compatible.
  • Check the paths you’ve set for the ROUGE and METEOR packages to ensure they are correct.
  • If using GPU, verify your CUDA installation to ensure it is configured properly.
  • If results are not as expected, consider retraining the model with updated hyperparameters.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Wrap Up

Now that you have the tools and knowledge to utilize fast abstractive summarization, you can embark on summarizing texts efficiently. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox