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

How can I obtain .gguf file if I use my onw dataset fine-tuned on clip? #103

Open
cr42yhc1 opened this issue Oct 8, 2024 · 2 comments
Open

Comments

@cr42yhc1
Copy link

cr42yhc1 commented Oct 8, 2024

Hi, Thank you for your contribution.
I have fine-tuned a CLIP model using my own dataset and currently have the checkpoint in PyTorch format with a .pth extension. I am looking to run this model in C++. Could you guide me on how to convert this .pth file into either the Hugging Face standard format or the gguf format? Any assistance or resources would be greatly appreciated.

@monatis
Copy link
Owner

monatis commented Oct 8, 2024

Hi, how did you finetune it? Currently this repo supports converting CLIP models from OpenAI and OpenCLIP in Huggingface format. So you need to first convert it to HF format, then you can follow the guide here.

@cr42yhc1 cr42yhc1 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
@cr42yhc1
Copy link
Author

cr42yhc1 commented Oct 9, 2024

Hi,thank you for your repply.

For fine-tuning code, you can refer to this openai/CLIP#83 and CSDN. If you need it, I can also provide my training code.

Is safetensors the HF format you mentioned? I tried to convert a .pth file to a .safetensors file using the following code, but your convert_hf_to_gguf.py script seems to require other related files. I attempted to use the related files from Huggingface, but encountered other issues. Maybe I made some mistakes during the operation.

import safetensors.torch
import torch
import safetensors

def convert(root):
    pth = torch.load(root, map_location='cpu', weights_only=True)
    safetensors.torch.save_file(pth, 'woce.safetensors')

root = './epoch_29.pth'
convert(root)

截屏2024-10-09 16 27 17

@cr42yhc1 cr42yhc1 reopened this Oct 9, 2024
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