# ml-postech/ample architecture

> Architecture diagram of the GitHub repository ml-postech/ample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ml-postech/ample
- Repository: https://github.com/ml-postech/ample

## Overview

This repository implements experiments in comparison-based active preference learning and a companion set of multi-objective language-model training workflows. The primary experiment entry point simulates user preferences and iteratively acquires comparisons; separate scripts generate feedback and queries. The `rewardsincontext` package adds reward-conditioned generation, dataset preparation, supervised fine-tuning, PPO, and evaluation. Edges are limited to README-documented behavior and relationships visible in the provided excerpts or SOURCE INDEX; unsampled wiring is not inferred.

Main entry points: [`rewardsincontext/ppo/utils.py`](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/utils.py) (PPO Shared Utilities), [`rewardsincontext/ppo/multi_reward_models.py`](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/multi_reward_models.py) (PPO Reward Models), [`rewardsincontext/ric/generation.py`](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/generation.py) (RiC Generation), [`rewardsincontext/ric/multi_reward_models.py`](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/multi_reward_models.py) (RiC Reward Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_active["Active Preference Learning"]
  node_experiment["Preference Experiment<br/>[main.py]"]
  node_feedback["Feedback Generation"]
  node_queries["Query Generation"]
end

subgraph group_ric["Reward-in-Context"]
  node_ricmain["RiC Iteration Driver<br/>[main.py]"]
  node_dataset["Reward Dataset Prep"]
  node_rictraining["RiC Training<br/>[training.py]"]
  node_ricgeneration["RiC Generation<br/>[generation.py]"]
  node_ricevaluation["RiC Evaluation<br/>[evaluation.py]"]
  node_ricrewards["RiC Reward Models"]
end

subgraph group_ppo["PPO Training"]
  node_ppo["PPO Trainer<br/>[ppo.py]"]
  node_morlhf["Multi-Objective RLHF<br/>[morlhf.py]"]
  node_ppoeval["PPO Evaluation"]
  node_soupeval["Rewarded Soups Eval"]
  node_pporewards["PPO Reward Models"]
  node_sharedutils["PPO Shared Utilities<br/>[utils.py]"]
end

subgraph group_sft["Supervised Fine-Tuning"]
  node_sft["SFT Trainer<br/>[sft.py]"]
  node_sfteval["Multiobjective SFT Eval"]
  node_merge["LoRA Merge<br/>[merge_sft_lora.py]"]
end

node_user(("Experimenter"))

node_user -->|"configures"| node_experiment
node_experiment -->|"simulates preferences"| node_user
node_ricmain -->|"calls training"| node_rictraining
node_ricmain -->|"imports"| node_ricgeneration
node_queries -->|"imports"| node_pporewards
node_queries -->|"imports"| node_sharedutils
node_dataset -->|"uses reward models"| node_ricrewards
node_ricgeneration -->|"scores outputs"| node_ricrewards
node_ricgeneration -->|"imports"| node_sharedutils
node_ricevaluation -->|"scores outputs"| node_ricrewards
node_ricevaluation -->|"imports"| node_sharedutils
node_rictraining -->|"imports"| node_sharedutils
node_ppo -->|"scores responses"| node_pporewards
node_ppo -->|"imports"| node_sharedutils
node_morlhf -->|"loads rewards"| node_pporewards
node_morlhf -->|"imports"| node_sharedutils
node_ppoeval -->|"imports"| node_pporewards
node_ppoeval -->|"imports"| node_sharedutils
node_soupeval -->|"imports"| node_pporewards
node_soupeval -->|"imports"| node_sharedutils
node_sft -.->|"imports"| node_sharedutils
node_sfteval -->|"imports"| node_pporewards
node_sfteval -->|"imports"| node_sharedutils
node_merge -.->|"imports"| node_sharedutils

click node_experiment "https://github.com/ml-postech/ample/blob/main/main.py"
click node_feedback "https://github.com/ml-postech/ample/blob/main/generate_feedback.py"
click node_queries "https://github.com/ml-postech/ample/blob/main/generate_queries.py"
click node_ricmain "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/main.py"
click node_dataset "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/prepare_dataset_with_rewards.py"
click node_rictraining "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/training.py"
click node_ricgeneration "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/generation.py"
click node_ricevaluation "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/evaluation.py"
click node_ricrewards "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/multi_reward_models.py"
click node_ppo "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/ppo.py"
click node_morlhf "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/morlhf.py"
click node_ppoeval "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/eval_ppo_single_model.py"
click node_soupeval "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/eval_rewarded_soups.py"
click node_pporewards "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/multi_reward_models.py"
click node_sft "https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/sft.py"
click node_sfteval "https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/eval_multiobjective.py"
click node_merge "https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/merge_sft_lora.py"
click node_sharedutils "https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_experiment,node_feedback,node_queries toneBlue
class node_ricmain,node_dataset,node_rictraining,node_ricgeneration,node_ricevaluation,node_ricrewards toneAmber
class node_ppo,node_morlhf,node_ppoeval,node_soupeval,node_pporewards,node_sharedutils toneMint
class node_sft,node_sfteval,node_merge toneRose
class node_user toneIndigo
```

## Components

### Active Preference Learning

- [Preference Experiment](https://github.com/ml-postech/ample/blob/main/main.py): `main.py`
- [Feedback Generation](https://github.com/ml-postech/ample/blob/main/generate_feedback.py): `generate_feedback.py`
- [Query Generation](https://github.com/ml-postech/ample/blob/main/generate_queries.py): `generate_queries.py`

### Reward-in-Context

- [RiC Iteration Driver](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/main.py): `rewardsincontext/ric/main.py`
- [Reward Dataset Prep](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/prepare_dataset_with_rewards.py): `rewardsincontext/ric/prepare_dataset_with_rewards.py`
- [RiC Training](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/training.py): `rewardsincontext/ric/training.py`
- [RiC Generation](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/generation.py): `rewardsincontext/ric/generation.py`
- [RiC Evaluation](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/evaluation.py): `rewardsincontext/ric/evaluation.py`
- [RiC Reward Models](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ric/multi_reward_models.py): `rewardsincontext/ric/multi_reward_models.py`

### PPO Training

- [PPO Trainer](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/ppo.py): `rewardsincontext/ppo/ppo.py`
- [Multi-Objective RLHF](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/morlhf.py): `rewardsincontext/ppo/morlhf.py`
- [PPO Evaluation](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/eval_ppo_single_model.py): `rewardsincontext/ppo/eval_ppo_single_model.py`
- [Rewarded Soups Eval](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/eval_rewarded_soups.py): `rewardsincontext/ppo/eval_rewarded_soups.py`
- [PPO Reward Models](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/multi_reward_models.py): `rewardsincontext/ppo/multi_reward_models.py`
- [PPO Shared Utilities](https://github.com/ml-postech/ample/blob/main/rewardsincontext/ppo/utils.py): `rewardsincontext/ppo/utils.py`

### Supervised Fine-Tuning

- [SFT Trainer](https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/sft.py): `rewardsincontext/sft/sft.py`
- [Multiobjective SFT Eval](https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/eval_multiobjective.py): `rewardsincontext/sft/eval_multiobjective.py`
- [LoRA Merge](https://github.com/ml-postech/ample/blob/main/rewardsincontext/sft/merge_sft_lora.py): `rewardsincontext/sft/merge_sft_lora.py`

### Other components

- **Experimenter**

## Connections

- Experimenter → Preference Experiment: configures (evidence: `README.md`)
- Preference Experiment → Experimenter: simulates preferences (evidence: `README.md`)
- RiC Iteration Driver → RiC Training: calls training (evidence: `rewardsincontext/ric/main.py`)
- RiC Iteration Driver → RiC Generation: imports (evidence: `rewardsincontext/ric/main.py`)
- Query Generation → PPO Reward Models: imports (evidence: `generate_queries.py`)
- Query Generation → PPO Shared Utilities: imports (evidence: `generate_queries.py`)
- Reward Dataset Prep → RiC Reward Models: uses reward models (evidence: `rewardsincontext/ric/prepare_dataset_with_rewards.py`)
- RiC Generation → RiC Reward Models: scores outputs (evidence: `rewardsincontext/ric/generation.py`)
- RiC Generation → PPO Shared Utilities: imports (evidence: `rewardsincontext/ric/generation.py`)
- RiC Evaluation → RiC Reward Models: scores outputs (evidence: `rewardsincontext/ric/evaluation.py`)
- RiC Evaluation → PPO Shared Utilities: imports (evidence: `rewardsincontext/ric/evaluation.py`)
- RiC Training → PPO Shared Utilities: imports (evidence: `rewardsincontext/ric/training.py`)
- PPO Trainer → PPO Reward Models: scores responses (evidence: `rewardsincontext/ppo/ppo.py`)
- PPO Trainer → PPO Shared Utilities: imports (evidence: `rewardsincontext/ppo/ppo.py`)
- Multi-Objective RLHF → PPO Reward Models: loads rewards (evidence: `rewardsincontext/ppo/morlhf.py`)
- Multi-Objective RLHF → PPO Shared Utilities: imports (evidence: `rewardsincontext/ppo/morlhf.py`)
- PPO Evaluation → PPO Reward Models: imports (evidence: `rewardsincontext/ppo/eval_ppo_single_model.py`)
- PPO Evaluation → PPO Shared Utilities: imports (evidence: `rewardsincontext/ppo/eval_ppo_single_model.py`)
- Rewarded Soups Eval → PPO Reward Models: imports (evidence: `rewardsincontext/ppo/eval_rewarded_soups.py`)
- Rewarded Soups Eval → PPO Shared Utilities: imports (evidence: `rewardsincontext/ppo/eval_rewarded_soups.py`)
- SFT Trainer → PPO Shared Utilities: imports (evidence: `rewardsincontext/sft/sft.py`)
- Multiobjective SFT Eval → PPO Reward Models: imports (evidence: `rewardsincontext/sft/eval_multiobjective.py`)
- Multiobjective SFT Eval → PPO Shared Utilities: imports (evidence: `rewardsincontext/sft/eval_multiobjective.py`)
- LoRA Merge → PPO Shared Utilities: imports (evidence: `rewardsincontext/sft/merge_sft_lora.py`)
