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 to fine tune Codegen? #16

Open
smith-co opened this issue Jun 9, 2022 · 18 comments
Open

How to fine tune Codegen? #16

smith-co opened this issue Jun 9, 2022 · 18 comments

Comments

@smith-co
Copy link

smith-co commented Jun 9, 2022

I would like to fine tune the Codegen model. Can you provide any documentation in this regard?

@shmuelhizmi
Copy link

+1

@enijkamp
Copy link
Contributor

The converted PyTorch models can be fine-tuned similarly to other causal LMs in HuggingFace.

See tutorials like http://reyfarhan.com/posts/easy-gpt2-finetuning-huggingface/.

@TheodoreGalanos
Copy link

Would you be releasing training code for the original models? Would be nice to try some on v3s (if possible).

@thisisanshgupta
Copy link

@enijkamp
Copy link
Contributor

enijkamp commented Jun 28, 2022

@TheodoreGalanos Working on a release for the JAX coding. I trained the models on TPU-v4 and have to resolve a blocker for v3.

@smith-co
Copy link
Author

@enijkamp @thisisanshgupta I am checking the link you have shared.

Still I think it would greatly help everyone if it is possible to provide fine tuning steps in the repo. 🙏

@Ontopic
Copy link

Ontopic commented Jul 13, 2022

I for one would appreciate any code/directions needed to run things on a TPU-v4. Great work all!

@enijkamp
Copy link
Contributor

enijkamp commented Jul 13, 2022

@thisisanshgupta @Ontopic Yes, I'm working on the release of my training library for TPU-v3/v4 and will keep you posted.

@tlkh
Copy link

tlkh commented Aug 17, 2022

Hello @enijkamp thank you for your work. Looking forward to some fine-tuning instructions and code.

Currently, I have tried to fine-tune as if it is GPT-2, but I am running into issues where the model's quality degrades significantly.

Is there any particular way the data has to be structured for fine-tuning? Currently, I am just concatenating together the prompts and code as follows:

def xyz():
    """abc"""
    code()

def xyz():
    """abc"""
    code()

@enijkamp
Copy link
Contributor

enijkamp commented Aug 17, 2022

@smith-co @thisisanshgupta @tlkh

For torch, I wrote up a minimal example in deepspeed, which can train the 16B on a ~24 GB gpu. You would need to sanity test this, optimize the configuration, plug in the data loader, and save the weights to disk:
https://github.com/salesforce/CodeGen/blob/main/jaxformer/hf/train_deepspeed.py

For jax, the training library in is undergoing sanity checks on TPU-v3 and should be released soon.

@enijkamp
Copy link
Contributor

@smith-co @thisisanshgupta @tlkh @Ontopic @TheodoreGalanos @shmuelhizmi A first release of the training code for TPU-v3/v4 is here:

https://github.com/salesforce/jaxformer

@zhangybuaa
Copy link

@enijkamp I want to fine-tune the model with my own code data, how should I build the dataset. Are there any requirements for the format of the dataset, whether the data needs to be labeled and what format should it be labeled in. Can some guidance or examples be given, thanks!

@calix
Copy link

calix commented Nov 18, 2022

@smith-co @thisisanshgupta @tlkh

For torch, I wrote up a minimal example in deepspeed, which can train the 16B on a ~24 GB gpu. You would need to sanity test this, optimize the configuration, plug in the data loader, and save the weights to disk: https://github.com/salesforce/CodeGen/blob/main/jaxformer/hf/train_deepspeed.py

For jax, the training library in is undergoing sanity checks on TPU-v3 and should be released soon.

Besides the VRAM, how much RAM would be required to train the model?

@glicerico
Copy link

@enijkamp , or anyone who has used jaxformer to fine-tune on TPU-v4, what is the approximate cost?

@enijkamp
Copy link
Contributor

enijkamp commented Jan 28, 2023

@glicerico Roughly speaking, cost is a function of the size of the model and data. How much data do you have? Which model do you want to fine-tune?

@glicerico
Copy link

glicerico commented Jan 30, 2023

@enijkamp , trying to reproduce the work by Shin and Van Durme, who used a few hundred (sentence, parse) pairs to fine tune codex for semantic parsing. I would like to do this with CodeGen. Seeing your results, I would probably want to fine tune the 16GB model.

@srnsrn120
Copy link

@enijkamp : I want to finetune mono model , Can you please share dataset format for python and details steps or notebook .

@watreyoung
Copy link

watreyoung commented Jun 9, 2023

@glicerico Roughly speaking, cost is a function of the size of the model and data. How much data do you have? Which model do you want to fine-tune?

Is there any more easier code script template withouth deep-speed to fine-tune CodeGen(350M)?
Plus: Is the data format same as other pre-trained model like CodeT5 or CodeBERT?
Looking forward to the reply.

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