AIExplainer

What is N-gram?

A sequence of n items from a given text or speech

An N-gram is a way to break down language into smaller parts, like words or sounds, and look at how they appear together in a sequence. It's used in natural language processing to understand patterns and relationships in language.

Think of an N-gram like a sliding window that moves over a sentence, looking at a few words at a time. For example, in the sentence 'the cat sat on the mat', a 3-gram would look at sequences like 'the cat sat' and 'cat sat on'.

Virtual assistants like Siri or Alexa use N-grams to understand what you're saying and respond accordingly. For example, if you say 'what's the weather like', the assistant uses N-grams to recognize the sequence of words and respond with the current weather.

N-grams are used in language modeling, text classification, and speech recognition to predict what word comes next in a sequence, or to identify the topic of a piece of text.

Some people think N-grams are only used for language translation, but they have a broader range of applications, including text summarization and sentiment analysis.

The concept of N-grams dates back to the 1950s, but it wasn't until the 1990s that they became widely used in natural language processing.

sequence model language model pattern recognition

Three products for different needs — explore what’s relevant to you.