Welcome to this guide where we uncover the magic behind the implementation of a Unified Model for Extractive and Abstractive Summarization using Inconsistency Loss. There’s no need to worry if this seems complex; we will break this down into manageable steps. Let’s dive in!
Prerequisites
Before jumping into the code, make sure you have the following requirements ready:
- Python 2.7
- TensorFlow 1.1.0
- pyrouge (for evaluation)
- tqdm
- Stanford CoreNLP 3.7.0 (for data preprocessing)
- NLTK (for data preprocessing)
Note: You can download Stanford CoreNLP 3.7.0 here.
Note: To use ROUGE evaluation, download the ROUGE-1.5.5 package here. Follow the instructions from here to install pyrouge and set the ROUGE path to your absolute path of ROUGE-1.5.5 directory.
Error Handling
If you encounter the error message “Cannot open exception db file for reading: path to ROUGE-1.5.5/data/WordNet-2.0.exc.db” when using pyrouge, you can find a solution here.
Data Preparation: CNNDaily Mail Dataset
The preparation for the CNNDaily Mail dataset is essential. The code to generate the dataset can be found in the data folder. We’ve modified the preprocessing code from this repository: GitHub.
Utilize our preprocessing scripts make_datafiles.py
and rouge_not_a_wrapper.py
. Follow the instructions of Option 2 in this repository to obtain the necessary preprocessed data.
Training the Model
Next, we’ll be training the models step by step. We will be using the sample scripts located in the scripts folder. Here’s how you can proceed:
Pretrain the Extractor
Run the script selector.sh
. The trained models will be saved in logselector/$EXP_NAME
directory.
Pretrain the Abstracter
Execute rewriter.sh
. The trained models will be saved in logrewriter/$EXP_NAME
directory.
End-to-End Training
To train the unified model, set the path of pretrained extractor and abstractor to SELECTOR_PATH
and REWRITER_PATH
in the send2end.sh
script. Models will be saved in logend2end/$EXP_NAME
directory.
Note: In our paper, we used the best extractor model from the validation set as the pretrained extractor during end-to-end training.
Evaluation Process
To evaluate the model during training, change the MODE
in the script to eval
and run it simultaneously with the train script. This process will test the latest training model:
- Switch between evaluation of loss or ROUGE scores using
EVAL_METHOD
. - For ROUGE evaluation, choose between greedy search or beam search with
DECODE_METHOD
.
We highly recommend you use the greedy search for concurrent ROUGE evaluation since it’s significantly faster—taking about 30 minutes compared to 7 hours for beam search on the CNNDaily Mail test set.
Expected Results
By following the provided scripts, your outcomes should be around these figures:
- Extractor: ROUGE-1 recall 73.5, ROUGE-2 recall 35.6, ROUGE-L recall 68.6
- Abstracter: ROUGE-1 F-1 score 45.4, ROUGE-2 F-1 score 21.8, ROUGE-L F-1 score 42.1
- Unified Model: ROUGE-1 F-1 score 40.68, ROUGE-2 F-1 score 17.97, ROUGE-L F-1 score 37.13
Troubleshooting
If you run into any hiccups during this process, consider these troubleshooting tips:
- Ensure that all dependencies are installed correctly and versions are compatible.
- Double-check your file paths in the scripts if the training or evaluation steps do not run as expected.
- Review error messages thoroughly; they often guide you toward the solution.
- For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
By following the steps outlined above, you will successfully implement a unified model for extractive and abstractive summarization using the Inconsistency Loss approach. Remember, every great programmer faces challenges; persistence is key.
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.