Skip to content

Download path #165

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

Closed
sarperdag opened this issue Dec 16, 2024 · 4 comments
Closed

Download path #165

sarperdag opened this issue Dec 16, 2024 · 4 comments

Comments

@sarperdag
Copy link

sarperdag commented Dec 16, 2024

Amazing library!

I'd like to check if a model is downloaded or not before starting a download, however, I can't seem to find a way to check this. How can I see if a model is fully downloaded and ready to use before calling LLMEvaluator's load method?

@davidkoski
Copy link
Collaborator

You would need to use https://github.com/huggingface/swift-transformers Hub API to check that. That said, the libraries here make use of that.

ModelFactory returns a container with a fully downloaded model:

// e.g. VLMModelFactory.shared
let modelFactory: ModelFactory

// e.g. MLXVLM.ModelRegistry.paligemma3bMix4488bit
let modelConfiguration: ModelConfiguration

let container = try await modelFactory.loadContainer(configuration: modelConfiguration)

The is the code used to do the download -- you could call this directly if you were not using the code above:

Ultimately that calls the Hub API:

            let repo = Hub.Repo(id: id)
            let modelFiles = ["*.safetensors", "*.json"]
            return try await hub.snapshot(
                from: repo, matching: modelFiles, progressHandler: progressHandler)

See if that works for you!

@yliuiuc1990
Copy link

How do I delete these downloaded models?

@davidkoski
Copy link
Collaborator

If you are doing the command line tools they are in ~/Documents/huggingface/models. For the applications they are in something named after the bundle id, e.g. ~/Library/Containers/mlx.LLMEval. You can delete those directories entirely or selectively the files in them.

@yliuiuc1990
Copy link

Got it. Was able to get the URL in Debug mode and delete the unused model files. Thank you @davidkoski

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

No branches or pull requests

3 participants