
Gutentagツールを使用して、59000を超える電子書籍を含む大規模なオンラインデータベースであるProject Gutenberg Webサイトから必要な詩コーパスを構築しました。
Emolexは、単語と感情の間の関連性のクラウドソーシングデータセットです。詩の感情に基づいて詩のコーパスを分類するために使用されました。その感情に対応する詩を使用して、各感情の言語モデルが構築されました。
Huggingfaceは、自然言語処理におけるさまざまなオープンソースモデルを提供するAIコミュニティです。 OpenaiのGPT-2モデルは、大きな詩のコーパスで微調整されたHuggingfaceのモデルハブから使用されました。
Flaskは、Pythonで書かれたマイクロWebフレームワークです。これは、微調整されたGPT-2モデルと対話するために使用されるWebアプリの構築に使用されました。
アルゴリズムは、機械学習モデルを生産に展開するためのシンプルで高速な方法を提供するMLOPSツールです。モデルと対話するためにWeb APIを構築するために使用されました。ユーザーは、Flaskアプリを介してAPIリクエストをモデルに作成できます。
Herokuは、開発者がアプリケーションを完全にクラウドで構築、実行、および運用できるようにするサービス(PAAS)としてのプラットフォームです。 Webアプリを展開するために使用され、世界中の24時間365日のユーザーがアクセスできるようにしました。
このプロジェクトは、必要な感情を埋め込む瞬時に元の詩を自動的に構成できるツールを作成することを目的として開発されました。 OpenaiのGPT-2は、マスクされた自己触媒ヘッドを備えたトランスアーキテクチャであるため、Generation関連のタスクで非常にうまく機能することができるため、基本言語モデルとして選択されました。
データセットは、プロジェクトGutenberg Webサイトから取得されました。 Emolexツールは、詩のコーパスを8つの異なる感情クラスに分割するために使用されました - anger, anticipation, disgust, fear, joy, sadness, surprise and trust 。これらのカテゴリのいずれにも適合しなかった詩は、ニュートラルカテゴリに追加されました。
当初、GPT-2モデルは中立詩について訓練されました。これにより、一般的な詩を生成する「中立」モデルが与えられました。各感情のモデルは、対応する感情の詩に関するこの「ニュートラルな」モデルを微調整することによって作成されました。これらのモデルを構築するプロセス全体は、colabにあります。これらのモデルは、Huggingface Model Hubにもあります。
以下は、各感情のモデルへのリンクです。
アルゴリズムを使用して、これらのモデルと相互作用する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.