Learn Before
Formula

Formula for Next Word Prediction with PCFGs

To predict the next word using a Probabilistic Context-Free Grammar (PCFG), the conditional probability of the next word wiw_i given the preceding words is calculated as the ratio of their prefix probabilities:

P(wiw1,w2,...,wi1)=P(w1,w2,...,wi1,wi)P(w1,w2,...,wi1)P(w_i | w_1, w_2, ..., w_{i-1}) = \frac{P(w_1, w_2, ..., w_{i-1}, w_i)}{P(w_1, w_2, ..., w_{i-1})}

0

1

Updated 2026-06-18

Tags

Data Science