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

Download path #165

Open
sarperdag opened this issue Dec 16, 2024 · 1 comment
Open

Download path #165

sarperdag opened this issue Dec 16, 2024 · 1 comment

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!

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

2 participants