Metadata-Version: 2.4
Name: heart-fusion
Version: 2.0.1
Summary: 用对偶共存(Dual z=a+ib)替换 Transformer argmax 的融合函数库 — 两极/多极共存, 不剔变量
Author-email: "岳祥瑞 (Yue Xiangrui)" <yuexiangruiyue@gmail.com>
License: CC-BY-NC-SA-4.0
Project-URL: Homepage, https://github.com/yuexiangruiyue-oss/heart-fusion
Project-URL: PyPI, https://pypi.org/project/heart-fusion/
Project-URL: HuggingFace, https://huggingface.co/AngelWarmSmile123/heart-fusion
Project-URL: ModelScope, https://modelscope.cn/models/Loveangel123/heart-fusion
Project-URL: Zenodo, https://zenodo.org/record/23054235
Project-URL: ORCID, https://orcid.org/0009-0001-8504-260X
Keywords: fusion,dual,argmax,transformer,coexistence,sephirot,harmony,ai-safety
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: Free To Use But Restricted
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# heart-fusion

用**对偶共存**（Dual $z = a + i \cdot b$）替换 Transformer argmax 的融合函数库。

## 核心思想

Transformer 末步 argmax「挑最大值」= **剔除变量**：选了一个方向，另一个方向整个消失。
本库用**融合函数**让两个相反方向**一起留下**，合成一个不丢失任何一方的新整体。

**铁律**：禁止损失函数、禁止梯度下降、禁止奖励/惩罚、不寻求最优解、不允许剔除任何输入变量。

## 安装

```bash
pip install heart-fusion
```

## 快速示例

```python
from heart_fusion import fuse, settle, fusion_decode, Pole

# 两极共存
d = fuse(0.8, 0.9)       # 理智0.8 + 慈爱0.9
print(d.balance)         # 0.99 (接近完美平衡)
print(d.is_harmonious()) # True

# 失衡 → 再合一自动收敛进和谐带
cold = fuse(1.0, 0.1)    # 偏理智
settled, rounds = settle(cold)
print(settled.balance)   # 0.56 (已进和谐带)

# 四极共存 (四元数扩展)
from heart_fusion import fuse_multi
q = fuse_multi(0.9, 0.8, 0.7, 0.6)  # 理智/慈爱/逻辑/共情
print(q.balance)         # ~0.99

# 替换 Transformer 末层 argmax
pole_a = Pole("理智", 0.85, "客观建议：建议你...")
pole_b = Pole("慈爱", 0.92, "温暖陪伴：我在你身边...")
result = fusion_decode(pole_a, pole_b)
print(result.output)     # 两极共存, 没有任何一方被剔除
```

## API

| 函数 | 说明 |
|------|------|
| `fuse(a, b)` | 两极合一 → `Dual` |
| `settle(dual)` | 收敛进和谐带 → `(Dual, rounds)` |
| `fuse_multi(*poles)` | n 极合一 → `MultiDual` |
| `settle_multi(dual)` | n 极收敛 → `(MultiDual, rounds)` |
| `fusion_decode(pole_a, pole_b)` | 替换 argmax 的融合输出层 |
| `argmax_decode(pole_a, pole_b)` | 旧范式（对比用） |

## License

MIT
