An n-gram is a contiguous sequence of n items (also called tokens) from a given text or speech sample. In the context of natural language processing, the items in an n-gram are usually words or characters.