arrow_backProjects
PERSONAL•2026•Duccio Meconcelli

InfiniteDante

TransformerPyTorchDPOONNX Runtime WebWebAssembly
§ 00 // ABSTRACT

A micro-LLM (~8.2M–12.1M parameters) trained on medieval Italian literature and Dante Alighieri's works, executing entirely in the browser via ONNX Runtime Web with constrained terza rima decoding.

InfiniteDante is an end-to-end micro-language model designed to generate continuous verse in the style of Dante Alighieri’s Divina Commedia, running client-side in the browser through ONNX Runtime Web and WebAssembly with zero server dependencies.

Model Architecture & Two-Stage Curriculum

Built on a compact NanoGPT-style decoder-only Transformer (15 layers, 8 attention heads, 256 embedding dimension, Rotary Position Embeddings, and weight tying), the model uses a custom Byte-Pair Encoding (BPE) tokenizer trained directly on Fourteenth-Century Italian orthography and exported as meta.json for browser-side tokenization.

Training is structured as a two-phase curriculum followed by post-training metric alignment:

  • Phase 1 — Classical & Medieval Pretraining: 10,000 iterations ($\text{lr} = 3 \times 10^{-4}$) on a corpus of medieval and classical Italian texts from Biblioteca Italiana (Boccaccio, Cecco Angiolieri, Cino da Pistoia, Jacopo Alighieri, Cecco d’Ascoli, Machiavelli, Manzoni) to establish syntactic and morphological foundations.
  • Phase 2 — Dantean Fine-Tuning: 2,000 iterations ($\text{lr} = 5 \times 10^{-5}$) with early stopping on Dante’s complete vernacular corpus (Divina Commedia, Vita Nuova, Convivio, Rime) alongside Latin-to-vernacular treatises (De Vulgari Eloquentia, Epistole).
  • Metric Alignment & DPO Experiments: Post-training Direct Preference Optimization (dpo_finetune.py) pairing authentic terzine ($y_w$) against metrically perturbed candidates ($y_l$) scored by a custom TerzinaScorer evaluating hendecasyllable syllable counts and rhyme adherence.
Pretraining and fine-tuning loss curves for InfiniteDante
Two-stage training and validation loss curves across pretraining and Dante fine-tuning
DPO metric alignment training curves for InfiniteDante
Direct Preference Optimization (DPO) loss and reward margin for hendecasyllable alignment

Constrained Terza Rima & Hendecasyllable Engine

Unconstrained autoregressive sampling at ~10M parameters frequently drifts out of strict poetic meter or breaks the interlocking terza rima chain (ABA BCB CDC). To enforce formal structure during client-side inference (6–8 ms/token on CPU via WASM), the browser runtime pairs standard logit processors (Temperature, Top-$K$, Top-$P$, Repetition Penalty) with a prosodic constraint layer:

  • Synalepha-Aware Syllabification: Tracks vowel elisions across word boundaries in real time to maintain 11-syllable hendecasyllabic lines.
  • Rhyme-Guided Line Closure: Scores candidate rhyme completions from a historical rimario against the model’s autoregressive log-probabilities when approaching the end of a verse, preserving the ABA BCB CDC rhyme scheme across stanzas.

Interactive Manuscript Interface

The web client presents the generator inside a Renaissance chiaroscuro manuscript layout featuring illuminated drop caps, live prosodic annotations (11 sillabe pills and [A] / [B] / [C] rhyme badges), custom incipit prompting, inline editing when paused, Italian speech synthesis declamation (window.speechSynthesis), and offline Progressive Web App (PWA) caching via Service Worker.

Resources