Skip to content

Seq2Seq model implemented with pytorch, using Copy Mechanism and Coverage Mechanism.

Notifications You must be signed in to change notification settings

wenhaofang/Seq2SeqPtr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Seq2Seq model implemented with pytorch, using Copy Mechanism and Coverage Mechanism.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages