What are N-Grams?

N-grams are models that calculates probabilities of a word given n-1 words that follow them.

What are n-grams?

N-Grams are probabilistic models that predict the next word in a sequence given the previous n number of words. More formally, N-grams mean a probabilistic model that can estimate probability of a word given n-1 previous words and thereby also asssign probabilities to the entire sequences.

Before diving into n-grams, lets just firstly revise some probability rules you would have learnt in 11th grade

P(BA)=P(AB)P(A)=P(A,B)P(A)P(B|A) = \dfrac{P(A \cap B)}{P(A)} = \dfrac{P(A, B)}{P(A)}
P(x1,x2,x3,..,xn)=P(x1)P(x2x1)P(x3x2,x1)P(xnxn1...x2,x1)P(x_1, x_2, x_3, .., x_n) = P(x_1)\cdot P(x_2|x_1)\cdot P(x_3|x_2, x_1) \cdot P(x_n|x_{n-1}...x_2,x_1)