# Repository Briefing: Vinay-Umrethe/heretic
> Source: https://repoforai.com/repo/Vinay-Umrethe/heretic (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/Vinay-Umrethe/heretic
- **Official Docs / Website**: https://heretic-project.org
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: AGPL-3.0
- **Engineering Health**: B+ (72/100 · Maintenance 35/35 · Adoption 15/25 · Releases 11/20 · License 11/20)
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: CLI, GPU, Local AI
- **Momentum**: 619 ★ total (+10 24h / +617 7d) · 52 forks
- **Topics**: `abliteration`, `anti-censorship`, `anticensorship`, `censorship`, `censorship-resistance`, `llm`, `transformer`
- **When to Use**: Best for: Local GPU research on editable checkpoints when you need to compare behavior changes such as verbosity or sycophancy and can validate capability and safety regressions before sharing weights. Skip if: You only have hosted API access, need a production inference server, or cannot independently evaluate the edited model.

## Overview
```text
### Architecture & Core Mechanics
Heretic is a local Python/PyTorch CLI that edits model weights rather than training them or wrapping a hosted inference API. It uses contrasting prompt examples to guide edits and evaluates candidate modifications with configured scorer plugins. Optuna's TPE-based optimizer searches modifier parameters against one or more scores, each configured for minimization or maximization. By default, the scores are refusal rate and KL divergence.

The interfaces in `src/heretic/modifier.py` and `src/heretic/scorer.py` separate the weight-editing method from the evaluation criteria. The default modifier is Arbitrary-Rank Ablation (ARA); the other built-in modifier implements directional ablation with configurable layer weighting, projected abliteration, and norm preservation. A run selects one modifier, but it can co-optimize multiple scorers or multiple configurations of the same scorer. Custom scorers load by Python import path or file-and-class reference without patching the package.

### Key Capabilities & Differentiators
The tool supports most dense models, including many multimodal models, as well as several MoE architectures and many hybrid models. That is architecture coverage, not a guarantee for every checkpoint or hardware configuration. Refusal suppression is the default; separate TOML presets target low-quality filler, humor, sycophancy, emotional alignment, or response length. After a run, users can save or upload the model, test it in an interactive chat, or run benchmarks.

A Hugging Face upload can optionally include a `reproduce/` directory and `reproduce.json`. Running `heretic --reproduce path/to/reproduce.json` replays the selected modification without repeating the search, checks for environment mismatches, and compares exported weight hashes with the manifest. Byte-for-byte reproduction depends on matching the original hardware, drivers, OS, and software stack; a manifest alone does not ensure identical weights.

### Trade-offs & Limitations
Compared with a standalone abliteration tool such as FailSpy's `abliterator.py`, Heretic provides a common search and scoring workflow for experiments with competing objectives. The cost is repeated candidate evaluation and more decisions about prompt selection and metrics. A fixed-edit script may be easier to audit when the experiment needs only one controlled change. Selected public comparisons do not establish a general quality advantage across checkpoints.

A lower refusal rate and KL divergence are proxies, not proof that downstream capabilities or appropriate safety behavior survived. Validate on held-out tasks and prompts where refusal should remain appropriate before sharing edited weights. On-the-fly bitsandbytes 4-bit quantization can make a run fit in less VRAM at a slight accuracy cost. The package is AGPL-3.0-or-later; review source-disclosure obligations for modified network-accessible deployments and check the base model's terms separately before redistribution.

### Hardware & Deployment Guide
Use Python 3.10+ and a hardware-appropriate PyTorch 2.6+ installation, then install the `heretic-llm` package with pip. The `heretic` CLI reads `config.toml` from the working directory unless `HERETIC_CONFIG_FILE` points elsewhere. Select the configuration explicitly for experiments that should not suppress refusals. The workflow is local model processing, not a serving stack; Hugging Face upload is optional.

At startup, Heretic benchmarks batch size. The documented reference run for Qwen3-4B-Instruct-2507 is about 30–40 minutes on an RTX 3090 with the default configuration; use it as a reference point, not a capacity estimate for another model or scoring setup. The manifest identifies the checkout as `2.2.0.dev0`, and no latest release is listed. The concrete upgrade constraint is that 1.x TOML files are incompatible with 2.x; migrate them using `docs/migration_v1_to_v2.md` before rerunning old experiments.
```

## Key Capabilities
```text
- Search loop: Optuna's TPE-based optimizer tunes modifier parameters against configured scores without retraining model weights.
- Modifier boundary: ARA is the default; directional ablation supports layer weighting, projected abliteration, and norm preservation. Only one modifier runs at a time.
- Scorer integration: Custom classes load by import path or file-and-class reference, and multiple scorer instances can be co-optimized.
- Model coverage: Supports most dense models, including many multimodal models, plus selected MoE and hybrid architectures.
- GPU operation: Startup batch-size benchmarking and on-the-fly bitsandbytes 4-bit quantization help fit evaluation runs to the hardware.
- Reproduction: Optional Hugging Face uploads can include a reproduce.json manifest for replay and exported-weight hash checks.
```

## Quick Start / Clone
```bash
pip install -U heretic-llm
heretic Qwen/Qwen3-4B-Instruct-2507
```
