AIExplainer

N-gram

An ordered sequence of N words.

An ordered sequence of N words. For example, truly madly is a 2-gram. Because order is relevant, madly truly is a different 2-gram than truly madly. Examples | --- | to go, go to, eat lunch, eat dinner | ate too much, happily ever after, the bell tolls | walk in the park, dust in the wind, the boy ate lentils | Many natural language understanding models rely on N-grams to predict the next word that the user will type or say. For example, suppose a user typed happily ever. An NLU model based on trigrams would likely predict that the user will next type the word after. Contrast N-grams with bag of words, which are unordered sets of words. See Large language models in Machine Learning Crash Course for more information.

Practitioners refer to n-gram when building, training, or evaluating machine learning systems. It appears in research papers, product documentation, and technical discussions about AI capabilities and limitations.