Handling variable output array
This will help you understand how to handle multiple varrible outputs in Client side
Often time you will want to get 1 or more outputs from your model. Inferless allows you to get multiple outputs from your model. In this guide, we’ll walk you through the steps to handle multiple outputs in Inferless.
There are 2 scenations for handling multiple outputs:
- Singe Dimentional Result Arrays
- Multi Dimentional Result Arrays
Single Dimentional Result Arrays
In code app.py make sure you return a list for both size = 1 and size > 1
in the API response you will get the results as a list of values for example with shape 2
Limitations:
You can only return a single list of type (String/Int/Float/Boolean) in the API response.
If you have multiple outputs of for each input you can return a all the different outputs as seperate list.
Example :
in the API response you will get the results as a list of values for example with shape 2
Multi Dimentional Result Arrays
If you are returning a multi dimentional array you can return the output as a list of list.
Example :
If you make a API call with 2 sentences you will get the output where data will be of shape [1536] and the shape wil be [2,768]
In the clinet you will need to reshape the output to get the original shape.