Hong Kong will cut thousands of civil service jobs and boost spending in artificial intelligence (AI) as it seeks to tackle an increasing deficit, authorities said.