botong516/Constrained-LLMs

Alignment of Large Language Models with Constrained Learning

1

stars

2

commits

Python

primary language

May 28, 2026

updated

README

🧠 Alignment of Large Language Models with Constrained Learning

This repo contains the implementation for the submission: "Alignment of Large Language Models with Constrained Learning".


📁 Directory Structure

algorithms/ – Dual Optimization Algorithms

  • dual_optimizer.py: Implements the dual variable computation algorithm.

data_prep/ – Data Preparation Scripts

  • dataset_configs/: Custom dataset class definitions.
  • collect.py: Collects prompt datasets.
  • generate.py: Generates responses using a specified model and prompt dataset.
  • score.py: Evaluates responses using reward and cost models.
  • templates/: Prompt templates used for model-based generation.

trainers/ – Training Scripts

  • multi_shot_trainer.py: Multi-shot training loop.
  • one_shot_trainer.py: One-shot training loop.

gpt_based/ – GPT-Based Evaluation Scripts

  • adversarial_collect.py: Collects adversarial prompts.
  • gpt_generate.py: Generates responses for GPT-based evaluation.
  • gpt_eval.py: Evaluates responses using a GPT model as the evaluator.
  • templates/: Prompt templates for GPT-based evaluation.

visualize/ – Plotting Scripts

  • Scripts to generate all figures presented in the paper.

exec/ – Execution Scripts

  • Bash scripts for running the scripts.

Contributors

botong516

2 commits

botong516/Constrained-LLMs

Alignment of Large Language Models with Constrained Learning

1

stars

2

commits

Python

primary language

May 28, 2026

updated

README

🧠 Alignment of Large Language Models with Constrained Learning

This repo contains the implementation for the submission: "Alignment of Large Language Models with Constrained Learning".


📁 Directory Structure

algorithms/ – Dual Optimization Algorithms

  • dual_optimizer.py: Implements the dual variable computation algorithm.

data_prep/ – Data Preparation Scripts

  • dataset_configs/: Custom dataset class definitions.
  • collect.py: Collects prompt datasets.
  • generate.py: Generates responses using a specified model and prompt dataset.
  • score.py: Evaluates responses using reward and cost models.
  • templates/: Prompt templates used for model-based generation.

trainers/ – Training Scripts

  • multi_shot_trainer.py: Multi-shot training loop.
  • one_shot_trainer.py: One-shot training loop.

gpt_based/ – GPT-Based Evaluation Scripts

  • adversarial_collect.py: Collects adversarial prompts.
  • gpt_generate.py: Generates responses for GPT-based evaluation.
  • gpt_eval.py: Evaluates responses using a GPT model as the evaluator.
  • templates/: Prompt templates for GPT-based evaluation.

visualize/ – Plotting Scripts

  • Scripts to generate all figures presented in the paper.

exec/ – Execution Scripts

  • Bash scripts for running the scripts.

Contributors

botong516

2 commits

Languages

Python

96.6%

Shell

3.4%