ml-commons: [BUG] post_process_function of painless script does not work while creating externally hosted models using http

What is the bug? post_process_function of painless script does not work while creating externally hosted models using http. This shows up in predict API

How can one reproduce the bug? Take any text2text generation inference API endpoint model from Hugging Face. Create http request and add below mentioned post_process_function but it does not work as expected.

The HF Models comes with response like this

[
    {
        "generated_text": "Your Generated text"
    }
]

So we need to translate this using post_process_function

"post_process_function": "\n return params['response'][0].generated_text; \n"

I have this

[
    {
        "generated_text": "Your Generated text"
    }
]

and i want to convert it to this below using post process function

  {
       "completion": "Your Generated text"
   }

below is the post_process_function

"post_process_function": "\n def json = \"{\" +\n \"\\\"completion\\\":\\\"\" + params['response'][0].generated_text + \"\\\" }\";\n return json;\n "

But it never works with _predict APIs

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18

Most upvoted comments

Hi @ylwu-amzn , i tested this and it worked perfectly. Thanks for this and we can close this