Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Caching #5

Draft
wants to merge 9 commits into
base: frontend_demo
Choose a base branch
from
Draft

Model Caching #5

wants to merge 9 commits into from

Conversation

CalebCourier
Copy link
Contributor

This PR demonstrates how we can properly cache local models during post-install for quick recall in a containerized environment (i.e. docker).

Currently it saves to a relative directory in the root of wherever the validator is installed which isn't ideal. We will need to figure out what directories we can use both locally and in a docker environment that will not require additional permissions (the reason we're not writing to something like .cache).

Beside caching the model weights for quick retrieval, we also introduce a singleton pattern for initializing the instance of the model.

In order to test and demonstrate the above, we switch the default encoding function back to the sentence-transformer model.

Comment on lines +324 to +328
def st_embed_function(sources: list[str]):
print("Running st_embed_function...")
return DefaultEncodingModel().encode(sources)

embed_function = st_embed_function
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need st_embed_function anymore as a wrapper. We should be able to just pass DefaultEncodingModel().encode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant