Building your first Truss
Model
class. This class must have:
__init__
functionload
functionpredict
function__init__
function, set up any variables that will be used in the load
and predict
functions.
load
function of the Truss, we implement logic
involved in downloading the model and loading it into memory.
For this Truss example, we define a HuggingFace pipeline, and choose
the text-classification
task, which uses BERT for text classification under the hood.
Note that the load function runs once when the model starts.
predict
function of the Truss, we implement logic related
to actual inference. For this example, we just call the HuggingFace pipeline
that we set up in the load
function.