All demos

N-Gram Graph Lab

Read an n-gram model as a graph

The probability table can also be drawn as a network: contexts become nodes and possible next words become weighted arrows. Following arrows generates text one choice at a time.

Try this
  1. Choose a text and n-gram size, then inspect the table and graph.
  2. Set a generation start context.
  3. Step through choices and watch the active path on the graph.

N-Gram Graph

Read The Graph

From table to arrows

Nodes are contexts. Arrows are possible generated words. Thicker arrows are more likely, and highlighted arrows are the choices available from the current context. A dashed outer ring means generation can stop at that context or continue from it.

Probability Table

The graph is drawn from these rows
Context to next-word probabilities
ContextNext wordCountProbability

Generation

1.00
Generated sentence

Current context
Tokens0
Vocabulary0
Contexts0
One choice0
Dead ends0
Repeated paths0