Views
No views yet

CoDA-1.7B-Instruct — optimized for code generation tasks with bidirectional diffusion modeling (1.7B parameters)CoDA-1.7B-Base — diffusion foundation model with bidirectional diffusion architecture, ideal for further fine-tuning and RL training[!NOTE] This model card is dedicated to theCoDA-1.7B-Instructmodel. Check out our model collection for other variants.
| Model | HumanEval | HumanEval+ | MBPP | MBPP+ | EvalPlus |
|---|---|---|---|---|---|
| CoDA-Base | 29.3 | 23.8 | 35.2 | 46.0 | 34.9 |
| CoDA-Instruct | 54.3 | 47.6 | 47.2 | 63.2 | 55.4 |
| Dream-Base | 56.7 | 50.0 | 68.7 | 57.4 | 53.7 |
| Dream-7B-Instruct | 57.9 | 53.7 | 68.3 | 56.1 | 54.9 |
| LLaDA-8B-Instruct | 35.4 | 31.7 | 31.5 | 28.6 | 30.2 |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model_name = "Salesforce/CoDA-v0-Instruct"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7# Generate code
8prompt = "Write a Python function to calculate fibonacci numbers"
9inputs = tokenizer(prompt, return_tensors="pt")
10outputs = model.generate(
11 **inputs,
12 max_tokens=256,
13 diffusion_steps=128,
14 temperature=0.0
15)
16print(tokenizer.decode(outputs[0]))1# Clone the repository
2git clone https://github.com/SalesforceAIResearch/CoDA
3cd CoDA
4
5# Set up environment
6python3 -m venv .venv
7source .venv/bin/activate
8pip install -r serving/requirements.txt
9
10# Export your Hugging Face token
11export HF_TOKEN="hf_..."
12
13# Start the server
14bash serving/fast-api/start_server.shhttp://localhost:8000.1python serving/fast-api/chat_cli.py \
2 --base-url http://localhost:8000 \
3 --model Salesforce/CoDA-v0-Instruct \
4 --stream \
5 --show-meta1export MAX_TOKENS=512 # Maximum tokens to generate
2export TEMPERATURE=0.7 # Sampling temperature
3export TOP_P=0.9 # Nucleus sampling threshold
4export STEPS=128 # Number of diffusion steps
5export ALG="entropy" # Sampling algorithm
6export ALG_TEMP=0.1 # Algorithm temperature
7export BLOCK_LENGTH=32 # Block size for processingSTEPS=64, TEMPERATURE=0.0STEPS=128, TEMPERATURE=0.7, TOP_P=0.9STEPS=256, TEMPERATURE=0.5, TOP_P=0.951# Clone the repository
2git clone https://github.com/SalesforceAIResearch/CoDA
3cd CoDA1# Configure TPU environment
2cd pre-train
3cp env.example .env # Add your TPU metadata
4bash setup_tpu.sh
5
6# Launch pre-training
7bash recipes/midtrain_v4_512.sh1# Set up fine-tuning environment
2cd post-train/LLaMA-Factory
3pip install -r requirements.txt
4
5# Configure dataset and run fine-tuning
6bash ../../run_sft.sh1cd evaluation/lm_eval
2bash eval_mbpp_humaneval.sh1@misc{coda2025,
2 title={CoDA: Coding LM via Diffusion Adaptation},
3 author={Chen, Haolin and Wang, Shiyu and Qin, Can and Pang, Bo and Liu, Zuxin and Qiu, Jielin and Zhang, Jianguo and Zhou, Yingbo and Chen, Zeyuan and Xu, Ran and Heinecke, Shelby and Savarese, Silvio and Xiong, Caiming and Wang, Huan and Yao, Weiran},
4 year={2025},
5 publisher={Salesforce AI Research}
6}