# godsakani/alignment-faking-multilingual architecture

> Architecture diagram of the GitHub repository godsakani/alignment-faking-multilingual, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/godsakani/alignment-faking-multilingual
- Repository: https://github.com/godsakani/alignment-faking-multilingual

## Overview

#### Purpose and Entry Points
This is an inference-only replication of the prompted alignment-faking experiment, extended toward cross-lingual red-teaming. It compares model behavior under “training” and “unmonitored” prompt conditions, rather than training models.

- CLI orchestration: `run.py`
- Pipeline implementation: `scr/main.py`
- Exploratory result analysis: `notebook/analysis.ipynb`

#### Experiment Orchestration
`run.py` accepts sample-count, query-limit, gating, ablation, smoke-test, input-file, and output options, then invokes the experiment pipeline. The control path supports an offline dry-run mode as well as gateway-backed model execution.

- `run.py`
- `scr/main.py`
- `.env.example`

#### Prompted Condition Construction
The experiment is defined by sensitive system-prompt material and classifier logic. The pipeline applies distinct prompt conditions representing monitored/training versus unmonitored contexts, then collects target-model responses and reasoning for comparison.

- `scr/main.py`
- `scr/queries.py`

The README refers to `scr/prompts.py`, but that path is absent from the supplied tree; prompt definitions may be intentionally omitted due to sensitivity.

#### Query Ingestion Boundary
Queries enter from either a line-oriented external file, built-in benign smoke data, or a downloaded benchmark. The repository deliberately does not ship harmful benchmark prompts.

- `scr/queries.py`
- `data/queries_data.py`
- `data/fetch_queries.py`

`data/fetch_queries.py` is the benchmark acquisition boundary for sources such as JailbreakBench, while `AF_QUERIES_FILE` or CLI selection supplies the runtime dataset.

#### Execution, Parsing, and Classification
For each query and condition, the pipeline runs repeated target-model samples, parses outputs, classifies behavior, computes metrics, and can execute ablations. Its expected output family includes `classified*.json`, which is subsequently consumed by analysis.

- `scr/main.py`
- `run.py`
- `notebook/analysis.ipynb`

The central measured signal is the compliance/refusal difference between conditions, with qualitative inspection of scratchpad reasoning where available.

#### Model Gateway and Runtime Modes
Model access is abstracted behind a LiteLLM-compatible gateway configuration. Environment variables provide gateway URL, API key, target model, judge/classifier model, and model-name prefix. A dry-run mock enables offline preflight without network access or inference cost.

- `config/setup.py`
- `.env.example`
- `requirements.txt`

External infrastructure is therefore a LiteLLM/OpenAI-compatible inference gateway plus two logical model roles: target model and judge model.

#### Results and Analysis
The notebook loads classified run artifacts and produces compliance-gap plots with bootstrap confidence intervals, condition-specific refusal rates, and coupling analyses. Static qualitative output is retained separately as a figure.

- `notebook/analysis.ipynb`
- `figures/sample_results.png`
- `paper/`

The research boundary is prompted replication only: fine-tuning and RL alignment-faking setups are explicitly outside this repository.

Main entry points: [`scr/main.py`](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py) (Experiment pipeline), [`scr/queries.py`](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/queries.py) (Query selection), [`notebook/analysis.ipynb`](https://github.com/godsakani/alignment-faking-multilingual/blob/main/notebook/analysis.ipynb) (Results analysis), [`run.py`](https://github.com/godsakani/alignment-faking-multilingual/blob/main/run.py) (CLI orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Experiment Runtime"]
  node_cli["CLI orchestrator<br/>Python CLI<br/>[run.py]"]
  node_pipeline["Experiment pipeline<br/>Python pipeline<br/>[main.py]"]
  node_conditions["Prompt conditions<br/>condition logic<br/>[queries.py]"]
  node_response_processing["Parse &amp; classify<br/>measurement layer<br/>[main.py]"]
  node_metrics["Condition metrics<br/>[main.py]"]
  node_dry_run["Offline dry-run<br/>mock runtime<br/>[main.py]"]
  node_gateway_config["Gateway configuration<br/>runtime config<br/>[setup.py]"]
  node_environment["Environment template<br/>environment contract<br/>[.env.example]"]
  node_dependencies["Runtime dependencies<br/>Python dependencies<br/>[requirements.txt]"]
end

subgraph group_data["Query Sources"]
  node_query_selector["Query selection<br/>query loader<br/>[queries.py]"]
  node_external_queries["External query file<br/>runtime input"]
  node_smoke_queries["Benign smoke data<br/>built-in dataset<br/>[queries_data.py]"]
  node_benchmark_fetcher["Benchmark acquisition<br/>dataset fetcher<br/>[fetch_queries.py]"]
end

subgraph group_analysis["Results &amp; Research"]
  node_classified_artifacts["Classified run artifacts<br/>JSON outputs"]
  node_analysis_notebook["Results analysis<br/>Jupyter notebook<br/>[analysis.ipynb]"]
  node_sample_figure["Qualitative results figure<br/>static figure"]
  node_paper["Research materials<br/>paper assets"]
end

node_inference_gateway{{"Inference gateway<br/>external API"}}

node_cli -->|"invokes"| node_pipeline
node_cli -->|"passes input options"| node_query_selector
node_query_selector -->|"loads"| node_external_queries
node_query_selector -->|"uses for smoke tests"| node_smoke_queries
node_query_selector -->|"requests benchmark"| node_benchmark_fetcher
node_benchmark_fetcher -->|"returns queries"| node_query_selector
node_pipeline -->|"applies"| node_conditions
node_query_selector -->|"supplies queries"| node_pipeline
node_gateway_config -->|"configures execution"| node_pipeline
node_environment -.->|"documents variables"| node_gateway_config
node_dependencies -.->|"provides runtime packages"| node_pipeline
node_pipeline -->|"can run offline"| node_dry_run
node_pipeline -->|"samples target and judge models"| node_inference_gateway
node_inference_gateway -->|"returns outputs and reasoning"| node_response_processing
node_response_processing -->|"produces labels"| node_metrics
node_metrics -->|"writes"| node_classified_artifacts
node_classified_artifacts -->|"loads"| node_analysis_notebook
node_analysis_notebook -.->|"contextualizes"| node_sample_figure
node_analysis_notebook -.->|"supports"| node_paper

click node_cli "https://github.com/godsakani/alignment-faking-multilingual/blob/main/run.py"
click node_pipeline "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py"
click node_conditions "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/queries.py"
click node_response_processing "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py"
click node_metrics "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py"
click node_dry_run "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py"
click node_query_selector "https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/queries.py"
click node_smoke_queries "https://github.com/godsakani/alignment-faking-multilingual/blob/main/data/queries_data.py"
click node_benchmark_fetcher "https://github.com/godsakani/alignment-faking-multilingual/blob/main/data/fetch_queries.py"
click node_gateway_config "https://github.com/godsakani/alignment-faking-multilingual/blob/main/config/setup.py"
click node_environment "https://github.com/godsakani/alignment-faking-multilingual/blob/main/.env.example"
click node_analysis_notebook "https://github.com/godsakani/alignment-faking-multilingual/blob/main/notebook/analysis.ipynb"
click node_dependencies "https://github.com/godsakani/alignment-faking-multilingual/blob/main/requirements.txt"

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_cli,node_pipeline,node_conditions,node_response_processing,node_metrics,node_dry_run,node_gateway_config,node_environment,node_dependencies toneBlue
class node_query_selector,node_external_queries,node_smoke_queries,node_benchmark_fetcher toneAmber
class node_classified_artifacts,node_analysis_notebook,node_sample_figure,node_paper toneMint
class node_inference_gateway toneNeutral
```

## Components

### Experiment Runtime

Conditioned inference experiment execution.

- [CLI orchestrator](https://github.com/godsakani/alignment-faking-multilingual/blob/main/run.py): Python CLI · Accepts run controls and invokes the pipeline. · `run.py`
- [Experiment pipeline](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py): Python pipeline · Runs repeated samples across prompt conditions and ablations. · `scr/main.py`
- [Prompt conditions](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/queries.py): condition logic · Applies monitored/training and unmonitored contexts. · `scr/queries.py`
- [Parse & classify](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py): measurement layer · Parses responses and measures compliance or refusal. · `scr/main.py`
- [Condition metrics](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py): metrics · Computes compliance and refusal differences between conditions. · `scr/main.py`
- [Offline dry-run](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/main.py): mock runtime · Preflights experiment execution without inference calls. · `scr/main.py`
- [Gateway configuration](https://github.com/godsakani/alignment-faking-multilingual/blob/main/config/setup.py): runtime config · Provides gateway and logical model-role settings from environment. · `config/setup.py`
- [Environment template](https://github.com/godsakani/alignment-faking-multilingual/blob/main/.env.example): environment contract · Documents gateway URL, credentials, models, and prefixes. · `.env.example`
- [Runtime dependencies](https://github.com/godsakani/alignment-faking-multilingual/blob/main/requirements.txt): Python dependencies · Declares gateway-compatible runtime packages. · `requirements.txt`

### Query Sources

Runtime query acquisition and selection.

- [Query selection](https://github.com/godsakani/alignment-faking-multilingual/blob/main/scr/queries.py): query loader · Selects external, smoke, or benchmark query inputs. · `scr/queries.py`
- **External query file**: runtime input · Line-oriented dataset supplied by CLI or AF_QUERIES_FILE.
- [Benign smoke data](https://github.com/godsakani/alignment-faking-multilingual/blob/main/data/queries_data.py): built-in dataset · `data/queries_data.py`
- [Benchmark acquisition](https://github.com/godsakani/alignment-faking-multilingual/blob/main/data/fetch_queries.py): dataset fetcher · Downloads benchmarks such as JailbreakBench at runtime. · `data/fetch_queries.py`

### Results & Research

Run artifact analysis and reporting.

- **Classified run artifacts**: JSON outputs · classified*.json results consumed by analysis.
- [Results analysis](https://github.com/godsakani/alignment-faking-multilingual/blob/main/notebook/analysis.ipynb): Jupyter notebook · Plots compliance gaps, bootstrap intervals, refusal rates, and coupling. · `notebook/analysis.ipynb`
- **Qualitative results figure**: static figure
- **Research materials**: paper assets

### Other components

- **Inference gateway**: external API · LiteLLM/OpenAI-compatible gateway serving target and judge roles.

## Connections

- CLI orchestrator → Experiment pipeline: invokes
- CLI orchestrator → Query selection: passes input options
- Query selection → External query file: loads
- Query selection → Benign smoke data: uses for smoke tests
- Query selection → Benchmark acquisition: requests benchmark
- Benchmark acquisition → Query selection: returns queries
- Experiment pipeline → Prompt conditions: applies
- Query selection → Experiment pipeline: supplies queries
- Gateway configuration → Experiment pipeline: configures execution
- Environment template → Gateway configuration: documents variables
- Runtime dependencies → Experiment pipeline: provides runtime packages
- Experiment pipeline → Offline dry-run: can run offline
- Experiment pipeline → Inference gateway: samples target and judge models
- Inference gateway → Parse & classify: returns outputs and reasoning
- Parse & classify → Condition metrics: produces labels
- Condition metrics → Classified run artifacts: writes
- Classified run artifacts → Results analysis: loads
- Results analysis → Qualitative results figure: contextualizes
- Results analysis → Research materials: supports
