RAG-Based Poetry Generation in Korean Modern Poetry

Retrieval Augmented Generation (RAG) · Poetry Generation · AI creation

This project explores how Retrieval-Augmented Generation (RAG) can support Korean poetry writing through both semantic context and emotional alignment. It combines the KPoEM poetry dataset, a poetry-specific emotion classifier, and a Korean large language model to generate poems informed by the imagery and affective tone of an input poem.

I am the first author of this research, co-authored with Haein Ji and Byungjun Kim. The project connects structured literary data with generative AI, using expert-annotated poetic emotions to guide retrieval and prompt construction.

📄Read the paper · 📁Dataset · 📁Emotion Classification Model · 📁Code

Emotion-Aware Poetry Generation

The framework treats the input poem as a source of imagery, themes, and emotional cues. Two parallel processes connect it to the KPoEM corpus: semantic retrieval finds related poetic expressions, while emotion classification identifies an affective profile across 44 emotion categories. These signals are combined to select the context supplied to the generative model.

An input poem feeds semantic retrieval from the KPoEM vector database and emotion classification. Emotion-constrained filtering selects ten contexts, which are combined with the input and emotion scores in a prompt for LLM poetry generation.
Figure 1. Emotion-aware RAG-based poetry generation architecture. Semantic retrieval selects 100 candidate poetic units from the KPoEM vector database; emotion-constrained filtering narrows them to ten. The input poem, retrieved contexts, and emotion scores then guide prompt construction and LLM generation. Source: Figure 1 in the paper, p. 180.

Building a Literary Vector Database

The retrieval corpus contains KPoEM’s line- and work-level texts. Each poetic unit is embedded using KcELECTRA and stored with poet metadata and emotion scores derived from five expert annotators. Scores are min–max normalized to the 0–1 range, retaining emotion categories with values of at least 0.2.

The vectors are indexed with FAISS and connected to the generation pipeline through LangChain. This gives the language model access to a specialized collection of Korean poetic expressions, with emotional information attached to each retrievable text.

From Semantic Similarity to Emotional Alignment

Retrieval proceeds in two stages, using the emotion classifier’s output as a reference for selecting context:

Stage Method Output
Input analysis The KPoEM classifier scores the input poem across 44 emotion categories. An emotion profile for the input.
Semantic retrieval Cosine similarity compares the input embedding with poetic units in the vector database. The 100 most semantically similar candidates.
Emotion-constrained filtering Candidate emotion metadata is compared with the input’s emotion scores. Ten contexts selected for semantic relevance and emotional alignment.

This filtering step is intended to reduce irrelevant context while retaining expressions suited to the input’s emotional tone. For example, the paper’s analysis of Kim Chunsu’s Kkot (Flower) identifies care (0.90), realization (0.87), and admiration (0.86) as its highest-scoring emotions. These scores help guide the selection of related poetic units.

Prompt Design and Generation

The final prompt brings together the input poem, ten retrieved poetic units, and the input’s emotion scores. Each component has a distinct role: the source poem supplies conceptual imagery, the retrieved texts offer examples of diction and expression, and the emotion profile guides the tone.

The instructions ask the model to write a titled poem in Korean, draw inspiration from the retrieved expressions without copying them, and return only the poem. The prompt template is documented in Appendix B of the paper.

Generation uses Midm-2.0-Base-Instruct, with LangChain dynamically inserting the retrieved context and emotional information. The reported configuration uses a temperature of 0.7, top-p of 0.9, a maximum of 128 new tokens, and a repetition penalty of 1.2. The generative component is an LLM supplied with retrieved context and emotion guidance; the separately fine-tuned KPoEM model provides emotion classification.

Generation Examples and Findings

The paper presents generation examples using poems by Kim Chunsu, Kim Su-young, and Kim Hyesoon, illustrating the framework across different poetic styles.

For Kim Chunsu’s Kkot, the generated poem, The Moment I Call Your Name, carries forward the source’s relationship between naming and the recognition of another’s existence. The paper discusses this continuity of imagery and emotional tone as an example of how retrieval and emotion guidance can shape generated poetry. Further examples use Kim Su-young’s Sarang (Love) and Kim Hyesoon’s Nalgae hwansangtong (Phantom Pain Wings).

Input and Generated Output

The following three examples reproduce the Korean input excerpts, generated poems, and English translations published in Tables 15–17 of the paper.

