Gemini actually knows nothing about Tunisian folk poetry until
The SFT Phase
The first hurdle was the data scarcity. Since there isn't a massive open-source corpus of Tunisian folk poetry, I had to curate a high-quality, small-scale dataset. The goal here wasn't just to give the model examples, but to teach it the structural constraints of the poetry.
1. Dataset Curation: I gathered a few hundred authentic poems and paired them with detailed linguistic explanations.
2. Prompt Engineering: Instead of simple "complete this poem" prompts, I used a format that explained the meter and the specific regional dialectal markers.
3. Fine-Tuning: I ran the SFT process to shift the model's internal probability distribution. This stopped the model from constantly correcting "incorrect" dialectal spelling back into Modern Standard Arabic.
Moving to RL for Nuance
SFT gets the model to mimic the style, but it doesn't necessarily make the poetry "good" or culturally resonant. That's where Reinforcement Learning comes in. I set up a reward model based on three specific criteria: adherence to the folk meter, use of authentic regional vocabulary, and the avoidance of classical Arabic clichés.
The process looked like this:
- The model generates five variations of a poem based on a theme.
- A human-in-the-loop (or a highly tuned critic model) ranks them.
- The reward signal pushes the model toward the "folk" identity and away from the "academic" identity.
The Technical Takeaway
The most interesting part of this AI workflow was seeing the tension between the model's pre-existing knowledge and the new fine-tuned data. Gemini has a massive "gravity" toward standard Arabic. To overcome this, you can't just provide examples; you have to actively penalize the model for being "too correct" in a formal sense.
For anyone attempting a similar deep dive into niche languages or dialects, the lesson is that SFT provides the vocabulary, but RL provides the "soul" or the stylistic intuition. If you're building an LLM agent for cultural preservation, don't stop at fine-tuning. The reward function is where the actual personality of the agent is forged. This approach turned a model that was guessing into one that could actually compose verse that felt authentic to the region.
