This message was deleted.
# ask-for-help
s
This message was deleted.
c
Yes it is possible, you can save custom_objects together with a model
✅ 1
e
Does this mean they need to be picklable?
c
Yes if it’s dynamically generated during training, you need a way to serialize them
If it’s static, it doesn’t hurt to leave them in code
e
I think (for example) we couldn’t pickle a type of vector storage format out of Facebook called a FAISS index. All we could do to persist it is write it directly to disk in a binary format and read it later.
Is there an option that does not require pickling? I think this is going to be an issue for our next project :/
c
@Eric Riddoch yes absolutely, that’s possible. option 1 is to put the binary file under your Bento project directory and package it during
bentoml build
option 2 is to use lower level model store API and do something like this:
Copy code
with bentoml.models.create(
        name,
        module=MODULE_NAME,
        api_version=API_VERSION,
        labels=labels,
        custom_objects=custom_objects,
        external_modules=external_modules,
        metadata=metadata,
        context=context,
        signatures=signatures,
    ) as bento_model:
        tf.keras.save_model(model, bento_model.path_of(MODEL_FILENAME))
        faiss.write_index(index, bento_model.path_of("my.index"))
        return bento_model
e
Oh, nice! I'll see if I can get one of these to work. Thanks!