見出し画像

【生成AI|LLaMA v2】太宰治の文体で500文字の文章がほしい。テーマは「花の美しさについて」

プログラム


from llama_cpp import Llama

# プロンプトを記入
prompt = """
太宰治(osamu dazai)の文体で、500文字の文章がほしい。テーマは「花の美しさについて」
"""

# ダウンロードしたModelをセット
llm = Llama(model_path="./llama-2-7b-chat.ggmlv3.q8_0.bin")

# 生成実行
output = llm(
    prompt,max_tokens=1000,stop=["System:", "User:", "Assistant:"],echo=True,
)

量子化でのモデル圧縮済みの「llama_cpp」本家がスペック不足で動かん!!

▽参考(わかりやすい解説)

出力の翻訳

太宰治(太宰治)の文体で、500文字の文章がほしい、テーマは「花の美しさについて」

パターン1

太宰治(1909-1948)は日本の小説家、エッセイスト、哲学者である。

太宰治流の「花の美しさ」を500字で紹介しよう。

花は私たちと同じように咲いては散り、その優美さと美しさで私たちに感動を与え続ける。

桜の繊細な花びら、ヒマワリの鮮やかな色、バラの魅惑的な香り......それぞれの花には、私たちの魂に語りかける特別な魅力がある。

繊細な美しさなのか、はかなさなのか。

人生のはかなさと、一瞬一瞬を大切にすることの大切さを思い出させてくれるのかもしれない。

花は夏の日のそよ風のようなもので、私たちに喜びと安らぎを与えてくれる。土や雨を押し分け、太陽や空に手を伸ばし、私たち自身の強さと持久力を思い出させてくれる。

曲がっても折れない花の茎のように、私たちも逆境の中に美を見出し、困難を乗り越えて再び花を咲かせることができる。

結局のところ、花は社会的な生き物なのだ。

互いに支えあい、栄養を与えあいながら、共に咲き、成長していく。

そして私たちもまた、他者とつながり、支え合い、高め合い、美と思いやりに満ちた世界を築くことを学ぶことができる

パターン2

花びらは繊細な翼のように広がり、色彩は空を舞う。
朝露を浴びれば優雅に咲き誇り、夕陽を浴びれば温もりと活力に輝く。
あなたの美しさは、つかの間のものではなく、喜びと驚きに満ちた終わりのない旅なのです。

愛と優しさが頂点に君臨する、あらゆることが可能な世界を夢見るよう私たちを鼓舞する。

あなたの花びらは、愛する人の手の優しさを思い起こさせ、あなたの香りは過ぎ去った日々の甘い思い出で私たちの心を満たしてくれる。
あなたにはもっと深い意味があり、厳しく容赦のない世界における希望と再生の象徴なのです。

あなたは、最も暗い瞬間であっても、大切にすべきもの、持ち続けるべきものが常にあることを私たちに思い出させてくれる。

あなたの美しさは光の道標であり、嵐の空を明るく照らし、私たちを明るい未来へと導いてくれます。

あなたの優美さと気品はつかの間のものではなく、喜びと驚きに満ちた終わりなき旅路であることを思い出しましょう。

あなたの美しさの中に、私たちはどんな人生にも立ち向かえる強さと、明るい明日を夢見る勇気を見出すからです。

あなたの輝きを讃え、あなたの優美を称えましょう。

あなたは自然からの真の贈り物であり、私たちを取り囲む美を思い出させてくれるからです。

llama_cppで出力

{'id': 'cmpl-8b6e0a92-1d31-4511-bf82-55b657c5dbde', 'object': 'text_completion', 'created': 1690355167, 'model': './llama-2-7b-chat.ggmlv3.q8_0.bin', 'choices': [{'text': '\n太宰治(Osamu dazai)の文体で、500文字の文章がほしい。テーマは「花の美しさについて」\n\nOsamu Dazai (1909-1948) was a Japanese novelist, essayist, and philosopher known for his works that explore the human condition and the complexities of modern Japanese society. Here is a 500-word piece on "The Beauty of Flowers" in the style of Osamu Dazai:\n\nFlowers are like people, each unique and beautiful in its own way. They bloom and fade, just as we do, and yet they continue to inspire us with their grace and beauty. The delicate petals of a cherry blossom, the vibrant colors of a sunflower, the intoxicating scent of a rose - each flower has its own special allure that speaks to our souls.\nBut what is it about flowers that makes them so beautiful? Is it their delicate beauty or their transience? Perhaps it is the way they remind us of the fleeting nature of life and the importance of cherishing each moment. Flowers are like a gentle breeze on a summer day - they bring us joy and peace, yet they are also transient and fragile.\nAnd yet, despite their fragility, flowers continue to inspire us with their resilience and determination. They push through the dirt and the rain, reach for the sun and the sky, and remind us of our own strength and endurance. Like a flower stem that bends but does not break, we too can find beauty in adversity and rise above our challenges to bloom again.\nFlowers also teach us the importance of connection and community. They are, after all, social creatures - they bloom and grow together, relying on each other for support and nourishment. And so, too, can we learn to connect with others, to support and uplift each other, and to build a world filled with beauty and compassion.\nIn the end, flowers remind us of the simple pleasures of life - the joys of nature, the beauty of art, and the importance', 'index': 0, 'logprobs': None, 'finish_reason': 'length'}], 'usage': {'prompt_tokens': 50, 'completion_tokens': 462, 'total_tokens': 512}}

いつもお読みいただき、ありがとうございます。 書くだけでなく読みたいので、コメント欄で記事名入れてもらうと見に行きます。