Network intrusion detection has always been one of the key tasks in network security. Traditional network intrusion detection methods mainly use machine learning method to construct detection models by extracting multi-dimensional features, while most of them ignore the time correlation of intrusion behaviors. In this paper, a Transformer network model with multi-head self-attention mechanism based on dimension reduction feature was designed by extracting the time sequence features of network intrusion behavior. The proposed model solved the problems that traditional serial sequential neural network models are difficult to converge and have a large time consumption. The optimal loss function and training parameters were selected to implement the network intrusion detection. The experimental results show that the network intrusion detection method based on Transformer network model achieves the accuracy and the detection rate of over 99% in multiple datasets.