A child prodigy, he studied at the Yuelu Academy in Changsha. In 1795, Yan Ruyi was involved in a debacle in which he organized a group of Gelao to defend against the raging Miao Rebellion (1795–1797).
As a child prodigy, Yan Ruyi's academic pursuits at the Yuelu Academy in Changsha were overshadowed by his involvement in a tumultuous incident in 1795. He played a role in organizing a group of Gelao to counter the Miao Rebellion (1795–1797), which was a time of upheaval.