PoetryDuel-GPT is a GPT-style autoregressive Transformer built from scratch in raw PyTorch — zero HuggingFace wrappers. It performs đối thơ (Vietnamese poetry dueling): given one or two lines of Lục Bát poetry, the model responds with a matching couplet that follows rhyme, tone, and syllable constraints.
Evaluated on 116 held-out Lục Bát couplet prompts (v4.2.3):
Rule
Accuracy
Random Baseline
All 5 rules simultaneously
91.4%
0.0%
Rhyme (vần lưng)
92.2%
0.6%
Tone (B-T-B-B pattern)
100.0%
6.2%
Syllable (exact 6+8)
100.0%
7.0%
Trầm-Bổng (Ngang ≠ Huyền)
99.1%
50.0%
Rhythm (nhịp điệu)
100.0%
7.0%
Quality Metric
Value
Lexical diversity
0.962
Average response length
14.0 syllables
Empty/short response rate
0.0%
Sample Output
Input: Công cha như núi thái sơn
Nghĩa mẹ như nước trong nguồn chảy ra
Output: Dù cho vật đổi sao dời
Nhưng dân vẫn Việt bốn phương rạng ngời
Input: Thân em như chẽn lúa đòng
Phất phơ dưới ngọn nắng hồng ban mai
Output: Bao la trời đất cao vời
Tình em tha thiết muôn lời nhớ thương
Control tokens condition the model on rhyme target, tone pattern, and tonal contrast — enabling rule-compliant generation without external rule engines.
During inference, tags are extracted from the user's input couplet:
[RHYME:X] — Target rhyme group from position 8 of the input's second line
[TONE:XXXXXX] — Bằng/Trắc tone pattern from the input's first line
[TRAMBONG:NH/HN] — Trầm-Bổng (Ngang→Huyền or Huyền→Ngang)
The model attends to these tags via standard self-attention, learning to generate output whose rhyme, tone, and diacritic patterns match the constraints.
Lục Bát Rules Enforced
Rule
Description
Implementation
R1: Vần lưng
Position 6 of output Lục rhymes with position 6 of output Bát
Soft rhyme biasing during generation
R2: Bằng-Trắc
BTB (Lục) + BTBB (Bát) tone pattern at even positions
[TONE:XXXXXX] control token
R3: Syllable
Exact 6+8 syllable count
Learned from training data
R4: Trầm-Bổng
Position 6 & 8 of Bát must differ in Ngang vs Huyền
[TRAMBONG:NH/HN] control token
R5: Nhịp điệu
2/2/2 or 4/4 rhythm structure
Implicit in data
Generation Features
Soft rhyme constraint — Rhyme candidates get +2.0 logit boost instead of hard masking