TenzinDJ / rnnpg

Code for Chinese Poetry Generation with Recurrent Neural Networks (EMNLP 2014)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chinese Poetry Generation with Recurrent Neural Networks

This project includes the code/model for the paper

Chinese Poetry Generation with Recurrent Neural Networks

@InProceedings{zhang-lapata:2014:EMNLP2014,
  author    = {Zhang, Xingxing  and  Lapata, Mirella},
  title     = {Chinese Poetry Generation with Recurrent Neural Networks},
  booktitle = {Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)},
  month     = {October},
  year      = {2014},
  address   = {Doha, Qatar},
  publisher = {Association for Computational Linguistics},
  pages     = {670--680},
  url       = {http://www.aclweb.org/anthology/D14-1074}
}

Acknowledgement

Our implementation is greatly inspired by Tomas Mikolov's rnnlm toolkit. We would like to thank Tomas Mikolov for making his code public available.

Dataset

Download the complete dataset from here

Dependencies

  • KenLM
  • G++ (4.4.7)
  • Java (1.8.0_51, 1.6 or 1.7 should also be fine)
  • Python (2.7)

Installation

  1. Install KenLM. Also remember to add kenlm to your LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/afs/inf.ed.ac.uk/user/s12/s1270921/usr/kenlm/lib
  1. Go to rnnpg folder and modify the Makefile (see below). Direct INCLUDES and LDFLAGS to your KenLM library. Also modify the Makefiles in rnnpg-decoder and rnnpg-generator.

  2. Make everything by ./INSTALL.sh

OUT_EXEC = rnnpg 
OBJS = $(patsubst %.cpp, %.o, $(wildcard *.cpp))

CC = g++
CPPFLAGS = -O3 -funroll-loops -ffast-math -finline-functions -Wall -Winline -pipe -DKENLM_MAX_ORDER=6

INCLUDES = -I/afs/inf.ed.ac.uk/user/s12/s1270921/usr/kenlm
LDFLAGS = -L/afs/inf.ed.ac.uk/user/s12/s1270921/usr/kenlm/lib -lkenlm

all : $(OUT_EXEC)
	rm *.o

$(OUT_EXEC) : $(OBJS)
	$(CC) -o $@ $^ $(INCLUDES) $(LDFLAGS)

%.o : %.cpp
	$(CC) $(CPPFLAGS) -c $< -o $@ $(INCLUDES)

clean:
	rm -f *.o
	rm -f $(OUT_EXEC)

Run Experiments

Download data/model from here

# move MISC.tar.bz2 to the root folder of this project, then
tar jxvf MISC.tar.bz2

1. Perplexity

cd experiments
./ppl.sh

2. Generation

cd experiments
./generation.sh

Enjoy the generated poems!

3. BLEU

Download from here

tar jxvf BLEU2-final.tar.bz2 
cd BLEU2-final
cd MERT_channel-1_RNN-CB-POS-LM-Eval-BLEU2
python showBLEU.py .

About

Code for Chinese Poetry Generation with Recurrent Neural Networks (EMNLP 2014)


Languages

Language:C++ 92.4%Language:Java 7.0%Language:Makefile 0.3%Language:Shell 0.2%Language:Python 0.2%