Language Models and Prosody for Text Reconstruction

Author: Jacob Murel

Meter is essential to many premodern texts. The oral culture in which texts circulated before being written relied on rhythms, epithets, and other such conventions to aid in recitation. Indeed, many famous works of premodern Greek—most notably Homer’s Iliad and Odyssey—were written in a metrical form known as dactylic hexameter.

This metrical system is essential literary information for text reconstruction. Any application of language models and AI tools to assist in reconstruction of premodern Greek must be informed by the constraints of dactylic hexameter. As the technical lead for the Princeton Logion project, I’m interested in translating the rules of premodern Greek hexameter into a computational setting to advance AI tools to assist classical philologists.

Specifically, in this blog, I address the most recent question facing my work with Logion: how might we build AI software that utilizes Greek hexameter’s strict constraints to guide and filter language model predictions for gap-filling and error correction?

Premodern Greek Hexameter

Poetry in Romance languages and the Greco-Roman world is built from rhythmic units known as metrical feet (there’s also the currently in vogue free verse that eschews meter, but my opinions on that form are irrelevant to the present subject). There are five metrical feet used in verse:

  • iamb: two syllables, unstressed-stressed
  • trochee: two syllables, stressed-unstressed
  • anapest: three syllables, unstressed-unstressed-stressed
  • dactyl: three syllables, stressed-unstressed-unstressed
  • spondee: two syllables, stressed-stressed

Languages lend themselves to certain meters. Many English poets—from Ol’ Bill Shakespeare to Dorothy Parker—wrote in iambs because the English language, by its nature, is conducive to iambic meter. Even that clause: be-cause the Eng-lish lang-uage by its na-ture is con-du-cive to i-am-bic me-ter. Premodern Greek (and Classical Latin) is naturally conducive to dactylic meter.

Specifically, Greek epic poetry uses a system known as dactylic hexameter. One line of dactylic hexameter consists of six feet. The first five feet may be either dactyls or spondees, while the last foot may be either a spondee or trochee (though it is always pronounced as a spondee). One line of hexameter may thus contain between twelve to seventeen syllables. Rather than measuring feet with syllable stresses (as done in modern English, German, etc.), premodern Greek (and Latin) rely on syllable weight, which is in turn determined by a syllable’s vowel length (long vs. short). There are additional constraints, most notably rules governing where pauses/word breaks (known as caesura) may appear in a line.

Because the rules governing hexameter are so systematic, they seem naturally translatable into code. Such an endeavor involves breaking down the scholar’s task of identifying a text’s meter (known as scansion) into smaller, discrete computational tasks.

Building the Hexameter Harness

Meter is not so simple as counting syllables however. Software must understand premodern Greek’s lexical and phonological structure: distinguish vowels from consonants, recognize diphthongs, handle special consonants (e.g., ζ, ξ, and ψ), etc. Moreover, for Greek hexameter, software must further track word positions within a line and account for common n-grams, such as epithets like γλαυκῶπις Ἀθήνη.

To this end, I represent individual characters via an original data structure: PhoneticUnit. This stores character-level information, such as whether it belongs to or carries explicit length markings (i.e., macron or breve).

Once each character is encoded as a phonetic unit, text can be syllabified per Greek phonological rules. We can define a syllable as a linguistic unit with an onset (optional consonant), nucleus (of at least one vowel), and coda (optional consonant). The code further checks for rules affecting different forms of consonants—e.g., double consonants behave differently than plosive-liquid combinations.

This is necessary for the following step of assigning syllables weights. Some vowels are long or short by nature and others remain ambiguous. Phenomena like correption can affect vowel length, and synizesis may combine adjacent vowels. By assigning each syllable a weight according to linguistic rules, a line of weighted syllables is then checked against plausible hexameter sequences. If the weighted sequence matches at least one hexameter template, the candidate passes the filter.

Testing

The hexameter filter is permissive rather than restrictive, prizing recall over precision. Most NLP and LM tasks privilege a single ground truth. But Ancient Greek poetry contains genuine metrical ambiguities, with differences between scholarly traditions regarding determinations of particular scansions. The filter code thus accounts for different scansions.

The filter is tested on multiple authors spanning a millennium of Greek literary history. This set includes Homer’s Iliad and Odyssey, Hesiod’s Theogony, Apollonius’ Argonautica, Quintus Smyrnaeus’ Posthomerica, and Nonnus’ Dionysiaca. The group was chosen to reflect diverse metrical habits and linguistic forms. The filter is additionally tested against non-hexametrical texts, specifically Sophocles’ Antigone and Aristotle’s prose, in order to account for false positives passing the filtering.

Filtering Language-Model Predictions

The motivating application is reconstruction for ancient metrical texts. As a test case, we can use a well-known passage from the opening of the Iliad with one word removed:

Ἡρώων, αὐτοὺς δὲ [—] τεῦχε κύνεσσιν

A language model can generate candidate completions for the missing span. The problem is that many statistically plausible completions fail to satisfy the metrical constraints of the line; they are linguistically plausible yet metrically impossible. Filtering aligns candidates with hexameter’s structural requirements.

This approach combines work from machine learning and classical philology, showing potential. Bringing those together produces something that is more useful than either component alone. The project is still evolving, but one lesson already stands out: domain knowledge remains valuable. Even in an era of large language models, explicitly encoding the rules of a problem dramatically improves the quality of the results. Two thousand years of textual critical research informs and guides the design of Logion’s AI systems. Without this core humanities scholarship, AI models would be ill-applied and, ultimately, useless for reconstructing ancient texts.

This entry was posted in Uncategorized. Bookmark the permalink.