{"data":{"slug":"salesforce-codegen","name":"CodeGen","tagline":"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":5177,"forks":423,"topics":["codex","generativemodel","languagemodel","llm","programsynthesis","tpu-acceleration"],"archived":false,"github_pushed_at":"2026-06-02T18:14:11+00:00","maintenance_label":"Steady","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":48,"watchers":78,"ai_summary":"CodeGen is a series of large language models for code generation and synthesis tasks. These models are trained on TPUs and include versions like CodeGen1, CodeGen2, and CodeGen2.5, each with varying capabilities from simple to advanced code infill sampling.","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-07-12T00:07:24.717819+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":"programsynthesis","name":"programsynthesis"},{"slug":"tpu-acceleration","name":"tpu-acceleration"},{"slug":"llm","name":"llm"},{"slug":"generativemodel","name":"generativemodel"},{"slug":"languagemodel","name":"languagemodel"},{"slug":"codex","name":"codex"}],"trust":{"provenance":{"is_fork":false,"github_id":475174123,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T23:20:15.732Z","maintenance":{"label":"Steady","score":60,"methodology":"github_public_v1","releases_90d":0,"days_since_push":39,"last_release_at":null},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T23:20:16.194Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-12T00:05:52.596Z"},"languages":{"value":["python"],"source":"github.language","observed_at":"2026-07-12T00:05:52.596Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-07-12T00:05:52.596Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["When you require high-performance model training and code generation that matches or exceeds the performance of OpenAI Codex on specific tasks","If your project benefits from working with open-source models under Apache License 2.0, providing flexibility in implementation without restrictive licensing terms","For applications that demand advanced infill sampling capabilities as supported by CodeGen2 and later versions"],"when_not_to_use":["In scenarios where the model's primary use is not centered around code generation or program synthesis, as its specialized training may limit its effectiveness for other types of generative tasks","If your project strictly requires a smaller memory footprint or simpler deployment because advanced models like CodeGen2.5 require significant computational resources and setup"],"source":"enrich:decision_facts","observed_at":"2026-07-12T00:06:20.726Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"CodeGen is a series of open-source large language models designed for program synthesis. Trained on TPUs, CodeGen offers several versions with varying capabilities from basic code generation to advanced infill sampling."}]}}