Custom Model
A custom model can be created with few steps.
Import a
BaseModel
class from genai-stack.Create a class with desired name(class name) and inherit the
BaseModel
class.Implement two methods:
load()
- Load the model. This method is run at once on class instantiation.Set a class attribute, which can be later accessed in the predict() method. This way a lot of time can be saved during prediction which avoids model loading during prediction.
predict()
- Accept a parameter namedquery
, which should hold the input to the model. Make prediction and return the generated prediction.
Example
Below code creates a GPT Neo model with GenAI Stack.
Last updated