Model
- Wrap a standard AI model with functionality necessary for
superduper
- Configure validation and training of a model on database data
Dependencies
(Optional dependencies)
Usage pattern
Note that Model
is an abstract base class which cannot be called directly.
To use Model
you should call any of its downstream implementations,
such as ObjectModel
or models in the AI-integrations.
Important notes
Model
instances can output data not-usually supported by your database.
This data will be encoded by default by pickle
, but more control may be added
by adding the parameters datatype=...
or output_schema=...
.
Implementations​
Here are a few superduper
native implementations:
ObjectModel
Use a self-built model (object
) or function with the system:
from superduper import ObjectModel
m = ObjectModel(
'my-model',
object=lambda x: x + 2,
)
db.apply(m)
QueryModel
Use a superduper
query to extract data from db
from superduper.components.model import QueryModel
query = ... # build a select query
m = QueryModel('my-query', select=query, key='<key-to-extract>')
db.apply(m)
APIModel
Request model outputs hosted behind an API:
from superduper.components.model import APIModel
m = APIModel('my-api', url='http://localhost:6666?token={MY_DEV_TOKEN}&model={model}&text={text}')
db.apply(m)
SequentialModel
Make predictions on the basis of a sequence of models:
from superduper.components.model import SequentialModel
m = SequentialModel(
'my-sequence',
models=[
model1,
model2,
model3,
]
)
db.apply(m)
See also