# RiddleWeaver

A framework for fine-tuning GPT-2 to generate math riddles and their solutions in multiple explanatory styles, using a dual-decoder architecture and a coherence-penalty loss that ties a generated riddle's wording to its generated answer.

RiddleWeaver fine-tunes GPT-2 on a math riddles dataset to both generate riddles and unpack their solutions in different conceptual styles, rather than only reproducing question-answer pairs from training data. Its dual-decoder architecture separates a riddle's surface narrative from its underlying mathematical structure during training, and a coherence-penalty loss penalizes generations where the semantic embedding of the generated question does not align with the embedding of the generated answer, intended to keep generated riddles internally consistent rather than producing text that only sounds like a riddle.

The project frames this as useful for building educational tools, gamified learning platforms and AI tutoring systems where a generated riddle must actually be solvable by its own stated answer.

It is a fine-tuning project built on GPT-2.

Website: https://github.com/StudioFoysal/RiddleGen-FineTuned-GPT2
