
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.