With the continuous improvement of information technology,the computer Internet has entered thousands of households,bringing convenience to people's life,but the computer network security vulnerabilities also to people's personal privacy and property security has a great threat,so it is very necessary to optimize the computer network security system.Artificial intelligence is an information technology that has developed rapidly by relying on the Internet in recent years.The application of it to the computer network security protection is conducive to improving the level of computer network security management.Based on this,this paper studies the application of artificial intelligence technology in computer network security,analyzes the necessity of the construction of computer network security defense system,and explains the effectiveness of artificial intelligence technology application by protecting spam as an example.