
Gutentag工具用于从项目Gutenberg网站上构建所需的诗歌语料库,该网站是一个庞大的在线数据库,其中包含超过59000个电子书。
Emolex是单词和情感之间关联的众包数据集。它被用来根据诗歌的情感对诗歌语料库进行分类。通过使用与该情感相对应的诗,为每种情感构建了语言模型。
HuggingFace是一个AI社区,可在自然语言处理中提供各种开源模型。 OpenAI的GPT-2模型来自Huggingface的模型中心,该模型中心在大型诗歌语料库中进行了微调。
烧瓶是用Python编写的微型网络框架。它用于构建一个用于与微型GPT-2模型交互的Web应用程序。
算法是一种MLOPS工具,它提供了一种简单,更快的方法,可以将机器学习模型部署到生产中。它用于构建Web API与模型进行交互。用户可以通过烧瓶应用程序向模型提出API请求。
Heroku是一个平台作为服务(PAA),使开发人员能够在云中完全构建,运行和操作应用程序。它用于部署Web应用程序,以便世界各地24x7的用户可以访问它。
开发该项目的目的是创建一个可以自动在即时嵌入所需情感的立即构成原始诗歌的工具。 OpenAI的GPT-2被选为基本语言模型,因为它具有带有掩盖的自我发挥头的变压器体系结构,使其能够在与生成相关的任务方面表现出色。
数据集是从Gutenberg项目网站获得的。 Emolex工具用于将诗歌语料库分为8种不同的情感阶级 - anger, anticipation, disgust, fear, joy, sadness, surprise and trust 。不适合任何这些类别的诗被添加到中性类别中。
最初,GPT-2模型接受了中性诗的训练。这给了我们“中性”模型,以产生任何一般诗。每种情绪的模型是通过对相应情感诗的“中性”模型进行微调来创建的。建立这些模型的整个过程可以在Colab中找到。这些模型也可以在HuggingFace模型中心中找到。
以下是指向每种情感模型的链接:
算法用于构建与这些模型相互作用的API。创建了一个烧瓶应用程序,以允许用户向算法发送API请求并接收生成的诗。该应用程序被部署并使用Heroku实时。
?AutoCompose
┣ data --> Contains entire poetry corpus as well as poem collections of each emotion stored in json format
┣ models --> Contains language models fine-tuned for each emotion
┃ ┣ anger
┃ ┣ anger2
┃ ┣ anticipation2
┃ ┣ disgust2
┃ ┣ fear
┃ ┣ fear2
┃ ┣ joy
┃ ┣ joy2
┃ ┣ neutral
┃ ┣ sadness2
┃ ┣ surprise2
┃ ┣ trust2
┣ notebooks --> Contains .ipynb files used to work with dataset and train the model
┣ outputs --> Contains 25 poems generated by the model for each emotion
┣ readme-assets --> Contains images and gifs used in readme file
┣ src --> Contains flask app and other supporting python files
┃ ┣ static
┃ ┃ ┗ images
┃ ┣ templates
愤怒的想法
I am not jealous; but this does vex
My heart so full of misery that I cannot stop
From angry thoughts. This brings me relief,
And a painful torment; and I
Am content to part from thee alone.
神在神秘中
Thence down the river to the mountain-side
I travelled with my boats and my oarsmen,
To seek a haven near the southern cape
Where dwelt some mighty god in mystery,
Unknowing I wandered therefrom, so
Unconscious I lay, and rested there.
雏菊和污秽
The little pool, by the house-wall,
Is covered with daisies and filth;
The fountains are withered and dim,
And the lizards writhe in rags.
我在遥远的角落看到你
I see thee in a far corner,
With a stealthy stride, and a trembling soul
I know thou, Dear, who should'st not fear
That I should come near thee!
I know thee.
绅士
Thy soul has joy, and thy soul is free,
And all the things it loves can live
In thy love for me and thee!
O gentle-throat, why sing so low,
Or do thy music too loudly?
Whence are all thy numbers fit?
If that thy mind is fix'd upon one,
It joys not to hear thee speak.
月亮
He took them home, and soon set them down
In a chest at the door of his room,
And asked them if they knew
What the moon was about.
亲爱的心
For you, dear heart, so lone and worn and weary,
Hear me, and the silence dies,
That still I think you must come near me,
And not so be blest.
大自然自己的
He is a wild magician,
Who takes up the air and vanishes
As though his name were Nature's own,
And that it were Nature's own prompting,
That he should leave school in such a way.
伪装的少女
He sees the aged damsels in disguise,
And how the princely damsels are dressed;
The queen of Sariola, as she stands,
Is clad in rich embroidery;
And every thing that she does wear
Is a royal dame in finest form,
And a queen in fairest posture too.