CIS 6270 Course Code
This repository contains code examples for CIS 6270, organized by lecture. We will develop the implementations alongside the course material, which connect the mathematical definitions, training objectives, and sampling equations to the executable PyTorch code herein. Each lecture directory contains its examples, data, and implementation notes; additional directories will accompany later lectures.
Lecture index
| Lectures | Topics | Code and documentation |
|---|---|---|
| 2 and 3 | Continuous generative models, flow matching, diffusion, and guidance | Guide Β· Flow matching Β· Diffusion |
Installation
Use Python 3.11, or another compatible Python version at least 3.10, in a new
virtual environment. The current examples were tested with PyTorch 2.9.1 and
Transformers 4.57.6, as specified in requirements.txt.
git clone https://huggingface.co/ChatterjeeLab/CIS6270
cd CIS6270
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
On Windows PowerShell, create the environment with python -m venv .venv
and activate it with .venv\Scripts\Activate.ps1.
Run the Lectures 2 and 3 examples
From the repository root:
python lectures_02_03/esm2_flow_guidance.py --epochs 200 --samples 8
python lectures_02_03/esm2_diffusion_guidance.py --epochs 200 --samples 8
Both scripts train on ESM-2 residue embeddings and compare classifier-free guidance, single-objective reward steering, and scalarized multi-objective steering. We use the same property definitions, normalization, and final constrained decoder to compare the flow and diffusion implementations.
The first run downloads the public ESM-2 checkpoint. Each script then writes generated sequences and model parameters to its own output directory. The lecture guide describes the data format, training and sampling settings, property calculations, normalization, and residue-count constraint, with commands for using a custom dataset.
Repository organization
CIS6270/
βββ README.md
βββ requirements.txt
βββ LICENSE
βββ lectures_02_03/
β βββ README.md
β βββ esm2_flow_guidance.py
β βββ esm2_diffusion_guidance.py
β βββ esm2_example.csv
β βββ GUIDANCE_NOTES.md
βββ tests/
βββ test_examples.py
Installation instructions and the lecture index are maintained at the repository root. Lecture-specific commands, mathematical explanations, and references accompany the corresponding code.
Tests
python -m unittest discover -s tests -v
The current unit tests cover property annotations, scalarization weights, reward gradients, DDPM schedule indexing, and constrained decoding.
License
The repository code is distributed under the MIT License. Pretrained model weights are downloaded from their original repositories under the corresponding distribution terms.
