• Stars
    star
    5,488
  • Rank 7,414 (Top 0.2 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created over 6 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 Nvidia 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.

Or build the Docker image with Dockerfile and run it with Docker. Remember to mount the correct model file paths into the Docker container.

Examples

Here are some examples generated by this model:

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

More Repositories

1

couplet-dataset

Dataset for couplets. 70万条对联数据库。
Python
709
star
2

del_gmail

Python script to delete mails from Gmail that match a keyword
Python
25
star
3

bard

A Java web framework that is easy to use, easy to extend.
Java
21
star
4

reddit-desktop

Reddit client for big screen.
JavaScript
15
star
5

tax_counter

Count individual income tax in China. 2019个人所得税计算器。
Python
15
star
6

scala2grpc

A SBT plugin to make it non-invasive to use gRPC with Scala.
Scala
10
star
7

twitter2mastodon

A tool to import posts from Twitter to Mastodon
Python
10
star
8

smart-ua-switcher

A chrome extension to set User-Agent based on URL rules.
JavaScript
10
star
9

redis_lease

Redis get/set/del with lease
Shell
8
star
10

linkgame

Link game written with create.js http://linkgame.binwang.me/
CoffeeScript
4
star
11

erlang_module

Popular erlang modules. http://erlang-modules.binwang.me/
CoffeeScript
4
star
12

fuckgfw

Shadowsocks config for OpenWRT
Shell
4
star
13

web_benchmark

A simple web service aims to be simple and fast.
Scala
4
star
14

wb14123.github.com

My blog
HTML
4
star
15

logical_foundations_exercise

The exercise for Logicial Foundations
HTML
3
star
16

blog

My blog source code
HTML
3
star
17

tla-cache

Use TLA+ to verify cache consistency for different algorithms
TLA
3
star
18

k3s-vm-cluster

3
star
19

redis-benchmark

Benchmark for rediscala
Scala
3
star
20

eroop

Experiment on combine OOP with Erlang's actor model
Elixir
2
star
21

gitlab-ci-multi-runner-docker

gitlab-ci-multi-runner with docker client built in. https://gitlab.com/gitlab-org/gitlab-ci-multi-runner
Go
2
star
22

tensorflow

Computation using data flow graphs for scalable machine learning
C++
1
star
23

matnn

learn neural network with matlab
MATLAB
1
star
24

docker-shadowsocks

Docker container for shadowsocks
1
star
25

bard-doc-ui

Web UI for documents that auto generated by Bard.
JavaScript
1
star
26

scala-stream-demo

Scala
1
star
27

Mr.White

A robot.
Python
1
star
28

auto_tsung

Auto deploy tsung environment to many machines
Shell
1
star