N-Gram
Interactive visualization of how text is broken down into contiguous sequences of N items for language modeling.
Generated N-grams
0 ITEMSEnter text to generate sequences
Tip: Use the slider to scroll through the list if it overflows.
Interactive visualization of how text is broken down into contiguous sequences of N items for language modeling.
Enter text to generate sequences
Tip: Use the slider to scroll through the list if it overflows.
See how text is broken down into overlapping sequences to help machines understand context and predict the next word.
An n-gram is a contiguous sequence of 'n' items from a given sample of text or speech. The "items" can be characters, syllables, or, most commonly, words. N-grams are a simple yet powerful way for machines to capture the context and statistical properties of a language.
By analyzing which words tend to appear together, n-gram models can form a probabilistic understanding of a language. This is the foundation for many Natural Language Processing (NLP) tasks.
The 'n' in n-gram determines the size of the sequence. The most common types are:
Use the N-gram Explainer above to see how this works in practice:
N-grams are fundamental to many classic NLP applications:
N-grams are a simple but effective method for capturing local context in text by breaking it into small, overlapping chunks. While modern deep learning models use more sophisticated techniques, n-grams remain a foundational concept for understanding how machines begin to process and find patterns in human language.
An n-gram is a contiguous sequence of 'n' items from a given sample of text or speech. The "items" can be characters, syllables, or, most commonly, words. N-grams are a simple yet powerful way for machines to capture the context and statistical properties of a language.