CodeGen is an open-source family of models for program synthesis, released by Salesforce AI Research, with multiple sizes including 350M, 1B, 3B, 7B, and 16B. The repository provides usage examples, training notes, and related publications.
Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).
What it is
Official release for the CodeGen1 and CodeGen2 models (350M, 1B, 3B, 7B, 16B) for Program Synthesis by Salesforce AI Research.
How it works
The README states that CodeGen is a family of open-source models for program synthesis. It mentions training on TPU-v4 and provides usage examples showing how to load models from Hugging Face Hub and generate code with transformers.
Getting started
Usage examples show how to load tokenizers and models:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen-2B-mono")
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen-2B-mono")
inputs = tokenizer("# this function prints hello world", return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0], truncate_before_pattern=[r"\n\n^#", "^'''", "\n\n\n"]))
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-7B")
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen2-7B", trust_remote_code=True, revision="main")
inputs = tokenizer("# this function prints hello world", return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0], truncate_before_pattern=[r"\n\n^#", "^'''", "\n\n\n"]))
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen25-7b-mono", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen25-7b-mono")
inputs = tokenizer("# this function prints hello world", return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0]))
Recent releases
The News section mentions CodeGen2.5 released in July 2023, CodeGen2.0 in May 2023, and CodeGen1.0 in March 2022. The latest RELEASES entry shows none.
Traction
Stars: 5180 Forks: 421 Open issues: 48
Behind the repo
Not provided in the README.
Caveats
License: Apache-2.0 Created: 2022-03-28 Last push: 2026-06-02 Topics include codex, generativemodel, languagemodel, llm, programsynthesis, tpu-acceleration "CodeGen is an open-source model family for program synthesis, trained on TPU-v4, and content includes usage on Hugging Face hub and related publications."






