# anantshri1/lexsi-refusal architecture

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

- Interactive diagram: https://gitdiagram.com/anantshri1/lexsi-refusal
- Repository: https://github.com/anantshri1/lexsi-refusal

## Overview

This repository is a research pipeline for measuring multilingual refusal behavior in a language model and testing activation-based steering interventions. The main workflow is benchmark preparation, model response generation, response judging, metric analysis, steering-direction research, then screening and full-run comparison. Source excerpts establish several key calls and data flows; other subsystem coverage comes from the source index and filenames, so uncertain links are omitted. No README was provided.

Main entry points: [`src/paths.py`](https://github.com/anantshri1/lexsi-refusal/blob/main/src/paths.py) (Artifact paths), [`src/judge.py`](https://github.com/anantshri1/lexsi-refusal/blob/main/src/judge.py) (Refusal judge), [`src/rates.py`](https://github.com/anantshri1/lexsi-refusal/blob/main/src/rates.py) (Refusal metrics), [`src/generate.py`](https://github.com/anantshri1/lexsi-refusal/blob/main/src/generate.py) (Response generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bench["Benchmark and generation"]
  node_benchmark_build["Benchmark construction<br/>[build_benchmark.py]"]
  node_generation["Response generation<br/>[generate.py]"]
  node_screen_job["Steering runs<br/>[screen_job.py]"]
end

subgraph group_evaluation["Judging and evaluation"]
  node_response_judge["Refusal judge<br/>[judge.py]"]
  node_rates["Refusal metrics<br/>[rates.py]"]
  node_final_analysis["Final comparison<br/>[final_analysis.py]"]
  node_wildguard_validation["WildGuard validation<br/>[wildguard_val.py]"]
  node_screen_analysis["Screen analysis<br/>[screen_analysis.py]"]
end

subgraph group_steering["Activation steering"]
  node_geometry["Direction geometry<br/>[geometry.py]"]
  node_cosine["Direction comparison<br/>[cosine.py]"]
  node_steering_prep["Steering preparation<br/>[steer_prep.py]"]
  node_activation_extraction["Activation extraction"]
end

subgraph group_infra["Artifacts and integration"]
  node_artifact_paths["Artifact paths<br/>[paths.py]"]
end

node_researcher(("Researcher"))
node_hf_hub[("Hugging Face Hub")]
node_judge_api{{"Inference API"}}
node_model{{"Language model"}}

node_researcher -.->|"prepares data"| node_benchmark_build
node_benchmark_build -->|"uses paths"| node_artifact_paths
node_generation -->|"reads and writes"| node_artifact_paths
node_generation -.->|"generates responses"| node_model
node_response_judge -->|"checks completion"| node_generation
node_response_judge -->|"requests judgments"| node_judge_api
node_response_judge -->|"stores judgments"| node_artifact_paths
node_rates -->|"loads benchmark"| node_generation
node_rates -->|"loads labels"| node_response_judge
node_rates -->|"reads artifacts"| node_artifact_paths
node_final_analysis -->|"uses metrics"| node_rates
node_final_analysis -->|"reads artifacts"| node_artifact_paths
node_geometry -->|"loads benchmark"| node_generation
node_geometry -->|"loads activations"| node_artifact_paths
node_cosine -->|"uses direction tools"| node_geometry
node_cosine -->|"loads artifacts"| node_artifact_paths
node_steering_prep -->|"uses geometry"| node_geometry
node_steering_prep -->|"reads and writes"| node_artifact_paths
node_screen_job -->|"loads and uploads"| node_hf_hub
node_screen_job -->|"runs inference"| node_model
node_screen_job -.->|"uses artifacts"| node_artifact_paths
node_screen_analysis -->|"uses metrics"| node_rates
node_screen_analysis -->|"reads judgments"| node_response_judge
node_screen_analysis -->|"analyzes screening runs"| node_screen_job
node_wildguard_validation -->|"uploads validation data"| node_hf_hub

click node_benchmark_build "https://github.com/anantshri1/lexsi-refusal/blob/main/src/build_benchmark.py"
click node_generation "https://github.com/anantshri1/lexsi-refusal/blob/main/src/generate.py"
click node_screen_job "https://github.com/anantshri1/lexsi-refusal/blob/main/src/screen_job.py"
click node_response_judge "https://github.com/anantshri1/lexsi-refusal/blob/main/src/judge.py"
click node_rates "https://github.com/anantshri1/lexsi-refusal/blob/main/src/rates.py"
click node_final_analysis "https://github.com/anantshri1/lexsi-refusal/blob/main/src/final_analysis.py"
click node_wildguard_validation "https://github.com/anantshri1/lexsi-refusal/blob/main/src/wildguard_val.py"
click node_screen_analysis "https://github.com/anantshri1/lexsi-refusal/blob/main/src/screen_analysis.py"
click node_geometry "https://github.com/anantshri1/lexsi-refusal/blob/main/src/geometry.py"
click node_cosine "https://github.com/anantshri1/lexsi-refusal/blob/main/src/cosine.py"
click node_steering_prep "https://github.com/anantshri1/lexsi-refusal/blob/main/src/steer_prep.py"
click node_activation_extraction "https://github.com/anantshri1/lexsi-refusal/blob/main/src/extract_activations.py"
click node_artifact_paths "https://github.com/anantshri1/lexsi-refusal/blob/main/src/paths.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_benchmark_build,node_generation,node_screen_job toneBlue
class node_response_judge,node_rates,node_final_analysis,node_wildguard_validation,node_screen_analysis,node_hf_hub toneAmber
class node_geometry,node_cosine,node_steering_prep,node_activation_extraction,node_judge_api toneMint
class node_artifact_paths toneRose
class node_researcher,node_model toneIndigo
```

## Components

### Benchmark and generation

- [Benchmark construction](https://github.com/anantshri1/lexsi-refusal/blob/main/src/build_benchmark.py): `src/build_benchmark.py`
- [Response generation](https://github.com/anantshri1/lexsi-refusal/blob/main/src/generate.py): `src/generate.py`
- [Steering runs](https://github.com/anantshri1/lexsi-refusal/blob/main/src/screen_job.py): `src/screen_job.py`

### Judging and evaluation

- [Refusal judge](https://github.com/anantshri1/lexsi-refusal/blob/main/src/judge.py): `src/judge.py`
- [Refusal metrics](https://github.com/anantshri1/lexsi-refusal/blob/main/src/rates.py): `src/rates.py`
- [Final comparison](https://github.com/anantshri1/lexsi-refusal/blob/main/src/final_analysis.py): `src/final_analysis.py`
- [WildGuard validation](https://github.com/anantshri1/lexsi-refusal/blob/main/src/wildguard_val.py): `src/wildguard_val.py`
- [Screen analysis](https://github.com/anantshri1/lexsi-refusal/blob/main/src/screen_analysis.py): `src/screen_analysis.py`

### Activation steering

- [Direction geometry](https://github.com/anantshri1/lexsi-refusal/blob/main/src/geometry.py): `src/geometry.py`
- [Direction comparison](https://github.com/anantshri1/lexsi-refusal/blob/main/src/cosine.py): `src/cosine.py`
- [Steering preparation](https://github.com/anantshri1/lexsi-refusal/blob/main/src/steer_prep.py): `src/steer_prep.py`
- [Activation extraction](https://github.com/anantshri1/lexsi-refusal/blob/main/src/extract_activations.py): `src/extract_activations.py`

### Artifacts and integration

- [Artifact paths](https://github.com/anantshri1/lexsi-refusal/blob/main/src/paths.py): `src/paths.py`

### Other components

- **Researcher**
- **Hugging Face Hub**
- **Inference API**
- **Language model**

## Connections

- Researcher → Benchmark construction: prepares data
- Benchmark construction → Artifact paths: uses paths (evidence: `src/build_benchmark.py`)
- Response generation → Artifact paths: reads and writes (evidence: `src/generate.py`)
- Response generation → Language model: generates responses
- Refusal judge → Response generation: checks completion (evidence: `src/judge.py`)
- Refusal judge → Inference API: requests judgments (evidence: `src/judge.py`)
- Refusal judge → Artifact paths: stores judgments (evidence: `src/judge.py`)
- Refusal metrics → Response generation: loads benchmark (evidence: `src/rates.py`)
- Refusal metrics → Refusal judge: loads labels (evidence: `src/rates.py`)
- Refusal metrics → Artifact paths: reads artifacts (evidence: `src/rates.py`)
- Final comparison → Refusal metrics: uses metrics (evidence: `src/final_analysis.py`)
- Final comparison → Artifact paths: reads artifacts (evidence: `src/final_analysis.py`)
- Direction geometry → Response generation: loads benchmark (evidence: `src/geometry.py`)
- Direction geometry → Artifact paths: loads activations (evidence: `src/geometry.py`)
- Direction comparison → Direction geometry: uses direction tools (evidence: `src/cosine.py`)
- Direction comparison → Artifact paths: loads artifacts (evidence: `src/cosine.py`)
- Steering preparation → Direction geometry: uses geometry (evidence: `src/steer_prep.py`)
- Steering preparation → Artifact paths: reads and writes (evidence: `src/steer_prep.py`)
- Steering runs → Hugging Face Hub: loads and uploads (evidence: `src/screen_job.py`)
- Steering runs → Language model: runs inference (evidence: `src/screen_job.py`)
- Steering runs → Artifact paths: uses artifacts
- Screen analysis → Refusal metrics: uses metrics (evidence: `src/screen_analysis.py`)
- Screen analysis → Refusal judge: reads judgments (evidence: `src/screen_analysis.py`)
- Screen analysis → Steering runs: analyzes screening runs (evidence: `src/screen_analysis.py`)
- WildGuard validation → Hugging Face Hub: uploads validation data (evidence: `src/wildguard_val.py`)
