A computer implemented method , comprising: performing optical character recognition on a document ; generating a character grid using character information obtained from the optical character recognition, wherein the character grid is a two-dimensional down-sampled version of the document ; applying a convolutional neural network (CNN ) to the character grid and to a query string ; in response to the applying, generating a segmentation mask identifying target data of the document corresponding to the query string , wherein the applying further comprises: generating an encoded character grid by applying a first encoder of the CNN to the character grid; generating a feature vector by applying a second encoder of the CNN to the query string , generating an intermediary segmentation mask by applying a first decoder to the encoded character grid, wherein the intermediary segmentation mask identifies one or more key-value pairs of data from the document ; and applying a second decoder of the CNN to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask identifying target data, wherein the second decoder is configured to add and/or concatenate the character grid, the intermediary segmentation mask, and the feature vector. performing optical character recognition on a document ; generating a character grid using character information obtained from the optical character recognition, wherein the character grid is a two-dimensional down-sampled version of the document ; applying a convolutional neural network (CNN ) to the character grid and to a query string ; in response to the applying, generating a segmentation mask identifying target data of the document corresponding to the query string , wherein the applying further comprises: generating an encoded character grid by applying a first encoder of the CNN to the character grid; generating a feature vector by applying a second encoder of the CNN to the query string , generating an intermediary segmentation mask by applying a first decoder to the encoded character grid, wherein the intermediary segmentation mask identifies one or more key-value pairs of data from the document ; and applying a second decoder of the CNN to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask identifying target data, wherein the second decoder is configured to add and/or concatenate the character grid, the intermediary segmentation mask, and the feature vector. generating an encoded character grid by applying a first encoder of the CNN to the character grid; generating a feature vector by applying a second encoder of the CNN to the query string , generating an intermediary segmentation mask by applying a first decoder to the encoded character grid, wherein the intermediary segmentation mask identifies one or more key-value pairs of data from the document ; and applying a second decoder of the CNN to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask identifying target data, wherein the second decoder is configured to add and/or concatenate the character grid, the intermediary segmentation mask, and the feature vector. <EOS>