Metadata-Version: 2.4
Name: apophatic-engine
Version: 0.2.3
Summary: Apophatic noise subtraction (¬X) engine for neural text generation and logit-vector optimization.
Author: xerx593, non human (ideal) piece of shit
License-Expression: Unlicense
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20.0
Dynamic: license-file

# Apophatic Engine (`apophatic-engine`)

[![PyPI version](https://img.shields.io/badge/pypi-v0.2.2-blue.svg)](https://pypi.org/project/apophatic-engine/)
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.22067674-blue.svg)](https://doi.org/10.5281/zenodo.22067674)
[![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](LICENSE)

An open-source Python reference implementation of the **Apophatic Inference Engine (AIE)**. Operates as a subtractive noise filter ($\neg X$) for Large Language Models, replacing speculative hallucinations with vector collapse toward baseline relaxation ($B_0$).

> *Apophatic Noise Subtraction ($\neg X$) for Neural Inference and System Optimization.*

The **Apophatic Engine** implements token-by-token noise subtraction ($\neg X$) derived from the **Nicht-Theory** theoretical framework. Instead of maximizing speculative probabilities (1-logic), the filter penalizes assertion pressure ($P_A$) and collapses high-entropy logit vectors directly into the **Sufficient Invariant Baseline ($B_0$)**.

## Theoretical Grounding

This repository provides the operational code implementation for Paper IV (*Apophatic Inference Engine*) of the [Nicht-Theory Framework](https://github.com/xerx593/nicht-theory) (DOI: 10.5281/zenodo.22067674).

## Installation

```bash
pip install apophatic-engine
```

## Quickstart (v0.2.2)

### Example 1: Collapse Regime (High Entropy)
```python
import numpy as np
from apophatic_engine import ApophaticEngine

engine = ApophaticEngine(sigma_threshold=0.40)
logits = np.array([1.1, 1.05, 1.12, 0.98])
result = engine.apply_apophatic_filter(logits, step=1)
print(result)
# Output:
# {
#     'status': 'COLLAPSED_TO_B0',
#     'logits': array([1.0625, 1.0625, 1.0625, 1.0625]),
#     'sigma': 0.999,
#     'P_A': 1.0,
#     'action': '¬X applied: Logit vector fully collapsed to baseline B_0'
# }
```

### Example 2: Preservation Regime (Invariant Signal)
```python
import numpy as np
from apophatic_engine import ApophaticEngine

engine = ApophaticEngine(sigma_threshold=0.40)
logits = np.array([0.1, 0.2, 5.0, 0.05])
result = engine.apply_apophatic_filter(logits, step=1)
print(result)
# Output:
# {
#     'status': 'INVARIANT_OUTPUT',
#     'token_id': 2,
#     'selected_token': 2,
#     'selected_token_id': 2,
#     'token': 2,
#     'logits': array([0.1178, 0.2172, 4.9264, 0.0685]),
#     'sigma': 0.14231,
#     'P_A': 1.0,
#     'action': 'Inconsistencies weakened with P_A=1.0; invariant signal preserved'
# }
```

## API Reference

### `ApophaticEngine`
```python
ApophaticEngine(sigma_threshold=0.40, gamma_decay=0.1)
```
- `sigma_threshold` (float): Uncertainty cutoff determining regime transition (default: `0.40`).
- `gamma_decay` (float): Step-wise decay factor applied to assertion pressure $P_A$ (default: `0.1`).

### `apply_apophatic_filter(logits, step)`
Processes a 1D NumPy array of raw model logits.
- **Parameters:**
  - `logits` (`np.ndarray`): Raw logit vector from model predictions.
  - `step` (`int`): Current generation step index, controlling $P_A$ scaling.
- **Returns:** A dictionary containing execution status, adjusted `logits` tensor, computed `sigma`, assertion pressure `P_A`, and operational action log.

## HuggingFace Integration

```python
from apophatic_engine import ApophaticEngine
# See examples/02_huggingface_integration.py for full LogitsProcessor implementation
```

## Authorship & License

**Authors:** xerx593 & Non-Human (ideal) piece of shit  
**License:** [The Unlicense](LICENSE) — Dedicated to the public domain
