HyperAI

This Spring Festival, We Recommend Three AI Tools to Help You Write Spring Festival Couplets

6 years ago
Headlines
Recommended List
Information
Dao Wei
特色图像

by Super Neuro

—-

Looking forward to it, looking forward to it, the Spring Festival is coming soon. Is there anything worth looking forward to during this year's Spring Festival? Why not do a good job at home before your parents urge you to get married or have children?

For example, if you want to write Spring Festival couplets for your home, or customize a few to give to relatives and friends, I have three robots here that can help you write couplets. Let’s learn about it.

AI that can write couplets

It's 2019 now, and I suddenly had the idea of finding an AI to write a couplet. With the help of the omnipotent Internet, I actually found three AI tools.

Microsoft's Couplet AI is a web product of Microsoft Research Asia. It can be traced back to the idea of automatic couplets in 2004.

After changes over the years, the latest version was launched in 2015, which can quickly complete the task of matching couplets.

And it will provide multiple options. If you are still not satisfied, it will give you several choices for each corresponding word. The most user-friendly thing is that you can embed your favorite words as needed.

This is a simple web couplet system, and it is said that this is a "practice project" of a hidden engineer.

It was released in October 2017 and was unexpectedly loved by the general public after its release, as it is said to be a source of happiness for the whole day. Some netizens even specially recorded a test video and uploaded it to bilibili.

The way to use it is also very simple. Give you the first line of the couplet, and it will immediately reply you with the second line. There is no room for negotiation, and it is clean and neat.

The author crawled millions of couplet data sets on the Internet and used the seq2seq model to hang the chain. In addition to the current tools, he also open-sourced his dataset and model on Github after completion.

It is a newcomer in the AI couplet community. It was created a week ago and is an AI model connected to a public account. The author created it after seeing a corpus of couplets and was eager to show his skills.

The method is to reply "Enter the content of the first couplet" in the background of the official account, and you will get the second couplet. Of course, there are times when it cannot match the second couplet.

If you forget to enter the first line, the background is a chat robot.

Is it a mule or a horse? Pull it out to make a couplet

In order to compare the effects of these three AI tools, we conducted several rounds of tests, and the output order was the results of Microsoft couplets, Wang Bin couplets, and AINLP couplets.

  • Round 1: Who is Fei-Fei Li?

In this round, except for the WeChat robot, which was a little difficult to read, the other two contestants were pretty normal.

  • Round 2: Wang Sicong eats hot dogs

As for the principal's behavior, the AINIP robot was unable to give an answer and directly started to act cute. Hahahaha, it seems that AI really doesn't know how rich Sicong is.

  • Round 3: Artificial intelligence writes Spring Festival couplets

This round, each of the three has its own characteristics. The "trigeminal nerve" given by Microsoft is going to make me laugh to death, AINLP's "miraculous craftsmanship" is also a bit confusing, and the second place "freedom" seems a bit bland.

  • Round 4: The first couplet: The setting sun and the solitary wild goose fly together

Wang Bin's answer to this classic sentence is too naughty. (In fact, Microsoft also provides a standard answer in the options)

  • Round 5: The first couplet: The sound of firecrackers bids farewell to the old year

Let’s get back to the topic and write Spring Festival couplets.

But judging from the results in the last round, it can be used to hang in front of the door.

How to train AI to write Spring Festival couplets?

After looking at these gadgets, we can basically see that in traditional Chinese culture, not only ancient poems, couplets, but also language units such as antithetical couplets have extremely strong regularities, which are very suitable for learning through machines and can be easily automated.

  1. Using the Encoder-Decoder model

The Encoder-Decoder framework can be seen as a research model in the field of text processing, with extremely wide application scenarios.

Abstract Encoder-Decoder Framework

The Encoder-Decoder framework can be understood intuitively as follows: it can be regarded as a general processing model suitable for processing one sentence (or paragraph) to generate another sentence (or paragraph). For a sentence pair, the goal is to generate a target sentence Y through the Encoder-Decoder framework given an input sentence X. X and Y can be in the same language or in two different languages. X and Y are composed of their own word sequences:

As the name implies, Encoder encodes the input sentence X and converts the input sentence into an intermediate semantic representation C through nonlinear transformation:

For the decoder, its task is to generate the word yi to be generated at time i based on the intermediate semantic representation C of sentence X and the previously generated historical information y1, y2….yi-1

Each yi is generated in this way in turn, so it looks like the entire system generates the target sentence Y based on the input sentence X.

This scenario is a typical application problem of the Encoder-Decoder framework. All you need to do is configure the specific model of the Encoder-Decoder framework, for example, both the Encoder and the Decoder use the RNN model.

Encoder-Decoder generates the lower link

You just need to find a large amount of couplet data to train this model, then you can use this model, input the first couplet, and the machine will automatically generate the second couplet.

The Encoder-Decoder framework plus Attention should significantly improve the quality of the second line. The reason is that it requires strict parallelism. Therefore, when generating a certain word in the second line, it is undoubtedly very important to find the corresponding word in the first line as the key reference information for generation.

For example, when the Attention model sees the character "三" in the first couplet, it will focus on the character "一" in the second couplet when generating the corresponding character. It should know that the corresponding character should be a numeric Chinese character.

Attention Model

Using Encoder-Decoder to do this, the antithesis between Chinese characters should be well learned, but how to ensure that the semantics of the generated second couplet are consistent is not necessarily a good solution. What does this mean? It means that the machine may see the first couplet "风云三尺剑" and it is very likely to match the following content: "雨风万丈刀". Looking at each character individually, the antithesis is very neat, but as a whole, the semantics do not seem so harmonious. (Note: In fact, if you really match this second couplet, it is actually quite heroic, right? This is actually related to the fact that people will combine consecutive characters into a reasonable context through imagination.)

Essentially, Encoder-Decoder is able to learn the language model during the decoding phase, and it is obvious that the introduction of the language model is very helpful for generating the readability and language consistency of the second line.

However, if the training data is not so large, I believe that by using a large number of ancient poems to train a poetry language model, in the Decoder generation stage, many possible candidate Chinese characters are generated at each time node t, and then using this language model + Beam Search, the generated couplets should be able to ensure a certain semantic consistency.

When generating couplets, there is actually the issue of the prosody of the Chinese characters in the upper and lower couplets, which can also be screened and filtered as a post-processing step similar to the language model.

  • 2. Use RNN to complete

Use RNN to build a language model of ancient poetry, and then automatically generate the first couplet through this RNN language model.

Figure fully automatically generates couplets

In addition, there is still a small problem left for couplets, that is, how to generate the horizontal scroll of the couplet. Because generally couplets need to be accompanied by a horizontal scroll to summarize the main themes of the upper and lower couplets.

The idea is actually similar. The upper and lower couplets can be regarded as a whole as the input of the Encoder, and the Decoder can be used to generate the horizontal banner. This is similar to the idea of using Encoder-Decoder+Attention for summarization.

References:

  • 1.https://blog.csdn.net/malefactor/article/details/51124732
  • "Using the Encoder-Decoder model to automatically generate couplets" by Zhang Junlin
  • 2.https://mp.weixin.qq.com/s/ettmrvz0SMpdBd5HU1xhnw
  • "The First Artificial Intelligence Couplet Competition" by WeChat Official Account: Xiang Zi Ran
  • 3.https://duilian.msra.cn/app/couplet.aspx
  • Microsoft Couplet Tool
  • 4.https://ai.binwang.me/couplet/
  • Wang Bin Automatic Couplet Matching System
  • 5. WeChat public account couplet tool: AINLP