Anhui clique
Liang was a native of Changle in Fujian province. From 1888-1890, he lived in Japan, where his father had been dispatched to by the government of Qing Dynasty China. In 1903, he passed the Imperial examination and in 1905 was accepted to the predecessor to Beijing University. In 1908, he was sent as an official to Shandong province. After the Xinhai Revolution and the formation of the Republic of China, he was recruited to the nationalist government by Yuan Shikai. After the death of Yuan, he gave his allegiance to Duan Qirui, warlord of the Anhui clique, serving as secretary to Duan Zhigui. After the defeat of the Anhui clique in the Zhili–Anhui War, he fled to the Japanese concession in Tianjin.