Heatmap of transitions in the poetry corpus

The generator starts with a poem supplied by the visitor. It counts which words follow one another and uses those relationships to produce another text. The model can be inspected before and after generation: every choice has a transition behind it.

Learning from neighboring words#

Training visits consecutive word pairs. For each word, it stores possible successors and the number of times each relationship appeared. These transition counts become weights when selecting the next word.

Generation begins with a randomly selected word and samples successive words from those weights. More frequently observed transitions receive greater weight. The process ends at the requested length or when it reaches a word with no continuation in the model.

A word with only one successor offers no real choice. A word with several successors can branch. This explains why some passages preserve original phrases while others produce unexpected combinations.

Three views of one model#

The interface provides a relationship matrix, heatmap and interactive graph. The matrix exposes counts, the heatmap supports comparisons and the graph lets visitors follow connections, move nodes and zoom.

The application uses TypeScript, React and Next.js, with D3 for visualizations. Analysis and generation operate on the supplied text; there is no language-model request writing the result.

What survives and what is lost#

This chain considers only the current word. It does not maintain an idea of the whole poem, its subject or structure. It can repeat sequences, lose coherence or stop early. Those limits are part of the experience: changing the input and inspecting the connections makes it possible to relate output to what the program actually learned.