Artificial intelligence (AI) is a very widely studied science at present. In an era of continuous technological development, there are more and more legal issues arising from AI. How to find out the problems as soon as possible and build a perfect legal liability system is very important at present. The purpose of this paper was to analyze the problems faced in the construction and implementation of the legal liability system in the context of AI and to improve the relevant laws. This paper first proposed the use of random forest algorithms to classify and assess legal risks related to legal issues that might arise from different AI products. This paper found that security, human rights, ethics, copyright and infringement issues in the AI era were among the most important issues. Then this paper selected three areas where legal cases occur more frequently in a city and conducted risk classification and assessment of AI products in these areas. The results showed that before the implementation of the system, the risk ratio of AI products in personal lending was 0.65, the risk ratio of transactions was about 0.8, and the risk ratio of returns was about 0.78; the risk rate of credit card AI products was about 0.5, the self-risk rate and return risk rate of smart medical AI products were about 0.35, and the transaction risk rate was about 0.5. After the implementation of the legal system, the overall legal risk ratio of its personal loan products dropped to about 0.5, the credit card AI products dropped to about 0.45, and the smart medical AI products dropped to 0.3. This showed that the relevant legal liability system constructed in this paper had a certain warning effect and could reduce the relevant legal risks of AI products. And the final expert's score for the legal system constructed in this paper was about 70 points, which showed that the legal system constructed in this paper had certain reliability and feasibility.