xenova / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
9.87k stars 582 forks source link

How to unload/destroy a pipeline? #715

Closed flatsiedatsie closed 1 month ago

flatsiedatsie commented 2 months ago

Question

I tried to find how to unload a pipeline to free up memory in the documentation, but couldn't find a mention of how to do that properly.

If there a proper way to "unload" a pipeline?

I'd be happy to add the answer to the documentation.

xenova commented 2 months ago

Hi there 👋 You can use pipeline.dispose(), which returns a promise that resolves when the pipeline has been disposed (see here). However, I definitely agree this should be documented and handled better... Let me know if you have any ideas!

flatsiedatsie commented 1 month ago

Is there a way to edit the documentation