About the possibility of adding client-accessible model metadata
Hello,
I would like to know if it's possible to add some custom, user-defined (at packaging time), meta-data about the model so that it can be retrieved by clients.
I describe my use case a little bit more: I usually have models with a variable number of inputs and outputs. Once the description of these inputs and outputs is captured in meta-data, my clients retrieve the metadata and build the necessary UI components to supply said data at inference. In this way I can accommodate any model and any task as long as the inputs types belong to the supported kind.
at inference time the mechanism is:
- ask the model "what kind of data do you expect?", "what do you return?" (get metadata)
- ask the user to supply what the model expects
- send this data over and expect a response containing the prediction (predict)
This is something I have been doing in custom made flask-like and GRPC serving code we have been using. I would like to completely switch to torch serve, because it's awesome. I may know how to write a custom handler to handle variable amounts of data being passed, but I don't know how I can query the model to get a description of expected inputs and outputs.
Would be awesome to have an API endpoint to get custom information about the model which could be information beyond the expected I/O (notes, git commit hash, and anything else).
I hope to receive your feedback. thanks for the great work.
@faustomilletari It is pretty much possible to package user-defined metadata inside a mar file and process it using a custom handler however at present there is no direct api for getting model metadata specifically, what model expects as input and the output it is going to return. You can refer following link to see how additional info can be packaged in mar file https://github.com/pytorch/serve/pull/408/files#diff-5ecf517e2f81911540a2dcb662ea5890R9
One of the approaches to solving your problem could be [bit hacky] -
- Create a custom handler which processes meta info [packaged as a part of mar file] as well as can handle prediction requests
- Torchserve at the frontend [api layer] doesn't interpret input data i.e. image or text or json data etc.. Taking advantage of this, you can send the first prediction request with JSON/txt data containing 'query for meta info'. And for a response, your custom handler should interpret input request i.e. if it is 'meta query' or 'actual prediction request' and accordingly process and send either meta info or predicted result.
Thanks a lot! I have solved by custom handler, returning metadata when no inputs are sent with the request :) that's pretty great!
Also, torch serving is fast! thanks for creating this. I love it