RLFT of Gemini 3.5 Flash for Tunisian folk poetry (الشعر الشعبي التونسي): rhyme-topology reward, Cloud Run scorer, calibrated against the national corpus
# tuni-folk-gemini
**An end-to-end SFT → RL pipeline that teaches Gemini 3.5 Flash to compose
Tunisian folk poetry (الشعر الشعبي التونسي / الملحون).**
```
gemini-3.5-flash
│
│ STAGE 1 — supervised fine-tuning
│ 3,631 (prompt, poem) pairs from the Diwan
│ teaches the DISTRIBUTION — what folk poetry sounds like
▼
tunifolk-sft-base
│
│ STAGE 2 — reinforcement fine-tuning
│ 843 prompts, no answers, graded by a programmatic reward
│ teaches the CONSTRAINT — rhyme topology, dialect, novelty
▼
tunifolk-rlft-from-sft
```
---
## Why this task, and why two stages
Tunisian folk poetry is an unusually good tuning target. Its metrical system is
*not* Khalilian — Muhammad al-Marzuqi's argument, adopted by Muhyi al-Din
Khrayyef and by the editorial committee of the national corpus, is that the
Tunisian dialect has `asbab` and `awtad` but no `fawasil`, so classical `buhur`
cannot be applied at all:
> «الشعر الشعبي الحديث لا يمكن أن نطبّق عليه البحور القديمة… ولا يمكن أن نضبط موازينه
> إلا بواسطة الإيقاع» — المرزوقي، *الأدب الشعبي*، ص 83
What *does* hold a poem together is a **rhyme topology** that differs per form
and is fully decidable by a program. That is what makes a reinforcement reward
possible here at all: an objective, cheap, hard-to-game structural signal on a
creative task.
The two stages teach different things, and neither substitutes for the other:
- **Supervised tuning can only teach what a target exemplifies.** Right for
register — diction, imagery, the sound of the Mudawwana. Wrong for "satisfy
this topology *and* stay in dialect *and* don't copy the source", because no
single poem demonstrates the conjunction, and copying a training poem is
zero loss.
- **Reinforcement tuning can only teach what a scorer can grade.** It never sees
a target, so it can be pushed toward that conjunction and told copying is
worthless — but from the base model it wastes its early run learning register
that a supervised pass learns in an hour.
**The order is enforced, not …