Build TorchServe Custom Handle for Transformers model (Python) -- 3

Job ID: 32084649

Budget: $100 – $300 USD

I am implementing rest API for our PyTorch transformers ai model. We have decided to use Pytorch Serve. The inputs will be JSON and outputs will be text. There might be a need to make some helper files to the handle file in order to manipulate inputs to the correct format.

We need help implementing Pytorch Torchserve for our Pytorch Transformers Model. The handle needs to be created to allow posting inputs using rest API in JSON format and output should be the prediction of our model. Also, classification codes need to be coded in order to allow the inputs to be in a specific format, but our current model has already examples from where the developer can start. The code is using docker.

implement https://github.com/pytorch/serve to this model https://github.com/JasonObeid/Chart2Text.

So after the job, we would have a modified repo, which contains dockerfile and modifications to allow this:

1. Request to rest API with JSON data in this format:
At the moment model is trained using this type of CSV-data example:
https://github.com/JasonObeid/Chart2Text/blob/master/dataset/multiColumn/data/0.csv

Data that need to be preprocessed (etc/templatePreprocess.py) for the model when submitted via rest API example:
// Starts
{
"heading": "People shot to death by U.S. police , by race 2017 to 2019",
"xAxisLabel": "Race",
"yAxisLabel": "Shots",
"dataLabel1": "White",
"data1": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel2": "Black",
"data2": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel3": "Hispanic",
"data3": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel4": "Other",
"data4": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel5": "Unknown",
"data5": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
]
}
// Ends

2. So after submitting that above payload to rest API, the rest API should return prediction like this (model prediction is in summaries section:
{
"summaries": [
"This statistic shows Average number in leading economies worldwide in 2050. In the Greece Croatia , Average number stood at 1.56 children per woman. In the Greece, Average users paid 1.5 children per woman."
],
"model": "THISISMODELNAME",
"object": "summary",
"query": {
"heading": "People shot to death by U.S. police , by race 2017 to 2019",
"xAxisLabel": "Race",
"yAxisLabel": "Shots",
"dataLabel1": "White",
"data1": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel2": "Black",
"data2": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel3": "Hispanic",
"data3": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel4": "Other",
"data4": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
],
"dataLabel5": "Unknown",
"data5": [
{ "x": "2017", "y": 457 },
{ "x": "2018", "y": 399 },
{ "x": "2019*", "y": 312 }
]
}
}

3. After modifications, you should create dockerfile for torchserve to serve this rest api in docker container.