This is a Seq2Seq model with Copy Mechanism and Coverage Mechanism.
Note: The project refers to atulkum and laihuiyuan
Datasets:
dataset1
: CNN/DailyMail
You can download the dataset from here, and then run
dataprocess/process.py
to process data.The downloaded files should be placed in the specified directory.
It defaults to
datasources
, which can be modified inutils/parser.py
.Alternatively, you can follow the steps from here, processing the data by yourself.
Models:
Other related models:
Incorporating Copying Mechanism in Sequence-to-Sequence Learning
PYTHONPATH=. python dataprocess/process.py
- for loader
# loader(basic)
PYTHONPATH=. python loaders/loader1.py
# loader for copy mechanism
PYTHONPATH=. python loaders/loader1.py --is_copy
- for module
# module(basic)
PYTHONPATH=. python modules/module1.py
# module with copy mechanism
PYTHONPATH=. python modules/module1.py --is_copy
# module with coverage mechanism
PYTHONPATH=. python modules/module1.py --is_coverage
# module with copy mechanism and coverage mechanism
PYTHONPATH=. python modules/module1.py --is_copy --is_coverage
python main.py
You can change the config either in the command line or in the file utils/parser.py
Here are the examples:
# train
python main.py \
--name main \
--mode train \
--is_copy \
--is_coverage
# train (continue training at checkpoint)
python main.py \
--name main \
--mode train \
--ckpt result/save/main/10000.ckpt \
--is_copy \
--is_coverage
# valid
python main.py \
--name main \
--mode valid \
--ckpt result/save/main/10000.ckpt \
--is_copy \
--is_coverage
# test
python main.py \
--name main \
--mode test \
--ckpt result/save/main/10000.ckpt \
--is_copy \
--is_coverage