Skip to content

Latest commit

 

History

History
109 lines (85 loc) · 2.56 KB

README.md

File metadata and controls

109 lines (85 loc) · 2.56 KB

Seq2Seq with Pointer Network

This is a Seq2Seq model with Copy Mechanism and Coverage Mechanism.

Note: The project refers to atulkum and laihuiyuan

Datasets:

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 in utils/parser.py.

Alternatively, you can follow the steps from here, processing the data by yourself.

Models:

Other related models:

Pointer Networks

Pointing the Unknown Words

Incorporating Copying Mechanism in Sequence-to-Sequence Learning

Data Process

PYTHONPATH=. python dataprocess/process.py

Unit Test

  • 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

Main Process

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