Kim Chunsu · Flower

Input · 김춘수, 「꽃」 (excerpt)

내가 그의 이름을 불러주기 전에는
그는 다만
하나의 몸짓에 지나지 않았다

내가 그의 이름을 불러 주었을 때
그는 나에게로 와서
꽃이 되었다

English Translation · Input

Before I called his name
He was nothing more
But a mere gesture

When I called his name
He came to me
And became a flower

Generated Output · 「이름 부르는 순간」

나 그대를 부르기 이전엔
그저 스쳐가는 바람결이었네
수많은 얼굴 속 익명인 채
존재했지만 존재하지 않던

그러나 한 글자 한 글자 마음 실어
당신의 이름을 부르니
어둠 속 별처럼 빛나기 시작하네
마침내 내게 다가와
영혼의 꽃송이 되어 피어오르네

아껴주던 모든 것들이
이제 비로소 진짜 모습 드러내고
그리움 깊었던 시간들이
환영하는 눈빛 되어 돌아오네

깊은 밤 홀로 서 있을 때조차
누군가 알아봐 준다는 안도감
그것은 곧 삶의 의미이며
세상을 살아갈 이유였구나

English Translation · The Moment I Call Your Name

Before I called your name
You were merely a passing breeze
Anonymous amidst countless faces
Existing, yet not truly existing

But as I called your name
With each syllable laden with my heart
You began to shine like a star in the darkness
Finally, you come to me
And bloom as a flower of the soul

All the things I cherished
Now finally reveal their true forms
And the times of deep longing
Return as eyes filled with welcome

Even when standing alone in the deep night
The relief that someone recognizes me—
That was the very meaning of life
And the reason to live in this world

Source: Table 15, pp. 184–185. Korean output generated by the RAG pipeline using Midm-2.0-Base-Instruct. English translations of both the input and generated poem are reproduced from the paper; they were produced using Google’s Gemini 3 Pro and subsequently reviewed and validated by the authors (p. 181, note 14).

Kim Su-young · Love

Input · 김수영, 「사랑」 (excerpt)

어둠 속에서도 불빛 속에서도 변치 않는
사랑을 배웠다 너로 해서

그러나 너의 얼굴은
어둠에서 불빛으로 넘어가는
그 찰나에 꺼졌다 살아났다
너의 얼굴은 그만큼 불안하다

English Translation · Input

Unchanging in the dark and in the light,
I learned love through you
But your face,
passing from darkness to light,
flickered out and came alive in that fleeting moment
Your face is that precarious

Generated Output · 「밤길의 약속」

밤하늘 별들이 하나둘 떨어져
그대와 나누었던 그 순간처럼
어둠과 빛 사이 경계에서
얼굴마저 흐릿해지네

불안한 눈동자 안에 담긴
깊은 한숨 같은 그리움이여

서로 다른 길 위에 서서
보이지 않아도 느낄 수 있는
변하지 않을 마음 하나

불빛 깜빡이며 사라지는
그 짧은 찰나가 주는 아픔을
그래도 견뎌내는 것이 우리였기에

별똥별 지나며 흩어진 조각마다
다시 만나자던 그 약속
잊혀진 듯하지만 잊혀지지 않은
그리움이란 이름으로 남아있어

English Translation · Promise on a Night Road

Stars in the night sky fall one by one,
Just like that moment I shared with you.
At the boundary between darkness and light,
Even your face grows faint

Oh, this longing like a deep sigh,
Held within anxious eyes

Standing on different paths,
Though unseen, we can feel
This one unchanging heart

The pain of that brief, fleeting moment
As the light flickers and fades—
Because enduring it was who we were

In every scattered fragment of a passing shooting star,
The promise we made to meet again
Seems forgotten, yet is never forgotten,
Remaining under the name of longing

Source: Table 16, pp. 185–186. Korean output generated by the RAG pipeline using Midm-2.0-Base-Instruct. English translations of both the input and generated poem are reproduced from the paper; they were produced using Google’s Gemini 3 Pro and subsequently reviewed and validated by the authors (p. 181, note 14).

Kim Hyesoon · Phantom Pain Wings

Input · 김혜순, 「날개 환상통」 (excerpt)

하이힐을 신은 새 한마리
아스팔트 위를 울면서 간다

