# ankitsharma285/judge-audited-dpo architecture

> Architecture diagram of the GitHub repository ankitsharma285/judge-audited-dpo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankitsharma285/judge-audited-dpo
- Repository: https://github.com/ankitsharma285/judge-audited-dpo

## Overview

This repository is a research pipeline for bias-audited instruction-model post-training and evaluation. Its main workflow prepares disjoint SFT and preference-prompt data, trains an SFT policy, generates candidate answers, obtains judge-labeled preference pairs, trains DPO variants, then evaluates them against SFT on held-out and shifted prompts. Separate judge pilots validate labeling and evaluation judges against human annotations; a human spot-check supports the labeling audit. The README documents the major stages; source excerpts provide implementation detail for only some components.

Main entry points: [`sft_train.py`](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/sft_train.py) (Train SFT), [`generate_eval_completions.py`](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/generate_eval_completions.py) (Generate eval answers), [`data_prep.py`](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/data_prep.py) (Prepare datasets), [`label_pairs.py`](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/label_pairs.py) (Label preference pairs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data_training["Data and training"]
  node_data_prep["Prepare datasets<br/>[data_prep.py]"]
  node_sft_train["Train SFT<br/>[sft_train.py]"]
  node_sft_check["Check SFT<br/>[sft_check.py]"]
  node_dpo_train["Train DPO<br/>[dpo_train.py]"]
  node_closeout_checks["Closeout checks<br/>[closeout_checks.py]"]
end

subgraph group_preference["Preference labeling"]
  node_generate_completions["Sample completions"]
  node_label_pairs["Label preference pairs<br/>[label_pairs.py]"]
end

subgraph group_judge_audit["Judge validation"]
  node_judge_pilot["Validate labeling judge<br/>[judge_pilot.py]"]
  node_spotcheck_prepare["Prepare human spot-check"]
  node_spotcheck_score["Score human spot-check<br/>[spotcheck_score.py]"]
  node_eval_judge_pilot["Validate eval judge"]
end

subgraph group_evaluation["Held-out evaluation"]
  node_prepare_eval_split["Prepare eval split"]
  node_generate_eval_completions["Generate eval answers"]
  node_score_eval["Score model comparisons<br/>[score_eval.py]"]
end

node_researcher(("Researcher"))
node_alpaca_data[("Alpaca data")]
node_human_annotations[("Human annotations")]
node_human_reviewer(("Human reviewer"))

node_alpaca_data -->|"provides source"| node_data_prep
node_data_prep -->|"provides SFT data"| node_sft_train
node_data_prep -->|"provides prompts"| node_generate_completions
node_sft_train -->|"provides policy"| node_generate_completions
node_generate_completions -->|"provides candidates"| node_label_pairs
node_label_pairs -->|"provides preference pairs"| node_dpo_train
node_sft_train -->|"provides reference policy"| node_dpo_train
node_human_annotations -->|"validates against"| node_judge_pilot
node_human_annotations -->|"validates against"| node_eval_judge_pilot
node_label_pairs -->|"provides labeled pairs"| node_spotcheck_prepare
node_human_reviewer -->|"provides judgments"| node_spotcheck_score
node_spotcheck_prepare -->|"prepares audit"| node_spotcheck_score
node_alpaca_data -->|"provides eval prompts"| node_prepare_eval_split
node_prepare_eval_split -->|"provides eval prompts"| node_generate_eval_completions
node_sft_train -->|"provides SFT checkpoint"| node_generate_eval_completions
node_dpo_train -->|"provides DPO checkpoints"| node_generate_eval_completions
node_generate_eval_completions -->|"provides answers"| node_score_eval
node_eval_judge_pilot -->|"validates judge"| node_score_eval

click node_data_prep "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/data_prep.py"
click node_sft_train "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/sft_train.py"
click node_sft_check "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/sft_check.py"
click node_generate_completions "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/generate_completions.py"
click node_label_pairs "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/label_pairs.py"
click node_dpo_train "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/dpo_train.py"
click node_judge_pilot "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/judge_pilot.py"
click node_spotcheck_prepare "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/spotcheck_prepare.py"
click node_spotcheck_score "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/spotcheck_score.py"
click node_eval_judge_pilot "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/eval_judge_pilot.py"
click node_prepare_eval_split "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/prepare_eval_split.py"
click node_generate_eval_completions "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/generate_eval_completions.py"
click node_score_eval "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/score_eval.py"
click node_closeout_checks "https://github.com/ankitsharma285/judge-audited-dpo/blob/main/closeout_checks.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_data_prep,node_sft_train,node_sft_check,node_dpo_train,node_closeout_checks,node_human_reviewer toneBlue
class node_generate_completions,node_label_pairs,node_alpaca_data,node_human_annotations toneAmber
class node_judge_pilot,node_spotcheck_prepare,node_spotcheck_score,node_eval_judge_pilot toneMint
class node_prepare_eval_split,node_generate_eval_completions,node_score_eval toneRose
class node_researcher toneIndigo
```

## Components

### Data and training

- [Prepare datasets](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/data_prep.py): `data_prep.py`
- [Train SFT](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/sft_train.py): `sft_train.py`
- [Check SFT](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/sft_check.py): `sft_check.py`
- [Train DPO](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/dpo_train.py): `dpo_train.py`
- [Closeout checks](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/closeout_checks.py): `closeout_checks.py`

### Preference labeling

- [Sample completions](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/generate_completions.py): `generate_completions.py`
- [Label preference pairs](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/label_pairs.py): `label_pairs.py`

### Judge validation

- [Validate labeling judge](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/judge_pilot.py): `judge_pilot.py`
- [Prepare human spot-check](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/spotcheck_prepare.py): `spotcheck_prepare.py`
- [Score human spot-check](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/spotcheck_score.py): `spotcheck_score.py`
- [Validate eval judge](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/eval_judge_pilot.py): `eval_judge_pilot.py`

### Held-out evaluation

- [Prepare eval split](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/prepare_eval_split.py): `prepare_eval_split.py`
- [Generate eval answers](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/generate_eval_completions.py): `generate_eval_completions.py`
- [Score model comparisons](https://github.com/ankitsharma285/judge-audited-dpo/blob/main/score_eval.py): `score_eval.py`

### Other components

- **Researcher**
- **Alpaca data**
- **Human annotations**
- **Human reviewer**

## Connections

- Alpaca data → Prepare datasets: provides source (evidence: `data_prep.py`)
- Prepare datasets → Train SFT: provides SFT data (evidence: `README.md`)
- Prepare datasets → Sample completions: provides prompts (evidence: `README.md`)
- Train SFT → Sample completions: provides policy (evidence: `README.md`)
- Sample completions → Label preference pairs: provides candidates (evidence: `README.md`)
- Label preference pairs → Train DPO: provides preference pairs (evidence: `README.md`)
- Train SFT → Train DPO: provides reference policy (evidence: `README.md`)
- Human annotations → Validate labeling judge: validates against (evidence: `README.md`)
- Human annotations → Validate eval judge: validates against (evidence: `README.md`)
- Label preference pairs → Prepare human spot-check: provides labeled pairs (evidence: `spotcheck_prepare.py`)
- Human reviewer → Score human spot-check: provides judgments
- Prepare human spot-check → Score human spot-check: prepares audit (evidence: `spotcheck_prepare.py`)
- Alpaca data → Prepare eval split: provides eval prompts (evidence: `README.md`)
- Prepare eval split → Generate eval answers: provides eval prompts (evidence: `README.md`)
- Train SFT → Generate eval answers: provides SFT checkpoint (evidence: `README.md`)
- Train DPO → Generate eval answers: provides DPO checkpoints (evidence: `README.md`)
- Generate eval answers → Score model comparisons: provides answers (evidence: `README.md`)
- Validate eval judge → Score model comparisons: validates judge (evidence: `README.md`)
