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