{"data":{"slug":"salesforce-codegen","name":"CodeGen","tagline":"A family of open-source models for program synthesis","github_url":"https://github.com/salesforce/CodeGen","owner":"salesforce","repo":"CodeGen","owner_avatar_url":"https://avatars.githubusercontent.com/u/453694?v=4","primary_language":"Python","stars":5180,"forks":420,"topics":["codex","generativemodel","languagemodel","llm","programsynthesis","tpu-acceleration"],"archived":false,"github_pushed_at":"2026-06-02T18:14:11+00:00","maintenance_label":"Slowing","stars_delta_30d":1,"url":"https://www.graphcanon.com/tools/salesforce-codegen","markdown_url":"https://www.graphcanon.com/tools/salesforce-codegen.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/salesforce-codegen","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=salesforce-codegen","description":"CodeGen is a family of open-source model for program synthesis. Trained on TPU-v4. Competitive with OpenAI Codex.","homepage_url":null,"license":"Apache-2.0","open_issues":49,"watchers":78,"ai_summary":"CodeGen is a series of models developed by Salesforce AI Research for generating code through program synthesis. It includes versions CodeGen1 and CodeGen2, with various sizes from 350M to 16B parameters. The models are trained on TPU-v4 and are competitive with OpenAI Codex.","readme_excerpt":"<p align=\"center\">\n  <img src=\"assets/codegen_logo.png\" width=\"25%\">\n</p>\n\n# CodeGen\nOfficial release for the **CodeGen1** and **CodeGen2** models (`350M`, `1B`, `3B`, `7B` `16B`) for **Program Synthesis** by [Salesforce AI Research](https://www.salesforceairesearch.com/).\n\n<p align=\"center\">\n  <img src=\"assets/two.gif\" width=\"60%\">\n</p>\n\n## News\n\n**July 2023**\n\n[**CodeGen2.5**](https://github.com/salesforce/CodeGen/tree/main/codegen25) released outperforming 16B parameter models with only 7B.\n\n**May 2023**\n\n**CodeGen2.0** released with strong infill sampling capability.\n\n**March 2022**\n\n**CodeGen1.0** released on par with OpenAI Codex at the time.\n\n## Publications\n\n[CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis](https://arxiv.org/abs/2203.13474)  \n[Erik Nijkamp](https://enijkamp.github.io/)\\*, [Bo Pang](https://scholar.google.com/citations?user=s9fNEVEAAAAJ&hl=en)\\*, [Hiroaki Hayashi](https://hiroakih.me/)\\*, [Lifu Tu](https://home.ttic.edu/~lifu/), [Huan Wang](https://scholar.google.com/citations?user=7NpTttkAAAAJ&hl=en), [Yingbo Zhou](https://scholar.google.com/citations?user=H_6RQ7oAAAAJ&hl=en), [Silvio Savarese](https://scholar.google.com/citations?user=ImpbxLsAAAAJ&hl=en), and [Caiming Xiong](https://scholar.google.com/citations?user=vaSdahkAAAAJ&hl=en)   \nICLR, 2023\n\n[CodeGen2: Lessons for Training LLMs on Programming and Natural Languages](https://arxiv.org/abs/2305.02309)   \n[Erik Nijkamp](https://enijkamp.github.io/)\\*, [Hiroaki Hayashi](https://hiroakih.me/)\\*, [Caiming Xiong](https://scholar.google.com/citations?user=vaSdahkAAAAJ&hl=en), [Silvio Savarese](https://scholar.google.com/citations?user=ImpbxLsAAAAJ&hl=en), and [Yingbo Zhou](https://scholar.google.com/citations?user=H_6RQ7oAAAAJ&hl=en)  \nICLR, 2023\n\n## Usage\n\nThe models are available on the [Hugging Face Hub](https://huggingface.co/models?search=salesforce+codegen).\n\n**CodeGen1.0**\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\ntokenizer = AutoTokenizer.from_pretrained(\"Salesforce/codegen-2B-mono\")\nmodel = AutoModelForCausalLM.from_pretrained(\"Salesforce/codegen-2B-mono\")\ninputs = tokenizer(\"# this function prints hello world\", return_tensors=\"pt\")\nsample = model.generate(**inputs, max_length=128)\nprint(tokenizer.decode(sample[0], truncate_before_pattern=[r\"\\n\\n^#\", \"^'''\", \"\\n\\n\\n\"]))\n```\n\n**CodeGen2.0**\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\ntokenizer = AutoTokenizer.from_pretrained(\"Salesforce/codegen2-7B\")\nmodel = AutoModelForCausalLM.from_pretrained(\"Salesforce/codegen2-7B\", trust_remote_code=True, revision=\"main\")\ninputs = tokenizer(\"# this function prints hello world\", return_tensors=\"pt\")\nsample = model.generate(**inputs, max_length=128)\nprint(tokenizer.decode(sample[0], truncate_before_pattern=[r\"\\n\\n^#\", \"^'''\", \"\\n\\n\\n\"]))\n```\n\n**CodeGen2.5**\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\ntokenizer = AutoTokenizer.from_pretrained(\"Salesforce/codegen25-7b-mono\", trust_remote_code=True)\nmodel = AutoModelForCausalLM.from_pretrained(\"Salesforce/codegen25-7b-mono\")\ninputs = tokenizer(\"# this function prints hello world\", return_tensors=\"pt\")\nsample = model.generate(**inputs, max_length=128)\nprint(tokenizer.decode(sample[0]))\n```\n\n## Training\n\nThe Jaxformer library for data pre-processing, training and fine-tuning the CodeGen models can be found here:\n\nhttps://github.com/salesforce/jaxformer\n\n## Citation\nIf you find our code or paper useful, please cite the paper:\n```bibtex\n@article{nijkamp2022codegen,\n  title={CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis},\n  author={Nijkamp, Erik and Pang, Bo and Hayashi, Hiroaki and Tu, Lifu and Wang, Huan and Zhou, Yingbo and Savarese, Silvio and Xiong, Caiming},\n  journal={ICLR},\n  year={2023}\n}\n\n@article{nijkamp2023codegen2,\n  title={CodeGen2: Lessons for Training LLMs on Programming and Natural Languages},\n  author={Ni","github_created_at":"2022-03-28T20:48:29+00:00","created_at":"2026-07-11T23:20:11.897318+00:00","updated_at":"2026-09-20T04:31:33.744441+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"codex","name":"codex"},{"slug":"generativemodel","name":"generativemodel"},{"slug":"languagemodel","name":"languagemodel"},{"slug":"llm","name":"llm"},{"slug":"programsynthesis","name":"programsynthesis"},{"slug":"tpu-acceleration","name":"tpu-acceleration"}],"trust":{"provenance":{"is_fork":false,"github_id":475174123,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-09-18T08:32:39.413Z","maintenance":{"label":"Slowing","score":36,"methodology":"github_public_v1","releases_90d":0,"days_since_push":107,"last_release_at":null,"stars_delta_30d":1,"open_issues_delta_30d":1},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-09-18T08:32:41.670Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-09-18T08:32:38.301Z"},"languages":{"value":["python"],"source":"github.language","observed_at":"2026-09-18T08:32:38.301Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-09-18T08:32:38.301Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["When you need an open-source alternative to proprietary models like OpenAI Codex for program synthesis.","If you require models that are trained on TPU-v4, offering potential performance benefits over models trained on other hardware.","For projects that benefit from the latest advancements in program synthesis, as CodeGen2.5 outperforms 16B parameter models with only 7B parameters.","When working with Python and the Hugging Face Transformers library, as CodeGen integrates seamlessly with these tools."],"when_not_to_use":["If your project strictly requires proprietary models with specific features not available in open-source alternatives.","When the hardware requirements for TPU-v4 trained models are not met or are not preferred in your environment.","If the latest version of CodeGen does not meet the specific performance or feature requirements of your project.","For projects that require models with a different licensing model, as CodeGen is licensed under Apache-2.0."],"source":"enrich:decision_facts","observed_at":"2026-09-18T10:30:08.236Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"CodeGen is a family of open-source models for program synthesis developed by Salesforce AI Research, available in various sizes from 350M to 16B parameters. It is trained on TPU-v4 and competes with OpenAI Codex."}]}}