Skip to content

Improve Hugging Face integration#7

Open
NielsRogge wants to merge 1 commit intozhaorw02:mainfrom
NielsRogge:add_mixin
Open

Improve Hugging Face integration#7
NielsRogge wants to merge 1 commit intozhaorw02:mainfrom
NielsRogge:add_mixin

Conversation

@NielsRogge
Copy link

@NielsRogge NielsRogge commented Mar 25, 2025

Hi @zhaorw02, thanks for making the model available on 🤗 !

This PR improves the Hugging Face integration by:

  • equiping the model with from_pretrained and push_to_hub capabilities
  • use safetensors for weights serialization
  • have download stats for your model.

This is all supported thanks to the PyTorchModelHubMixin class. It works like so:

from lit_gpt.model_cache import GPTCache

model = GPTCache(...)

# equip with weights
filepath = hf_hub_download(repo_id="zzzrw/DeepMesh", filename="pytorch_model.bin")
state_dict = torch.load(filepath, map_location="cpu")
model.load_state_dict(state_dict)

# push to the hub
model.push_to_hub("zzzrw/DeepMesh")

# now anyone can use it like so:
model = GPTCache.from_pretrained("zzzrw/DeepMesh")

Feel free to try it out!

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