The two main classes of transformers are encoder transformers and decoder transformers. Encoder transformers focus on encoding the input sequence and capturing its representations, while decoder transformers generate output sequences by attending to both the input sequence and previously generated output tokens in an autoregressive manner.