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

Option to Disable Model Caching When Using "pipeline" #35337

Open
FadiAmon opened this issue Dec 19, 2024 · 1 comment
Open

Option to Disable Model Caching When Using "pipeline" #35337

FadiAmon opened this issue Dec 19, 2024 · 1 comment
Labels
Feature request Request for a new feature

Comments

@FadiAmon
Copy link

Feature request

Add a new parameter disable_caching to the pipeline function to control model caching. This feature would be useful for users who need to load models temporarily without storing them in cache, reducing unnecessary disk usage and improving performance for one-time use cases.

from transformers import pipeline
# Example of disabling caching
pipe = pipeline(task="zero-shot-classification", model="typeform/distilbert-base-uncased-mnli", disable_caching=True)

Motivation

When testing different models temporarily, it's inefficient to cache each model, especially when they will not be reused. This can lead to wasted disk space and potential performance issues and errors for users who frequently experiment with various models.

Your contribution

I am not very experienced with the library but I am willing to contribute to the initial implementation and testing of this feature if no one wants to work on it.

@FadiAmon FadiAmon added the Feature request Request for a new feature label Dec 19, 2024
@Rocketknight1
Copy link
Member

Hi @FadiAmon, I'm not sure we can add this! It's not really possible to load a model without downloading it first, so the files will have to be downloaded somewhere. The only way to reduce cache usage would be to delete the model files after the model has finished loading.

If this is a problem for you, you can use the existing cache_dir argument to control where models are downloaded. You can then empty this directory as part of your script, or even make it a TemporaryDirectory() so it automatically gets cleaned up after the model has been loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants