# sourangshupal/sagemaker-model-customization-demo architecture

> Architecture diagram of the GitHub repository sourangshupal/sagemaker-model-customization-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sourangshupal/sagemaker-model-customization-demo
- Repository: https://github.com/sourangshupal/sagemaker-model-customization-demo

## Overview

This repository is a set of local command-line workflows for serverless SageMaker model customization. ContractNLI data preparation feeds LoRA SFT, while a separate preference-data path feeds DPO; both produce managed model artifacts. Evaluation branches include managed custom scoring, local base-versus-SFT comparison, and Bedrock-backed LLM judging. Deployment scripts serve the SFT, base, and DPO models through SageMaker endpoints and support teardown. Edges reflect the excerpts and README; the workshop helpers and cloud services are external dependencies.

Main entry points: [`scripts/config.py`](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/config.py) (Environment config), [`scripts/03_evaluate_sft.py`](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/03_evaluate_sft.py) (Managed SFT scoring), [`scripts/06_evaluate_dpo.py`](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/06_evaluate_dpo.py) (DPO LLM judge), [`scripts/04_deploy_sft.py`](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04_deploy_sft.py) (SFT deployment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_contractprep["ContractNLI prep"]
  node_sftdata[("SFT datasets")]
  node_dpoprep["Preference prep<br/>[05_train_dpo.py]"]
  node_dpodata[("DPO datasets<br/>[05_train_dpo.py]")]
end

subgraph group_training["Model training"]
  node_sfttrain["SFT LoRA training<br/>[02_train_sft.py]"]
  node_dpotrain["DPO training<br/>[05_train_dpo.py]"]
  node_modelregistry[("Model packages")]
end

subgraph group_evaluation["Evaluation"]
  node_sfteval["Managed SFT scoring<br/>[03_evaluate_sft.py]"]
  node_abcompare["Local A/B scoring<br/>[04c_ab_compare.py]"]
  node_dpoeval["DPO LLM judge<br/>[06_evaluate_dpo.py]"]
end

subgraph group_serving["Deployment"]
  node_sftdeploy["SFT deployment<br/>[04_deploy_sft.py]"]
  node_basedeploy["Base deployment<br/>[04b_deploy_base.py]"]
  node_dpodeploy["DPO deployment<br/>[04d_deploy_dpo.py]"]
  node_sftendpoint["SFT vLLM endpoint<br/>[04_deploy_sft.py]"]
  node_baseendpoint["Base vLLM endpoint<br/>[04b_deploy_base.py]"]
  node_dpoendpoint["DPO vLLM endpoint<br/>[04d_deploy_dpo.py]"]
end

subgraph group_shared["Configuration"]
  node_config["Environment config<br/>[config.py]"]
end

node_engineer(("Local operator"))
node_workshop["Workshop helpers"]
node_scorer["ContractNLI scorer"]
node_mlflow[("MLflow tracking")]
node_bedrock["Amazon Bedrock"]
node_sagemaker["SageMaker AI"]
node_s3[("Amazon S3")]

node_engineer -->|"runs"| node_contractprep
node_engineer -->|"runs"| node_sfttrain
node_engineer -->|"runs"| node_sfteval
node_engineer -->|"runs"| node_sftdeploy
node_engineer -->|"runs"| node_dpoprep
node_engineer -->|"runs"| node_dpotrain
node_engineer -->|"runs"| node_dpoeval
node_engineer -->|"runs"| node_dpodeploy
node_contractprep -->|"loads settings"| node_config
node_contractprep -->|"uses helpers"| node_workshop
node_contractprep -->|"uploads splits"| node_s3
node_contractprep -->|"registers"| node_sftdata
node_dpoprep -->|"loads settings"| node_config
node_dpoprep -->|"uploads splits"| node_s3
node_dpoprep -->|"registers"| node_dpodata
node_dpotrain -->|"reads"| node_dpodata
node_sfttrain -->|"reads"| node_sftdata
node_sfttrain -->|"loads settings"| node_config
node_sfttrain -->|"publishes model"| node_modelregistry
node_dpotrain -->|"loads settings"| node_config
node_dpotrain -->|"publishes model"| node_modelregistry
node_sfteval -->|"loads settings"| node_config
node_sfteval -->|"reads model"| node_modelregistry
node_sfteval -->|"reads test set"| node_sftdata
node_sfteval -->|"registers evaluator"| node_scorer
node_sfteval -->|"launches evaluation"| node_sagemaker
node_sfteval -->|"tracks results"| node_mlflow
node_dpoeval -->|"loads settings"| node_config
node_dpoeval -->|"reads model"| node_modelregistry
node_dpoeval -->|"reads test set"| node_dpodata
node_dpoeval -->|"judges outputs"| node_bedrock
node_dpoeval -->|"tracks results"| node_mlflow
node_dpoeval -->|"launches evaluation"| node_sagemaker
node_abcompare -->|"uses scorer"| node_workshop
node_abcompare -->|"invokes"| node_sftendpoint
node_abcompare -->|"invokes"| node_baseendpoint
node_sftdeploy -->|"loads settings"| node_config
node_sftdeploy -->|"reads checkpoint"| node_modelregistry
node_sftdeploy -->|"creates endpoint"| node_sagemaker
node_sftdeploy -->|"configures"| node_sftendpoint
node_sftdeploy -->|"loads checkpoint"| node_s3
node_basedeploy -->|"loads settings"| node_config
node_basedeploy -->|"creates endpoint"| node_sagemaker
node_basedeploy -->|"configures"| node_baseendpoint
node_basedeploy -->|"loads artifact"| node_s3
node_dpodeploy -->|"loads settings"| node_config
node_dpodeploy -->|"reads checkpoint"| node_modelregistry
node_dpodeploy -->|"creates endpoint"| node_sagemaker

click node_config "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/config.py"
click node_contractprep "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/01_data_prep_sft.py"
click node_sftdata "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/01_data_prep_sft.py"
click node_dpoprep "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py"
click node_dpodata "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py"
click node_sfttrain "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/02_train_sft.py"
click node_dpotrain "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py"
click node_sfteval "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/03_evaluate_sft.py"
click node_abcompare "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04c_ab_compare.py"
click node_dpoeval "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/06_evaluate_dpo.py"
click node_sftdeploy "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04_deploy_sft.py"
click node_basedeploy "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04b_deploy_base.py"
click node_dpodeploy "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04d_deploy_dpo.py"
click node_sftendpoint "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04_deploy_sft.py"
click node_baseendpoint "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04b_deploy_base.py"
click node_dpoendpoint "https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04d_deploy_dpo.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_contractprep,node_sftdata,node_dpoprep,node_dpodata toneBlue
class node_sfttrain,node_dpotrain,node_modelregistry,node_mlflow,node_s3 toneAmber
class node_sfteval,node_abcompare,node_dpoeval toneMint
class node_sftdeploy,node_basedeploy,node_dpodeploy,node_sftendpoint,node_baseendpoint,node_dpoendpoint toneRose
class node_config,node_engineer,node_workshop,node_scorer,node_bedrock,node_sagemaker toneIndigo
```

## Components

### Data preparation

- [ContractNLI prep](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/01_data_prep_sft.py): `scripts/01_data_prep_sft.py`
- [SFT datasets](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/01_data_prep_sft.py): `scripts/01_data_prep_sft.py`
- [Preference prep](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py): `scripts/05_train_dpo.py`
- [DPO datasets](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py): `scripts/05_train_dpo.py`

### Model training

- [SFT LoRA training](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/02_train_sft.py): `scripts/02_train_sft.py`
- [DPO training](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/05_train_dpo.py): `scripts/05_train_dpo.py`
- **Model packages**

### Evaluation

- [Managed SFT scoring](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/03_evaluate_sft.py): `scripts/03_evaluate_sft.py`
- [Local A/B scoring](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04c_ab_compare.py): `scripts/04c_ab_compare.py`
- [DPO LLM judge](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/06_evaluate_dpo.py): `scripts/06_evaluate_dpo.py`

### Deployment

- [SFT deployment](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04_deploy_sft.py): `scripts/04_deploy_sft.py`
- [Base deployment](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04b_deploy_base.py): `scripts/04b_deploy_base.py`
- [DPO deployment](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04d_deploy_dpo.py): `scripts/04d_deploy_dpo.py`
- [SFT vLLM endpoint](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04_deploy_sft.py): `scripts/04_deploy_sft.py`
- [Base vLLM endpoint](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04b_deploy_base.py): `scripts/04b_deploy_base.py`
- [DPO vLLM endpoint](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/04d_deploy_dpo.py): `scripts/04d_deploy_dpo.py`

### Configuration

- [Environment config](https://github.com/sourangshupal/sagemaker-model-customization-demo/blob/main/scripts/config.py): `scripts/config.py`

### Other components

- **Local operator**
- **Workshop helpers**
- **ContractNLI scorer**
- **MLflow tracking**
- **Amazon Bedrock**
- **SageMaker AI**
- **Amazon S3**

## Connections

- Local operator → ContractNLI prep: runs (evidence: `README.md`)
- Local operator → SFT LoRA training: runs (evidence: `README.md`)
- Local operator → Managed SFT scoring: runs (evidence: `README.md`)
- Local operator → SFT deployment: runs (evidence: `README.md`)
- Local operator → Preference prep: runs (evidence: `README.md`)
- Local operator → DPO training: runs (evidence: `README.md`)
- Local operator → DPO LLM judge: runs (evidence: `README.md`)
- Local operator → DPO deployment: runs (evidence: `README.md`)
- ContractNLI prep → Environment config: loads settings (evidence: `scripts/01_data_prep_sft.py`)
- ContractNLI prep → Workshop helpers: uses helpers (evidence: `scripts/01_data_prep_sft.py`)
- ContractNLI prep → Amazon S3: uploads splits (evidence: `scripts/01_data_prep_sft.py`)
- ContractNLI prep → SFT datasets: registers (evidence: `scripts/01_data_prep_sft.py`)
- Preference prep → Environment config: loads settings (evidence: `scripts/05_train_dpo.py`)
- Preference prep → Amazon S3: uploads splits (evidence: `scripts/05_train_dpo.py`)
- Preference prep → DPO datasets: registers (evidence: `scripts/05_train_dpo.py`)
- DPO training → DPO datasets: reads (evidence: `scripts/05_train_dpo.py`)
- SFT LoRA training → SFT datasets: reads (evidence: `scripts/02_train_sft.py`)
- SFT LoRA training → Environment config: loads settings (evidence: `scripts/02_train_sft.py`)
- SFT LoRA training → Model packages: publishes model (evidence: `scripts/02_train_sft.py`)
- DPO training → Environment config: loads settings (evidence: `scripts/05_train_dpo.py`)
- DPO training → Model packages: publishes model (evidence: `scripts/05_train_dpo.py`)
- Managed SFT scoring → Environment config: loads settings (evidence: `scripts/03_evaluate_sft.py`)
- Managed SFT scoring → Model packages: reads model (evidence: `scripts/03_evaluate_sft.py`)
- Managed SFT scoring → SFT datasets: reads test set (evidence: `scripts/03_evaluate_sft.py`)
- Managed SFT scoring → ContractNLI scorer: registers evaluator (evidence: `scripts/03_evaluate_sft.py`)
- Managed SFT scoring → SageMaker AI: launches evaluation (evidence: `scripts/03_evaluate_sft.py`)
- Managed SFT scoring → MLflow tracking: tracks results (evidence: `scripts/03_evaluate_sft.py`)
- DPO LLM judge → Environment config: loads settings (evidence: `scripts/06_evaluate_dpo.py`)
- DPO LLM judge → Model packages: reads model (evidence: `scripts/06_evaluate_dpo.py`)
- DPO LLM judge → DPO datasets: reads test set (evidence: `scripts/06_evaluate_dpo.py`)
- DPO LLM judge → Amazon Bedrock: judges outputs (evidence: `scripts/06_evaluate_dpo.py`)
- DPO LLM judge → MLflow tracking: tracks results (evidence: `scripts/06_evaluate_dpo.py`)
- DPO LLM judge → SageMaker AI: launches evaluation (evidence: `scripts/06_evaluate_dpo.py`)
- Local A/B scoring → Workshop helpers: uses scorer (evidence: `scripts/04c_ab_compare.py`)
- Local A/B scoring → SFT vLLM endpoint: invokes (evidence: `scripts/04c_ab_compare.py`)
- Local A/B scoring → Base vLLM endpoint: invokes (evidence: `scripts/04c_ab_compare.py`)
- SFT deployment → Environment config: loads settings (evidence: `scripts/04_deploy_sft.py`)
- SFT deployment → Model packages: reads checkpoint (evidence: `scripts/04_deploy_sft.py`)
- SFT deployment → SageMaker AI: creates endpoint (evidence: `scripts/04_deploy_sft.py`)
- SFT deployment → SFT vLLM endpoint: configures (evidence: `scripts/04_deploy_sft.py`)
- SFT deployment → Amazon S3: loads checkpoint (evidence: `scripts/04_deploy_sft.py`)
- Base deployment → Environment config: loads settings (evidence: `scripts/04b_deploy_base.py`)
- Base deployment → SageMaker AI: creates endpoint (evidence: `scripts/04b_deploy_base.py`)
- Base deployment → Base vLLM endpoint: configures (evidence: `scripts/04b_deploy_base.py`)
- Base deployment → Amazon S3: loads artifact (evidence: `scripts/04b_deploy_base.py`)
- DPO deployment → Environment config: loads settings (evidence: `scripts/04d_deploy_dpo.py`)
- DPO deployment → Model packages: reads checkpoint (evidence: `scripts/04d_deploy_dpo.py`)
- DPO deployment → SageMaker AI: creates endpoint (evidence: `scripts/04d_deploy_dpo.py`)
