Recurrent neural network (RNN) is employed as a machine learning model for fast optical proximity correction (OPC). RNN consists of a number of neural network instances which are serially connected, with each instance in charge of one segment. RNN thus allows some localized segments to be corrected together in one execution, which offers higher accuracy. A basic RNN is extended by introducing gated recurrent unit (GRU) cells in recurrent hidden layers, which are then connected in both forward and backward directions; attention layer is adopted to help output layer predict mask bias more accurately. The proposed RNN structure is used for OPC implementation. A choice of input features, sampling of training data, an algorithm of mapping segments to neural network instances, and final mask bias calculation are addressed toward efficient implementation. Experiments demonstrate that the proposed OPC method corrects a mask layout with 36% lower EPE compared to state-of-the-art OPC method using artificial neural network structure.