ggerganov / ggml

Tensor library for machine learning
MIT License
11.22k stars 1.04k forks source link

Converting an arbritrary HF Transformer GPT2 to ggml format #519

Open JellePiepenbrock opened 1 year ago

JellePiepenbrock commented 1 year ago

Good afternoon,

I was taking a look at https://github.com/ggerganov/ggml/tree/master/examples/gpt-2. There are several ways to obtain ggml compliant GPT2 weights. If I would have a PyTorch-trained GPT2 model trained via the Transformers library, how would convert it to ggml?

It seems the Cerebras example could be using a PyTorch model (but I don't know for sure). Could anyone confirm that I could use something similar to the Cerebras example, or is it more complicated?

ebeyabraham commented 1 year ago

You can convert HF gpt2 to ggml using this script: https://gist.github.com/MrGrayCode/f8c795f1e2744dc5d5c7d8917c7846e0