seq2seq-couplet

Play couplet with seq2seq model. 用深度学习对对联。

Github星跟踪图

This is a project use seq2seq model to play couplets (对对联)。 This project is written with Tensorflow. You can try the demo at https://ai.binwang.me/couplet.

Pre-requirements

  • Tensorflow
  • Python 3.6
  • Dataset

Dataset

You will need some data to run this program, the dataset can be downloaded from this project.

** Note: If you are using your own dataset, you need to add <s> and <\s> as the first two line into the vocabs file. **

Usage

Train

Open couplet.py and config the file locations and hyperparams. Then run python couplet.py to train the model. You can see the training loss and bleu score at Tensorbloard. You may need to re-config learning_rate when you find the loss stops descresing. Here is an example of the loss graph:

loss graph

If you stoped the training and want to continue to train it. You can set restore_model to True and use m.train(<epoches>, start=<start>), which start is the steps you've already run.

I've trained the model on a Nivida GTX-1080 GPU for about 4 days.

Run the trained model

Open server.py and config the vocab_file and model_dir params. Then run python server.py will start a web service that can play couplet.

Examples

Here are some examples generated by this model:, 上联, 下联, -----------------------------, --------------------, 殷勤怕负三春意, 潇洒难书一字愁, 如此清秋何吝酒, 这般明月不须钱, 天朗气清风和畅, 云蒸霞蔚日光辉, 梦里不知身是客, 醉时已觉酒为朋, 千秋月色君长看, 一夜风声我自怜

主要指标

概览
名称与所有者wb14123/seq2seq-couplet
主编程语言Python
编程语言Python (语言数: 2)
平台
许可证GNU Affero General Public License v3.0
所有者活动
创建于2018-02-24 02:44:52
推送于2024-07-25 02:24:32
最后一次提交2024-07-24 22:24:27
发布数0
用户参与
星数5.5k
关注者数125
派生数1.1k
提交数49
已启用问题?
问题数72
打开的问题数9
拉请求数0
打开的拉请求数2
关闭的拉请求数9
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?