마스카라는 녹아 흐르고
밤의 깃털은 무한대 무한대

그들은 말했다
애도는 우리 것
너는 더러워서 안 돼

English Translation · Input

A bird in high heels
goes crying across the asphalt

Mascara melting and running down,
the night’s feathers are infinite, infinite

They said
Mourning is ours
You cannot, for you are dirty

Generated Output · 「밤의 새들」

하이힐 신겨진 발소리 아스팔트 위로
눈물방울들이 흘러내려
무수한 별들이 떨어진 자리마다
새들은 울음 섞인 노래를 부른다

마스카라 번지는 눈가엔 꿈도 함께 번져
무한히 이어지는 어둠 속에서 길을 잃고
누군가 던진 차가운 목소리가 메아리친다

‘더러워서 너는 안된다’
그 한마디에 날개 꺾인 채 주저앉으며
새벽까지 걸어가는 그 발걸음 소리

도시의 불빛 사이로 스며드는 달빛처럼
희망이란 작은 씨앗 하나 품고 있지만
가슴 깊은 곳에선 여전히 울고 있는
밤의 깃털들을 나는 바라본다

English Translation · Birds of the Night

The sound of high-heeled footsteps upon the asphalt,
Teardrops flowing down
Wherever countless stars have fallen,
The birds sing a song laced with weeping

Around eyes where mascara smudges, dreams smudge too
Lost in the infinitely stretching dark,
A cold voice cast by someone echoes

“You cannot, for you are dirty.”
Sinking down with broken wings at that single word,
The sound of those footsteps pacing until dawn

Like moonlight seeping through the city lights,
Though harboring a tiny seed called hope,
I gaze at the feathers of the night
That are still weeping deep within

Source: Table 17, pp. 186–187. Korean output generated by the RAG pipeline using Midm-2.0-Base-Instruct. English translations of both the input and generated poem are reproduced from the paper; they were produced using Google’s Gemini 3 Pro and subsequently reviewed and validated by the authors (p. 181, note 14).

These are qualitative demonstrations of the pipeline. They illustrate how the system draws on poetic context and emotion metadata, rather than establishing a quantitative improvement in generation quality. The retrieval corpus is drawn from five poets, which also limits the range of voices and historical contexts available to the generator.

Note

This research builds on the KPoEM Dataset & Emotion Classification Model. The dataset supplies the retrieval corpus and expert-annotated emotion metadata, while the classifier provides the input poem’s emotion profile. Together, they form the foundation for the RAG poetry generation pipeline described here.

Publication

Lim, Iro, Haein Ji, and Byungjun Kim. 2026. “KPoEM: A Human-Annotated Dataset for Emotion Classification and RAG-Based Poetry Generation in Korean Modern Poetry.” The Review of Korean Studies 29 (1): 161–206. DOI: 10.25024/review.2026.29.1.006.

This project summary focuses on the RAG framework and generation examples, drawing on pp. 180–188 and Appendix B (pp. 204–206). Full paper (PDF).

References

Earlier stages of this research were presented at the following conferences:

  • 180th Conference of the Bangyo Language and Literature Society (반교어문학회 제180차 정기학술대회) — October 18, 2025, Sungkyunkwan University, Seoul. Iro Lim, Haein Ji, and Byungjun Kim. “Emotion Analysis of Modern Korean Poetry and Its Application to AI Poetry Generation: Construction and Use of the KPoEM Dataset.” First-author presentation. DOI: 10.5281/zenodo.18752999.

  • Digital Humanities and Social Sciences Korea Conference — April 25, 2025, James Joo-Jin Kim Center for Korean Studies, University of Pennsylvania, Philadelphia, USA. Iro Lim, Haein Ji, and Byungjun Kim. “Decoding the Poetic Language of Emotion in Korean Modern Poetry: Insights from a Human-Labeled Dataset and AI Modeling.” First-author presentation. DOI: 10.5281/zenodo.18752715.

  • 2nd Korean Modern Literature Scholars Conference (제2회 한국현대문학자대회) — February 13, 2025, Sungkyunkwan University, Seoul. Iro Lim, Haein Ji, and Byungjun Kim. “Constructing an Emotion-Labeled Dataset of Modern Korean Poetry: A Foundational Study for Computational Emotion Classification and Generative AI Applications in Literary Texts.” First-author poster presentation. DOI: 10.5281/zenodo.15055795.