Search code examples
restdeeppavlov

DeepPavlov REST API response format is not valid JSON


I currently have a DeepPavlov bot running in a docker container and using the rise RESTAPI.

My model is based on the English Q&A bot config, but trained on my own Q/A data. It has the identical chainer config.

It ends with the proba2labels/answers_vocab components:

    {
      "in": "y_pred_proba",
      "out": "y_pred_ids",
      "class_name": "proba2labels",
      "max_proba": true
    },
    {
      "in": "y_pred_ids",
      "out": "y_pred_answers",
      "ref": "answers_vocab"
    }
  ],
  "out": [
    "y_pred_answers",
    "y_pred_proba"
  ]

When I query it, I get a response in a format I personally haven't seen before:

[
  [
    "lower_voice_less_aggressive",
    [
      0.08536596502221176,
      0.05579590618528472,
      0.6571040611256327,
      0.01416261235595541,
      0.0551734506188862,
      0.048422377649025135,
      0.0404958436323856,
      0.04347978341061844
    ]
  ]
]

It would be far more usable if it was returned as valid JSON. Is there a way to configure DeepPavlov to do this?


Solution

  • No, there is no easy way to configure DeepPavlov to do this. You either should change DeepPavlov source code or write your own server with proper response format. In the second case, DeepPavlov model could be used with build_model method.