CoolFace
Modelpublic

Salesforce/codegen-2B-multi

sourceHugging Facebsd-3-clauseupdated 2y agoView on Hugging Face
42likes762downloads
README.md63 linesDownload Raw Back to root
1---2license: bsd-3-clause3---4# CodeGen (CodeGen-Multi 2B)5 6## Model description7 8CodeGen is a family of autoregressive language models for **program synthesis** from the paper: [A Conversational Paradigm for Program Synthesis](https://arxiv.org/abs/2203.13474) by Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, Caiming Xiong. The models are originally released in [this repository](https://github.com/salesforce/CodeGen), under 3 pre-training data variants (`NL`, `Multi`, `Mono`) and 4 model size variants (`350M`, `2B`, `6B`, `16B`).9 10The checkpoint included in this repository is denoted as **CodeGen-Multi 2B** in the paper, where "Multi" means the model is initialized with *CodeGen-NL 2B* and further pre-trained on a dataset of multiple programming languages, and "2B" refers to the number of trainable parameters.11 12## Training data13 14This checkpoint (CodeGen-Multi 2B) was firstly initialized with *CodeGen-NL 2B*, and then pre-trained on [BigQuery](https://console.cloud.google.com/marketplace/details/github/github-repos), a large-scale dataset of multiple programming languages from GitHub repositories. The data consists of 119.2B tokens and includes C, C++, Go, Java, JavaScript, and Python.15 16## Training procedure17 18CodeGen was trained using cross-entropy loss to maximize the likelihood of sequential inputs.19The family of models are trained using multiple TPU-v4-512 by Google, leveraging data and model parallelism.20See Section 2.3 of the [paper](https://arxiv.org/abs/2203.13474) for more details.21 22## Evaluation results23 24We evaluate our models on two code generation benchmark: HumanEval and MTPB. Please refer to the [paper](https://arxiv.org/abs/2203.13474) for more details.25 26 27## Intended Use and Limitations28 29As an autoregressive language model, CodeGen is capable of extracting features from given natural language and programming language texts, and calculating the likelihood of them.30However, the model is intended for and best at **program synthesis**, that is, generating executable code given English prompts, where the prompts should be in the form of a comment string. The model can complete partially-generated code as well.31 32## How to use33 34This model can be easily loaded using the `AutoModelForCausalLM` functionality:35 36```python37from transformers import AutoTokenizer, AutoModelForCausalLM38tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen-2B-multi")39model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen-2B-multi")40 41text = "def hello_world():"42input_ids = tokenizer(text, return_tensors="pt").input_ids43 44generated_ids = model.generate(input_ids, max_length=128)45print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))46```47 48## Ethical Considerations49 50This release is for research purposes only in support of an academic paper. Our models, datasets, and code are not specifically designed or evaluated for all downstream purposes. We strongly recommend users evaluate and address potential concerns related to accuracy, safety, and fairness before deploying this model. We encourage users to consider the common limitations of AI, comply with applicable laws, and leverage best practices when selecting use cases, particularly for high-risk scenarios where errors or misuse could significantly impact people’s lives, rights, or safety. For further guidance on use cases, refer to our AUP and AI AUP. 51 52 53## BibTeX entry and citation info54 55```bibtex56@article{Nijkamp2022ACP,57  title={A Conversational Paradigm for Program Synthesis},58  author={Nijkamp, Erik and Pang, Bo and Hayashi, Hiroaki and Tu, Lifu and Wang, Huan and Zhou, Yingbo and Savarese, Silvio and Xiong, Caiming},59  journal={arXiv preprint},60  year={2022}61}62```63