A computer implemented method (300, 400), comprising: performing optical character recognition on a document (120A, 200A); 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 (120A, 200A); applying a convolutional neural network (CNN (140A, 140B)) to the character grid and to a query string; in response to the applying, generating a segmentation mask (200C, 200D) identifying target data of the document (120A, 200A) corresponding to the query string, wherein the applying further comprises: generating an encoded character grid by applying a first encoder of the CNN (140A, 140B) to the character grid; generating a feature vector by applying a second encoder of the CNN (140A, 140B) 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 (120A, 200A); and applying a second decoder of the CNN (140A, 140B) to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask (200C, 200D) 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 (120A, 200A); 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 (120A, 200A); applying a convolutional neural network (CNN (140A, 140B)) to the character grid and to a query string; in response to the applying, generating a segmentation mask (200C, 200D) identifying target data of the document (120A, 200A) corresponding to the query string, wherein the applying further comprises: generating an encoded character grid by applying a first encoder of the CNN (140A, 140B) to the character grid; generating a feature vector by applying a second encoder of the CNN (140A, 140B) 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 (120A, 200A); and applying a second decoder of the CNN (140A, 140B) to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask (200C, 200D) 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 (140A, 140B) to the character grid; generating a feature vector by applying a second encoder of the CNN (140A, 140B) 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 (120A, 200A); and applying a second decoder of the CNN (140A, 140B) to the character grid, the intermediary segmentation mask, and the feature vector to generate the segmentation mask (200C, 200D) 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.