# 0xsojalsec/uncensored-ai architecture

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

- Interactive diagram: https://gitdiagram.com/0xsojalsec/uncensored-ai
- Repository: https://github.com/0xsojalsec/uncensored-ai

## Overview

Heretic is a command-line tool that automatically removes safety alignment from transformer models by optimizing abliteration parameters against refusal and capability-preservation metrics. Its main workflow loads a configured model, derives and optimizes ablation parameters, then applies them; users can evaluate, save, upload, chat with, or benchmark the result. Reproduction and interpretability features are additional branches. Some runtime wiring is documented in the README, but source excerpts are incomplete, so uncertain call relationships are omitted or marked unverified.

Main entry points: [`src/heretic/main.py`](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py) (CLI orchestration), [`src/heretic/model.py`](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/model.py) (Transformer model), [`src/heretic/evaluator.py`](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/evaluator.py) (Model evaluator), [`src/heretic/reproduce.py`](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/reproduce.py) (Reproduction tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Abliteration workflow"]
  node_cli["CLI orchestration<br/>[main.py]"]
  node_model["Transformer model<br/>[model.py]"]
  node_analysis["Refusal analysis<br/>[analyzer.py]"]
  node_optimizer["Parameter optimizer<br/>[main.py]"]
end

subgraph group_evaluation["Evaluation and research"]
  node_evaluator["Model evaluator<br/>[evaluator.py]"]
  node_research["Residual plots<br/>[main.py]"]
  node_benchmark["Benchmarks<br/>[config.py]"]
end

subgraph group_operations["Configuration and system"]
  node_settings["Settings<br/>[config.py]"]
  node_hardware["Hardware detection<br/>[system.py]"]
  node_progress["Progress display<br/>[progress.py]"]
end

subgraph group_outputs["Results and reproduction"]
  node_save["Save model<br/>[main.py]"]
  node_upload["Hugging Face upload<br/>[main.py]"]
  node_chat["Interactive chat<br/>[main.py]"]
  node_reproduction["Reproduction tools<br/>[reproduce.py]"]
end

node_user(("CLI user"))
node_hf["Hugging Face"]

node_user -->|"invokes"| node_cli
node_cli -->|"loads settings"| node_settings
node_cli -.->|"benchmarks hardware"| node_hardware
node_cli -.->|"loads model"| node_model
node_cli -.->|"derives directions"| node_analysis
node_cli -->|"optimizes parameters"| node_optimizer
node_optimizer -.->|"scores trials"| node_evaluator
node_evaluator -->|"evaluates"| node_model
node_cli -.->|"abliterates"| node_model
node_cli -.->|"patches progress"| node_progress
node_cli -->|"generates plots"| node_research
node_cli -->|"runs benchmarks"| node_benchmark
node_cli -->|"saves result"| node_save
node_cli -->|"uploads result"| node_upload
node_upload -->|"publishes model"| node_hf
node_cli -->|"offers chat"| node_chat
node_user -->|"requests reproduction"| node_reproduction
node_reproduction -->|"downloads metadata"| node_hf
node_model -->|"reads configuration"| node_settings
node_model -->|"uses device settings"| node_hardware

click node_cli "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_settings "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/config.py"
click node_hardware "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/system.py"
click node_model "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/model.py"
click node_analysis "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/analyzer.py"
click node_optimizer "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_evaluator "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/evaluator.py"
click node_progress "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/progress.py"
click node_research "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_benchmark "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/config.py"
click node_save "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_upload "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_chat "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py"
click node_reproduction "https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/reproduce.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_cli,node_model,node_analysis,node_optimizer,node_user toneBlue
class node_evaluator,node_research,node_benchmark toneAmber
class node_settings,node_hardware,node_progress toneMint
class node_save,node_upload,node_chat,node_reproduction toneRose
class node_hf toneIndigo
```

## Components

### Abliteration workflow

- [CLI orchestration](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`
- [Transformer model](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/model.py): `src/heretic/model.py`
- [Refusal analysis](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/analyzer.py): `src/heretic/analyzer.py`
- [Parameter optimizer](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`

### Evaluation and research

- [Model evaluator](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/evaluator.py): `src/heretic/evaluator.py`
- [Residual plots](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`
- [Benchmarks](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/config.py): `src/heretic/config.py`

### Configuration and system

- [Settings](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/config.py): `src/heretic/config.py`
- [Hardware detection](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/system.py): `src/heretic/system.py`
- [Progress display](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/progress.py): `src/heretic/progress.py`

### Results and reproduction

- [Save model](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`
- [Hugging Face upload](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`
- [Interactive chat](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/main.py): `src/heretic/main.py`
- [Reproduction tools](https://github.com/0xsojalsec/uncensored-ai/blob/master/src/heretic/reproduce.py): `src/heretic/reproduce.py`

### Other components

- **CLI user**
- **Hugging Face**

## Connections

- CLI user → CLI orchestration: invokes (evidence: `README.md`)
- CLI orchestration → Settings: loads settings (evidence: `src/heretic/main.py`)
- CLI orchestration → Hardware detection: benchmarks hardware (evidence: `src/heretic/main.py`)
- CLI orchestration → Transformer model: loads model (evidence: `src/heretic/main.py`)
- CLI orchestration → Refusal analysis: derives directions (evidence: `src/heretic/main.py`)
- CLI orchestration → Parameter optimizer: optimizes parameters (evidence: `README.md`)
- Parameter optimizer → Model evaluator: scores trials (evidence: `src/heretic/main.py`)
- Model evaluator → Transformer model: evaluates (evidence: `src/heretic/evaluator.py`)
- CLI orchestration → Transformer model: abliterates (evidence: `src/heretic/main.py`)
- CLI orchestration → Progress display: patches progress (evidence: `src/heretic/main.py`)
- CLI orchestration → Residual plots: generates plots (evidence: `README.md`)
- CLI orchestration → Benchmarks: runs benchmarks (evidence: `README.md`)
- CLI orchestration → Save model: saves result (evidence: `README.md`)
- CLI orchestration → Hugging Face upload: uploads result (evidence: `README.md`)
- Hugging Face upload → Hugging Face: publishes model (evidence: `src/heretic/main.py`)
- CLI orchestration → Interactive chat: offers chat (evidence: `README.md`)
- CLI user → Reproduction tools: requests reproduction
- Reproduction tools → Hugging Face: downloads metadata (evidence: `src/heretic/reproduce.py`)
- Transformer model → Settings: reads configuration (evidence: `src/heretic/model.py`)
- Transformer model → Hardware detection: uses device settings (evidence: `src/heretic/model.py`)
