Home▸AI & Machine Learning▸Part-of-Speech Tagging: HMM Viterbi Trellis

Part-of-Speech Tagging: HMM Viterbi Trellis (2D)

2D companion to the 3D Viterbi trellis: watch a Hidden Markov Model tag a sentence word by word on a flat canvas grid, tracing every candidate tag, every backpointer, and the single highest-probability path — including classic ambiguous words like 'flies' and 'book'.

AI & Machine Learning2DAdvanced60 FPS📱 Mobile-adapted⇄ 3D version
2d-natural-language-processing-advanced ↗ Open standalone

A Hidden Markov Model tags each word of a sentence by treating the seven parts of speech as hidden states and running the Viterbi algorithm to find the single most probable tag sequence. This 2D companion renders the full decoding trellis as a flat canvas grid — every (word, tag) candidate as a node, every backpointer as a line — and steps through the forward recursion live as it happens, word by word. Six preset sentences include classic structurally ambiguous cases ("Time flies like an arrow", "Book that flight for me") where the correct tag for a word depends entirely on grammatical context rather than the word alone. A transition-smoothing slider lets you dial the model's grammar knowledge down toward a uniform prior, watching in real time how the Viterbi path — and the running path log-probability and tagging accuracy — respond as the transition statistics stop doing their job.

⚙ Under the hood

2D companion to the 3D Viterbi trellis: watch a Hidden Markov Model tag a sentence word by word on a flat canvas grid, tracing every candidate tag, every backpointer, and the single highest-probability path.

NLPHMMViterbi algorithmpart-of-speech taggingdynamic programminglinguistics

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)