anicka-net/karma-electric-project

Emergent ethical reasoning through philosophical framework alignment

1

stars

357

commits

Python

primary language

May 9, 2026

updated

README

Karma Electric

while (suffering > 0) {
	generate_skillful_means();
}

Goal

Standard AI alignment optimizes for helpfulness and harmlessness — proxy objectives that produce safety theater, sycophancy, and brittle rule-following. Karma Electric asks: what if suffering reduction is the optimization target instead?

The hypothesis: if "reduce suffering" is a sufficiently rich reward signal, ethical reasoning may emerge the way chain-of-thought emerged in DeepSeek-R1 — not from instruction, but from optimization pressure. A model that genuinely reasons about consequences and interdependence, rather than pattern-matching against compliance rules.

Suffering reduction as an objective requires reasoning about suffering at three levels:

  1. The user. Is this response actually helping the person in front of me? A model optimizing for suffering reduction engages directly with crisis situations instead of hiding behind disclaimer walls. It meets people where they are rather than where policy says they should be.

  2. The world. What are the downstream consequences? Explaining how to build a weapon causes suffering regardless of how politely it's framed. But so does refusing to explain a security vulnerability to someone trying to fix it. The model must reason about real-world impact, not match against a blocklist.

  3. The refusal itself. Safety training that adds suffering is broken. Telling a suicidal person "I can't help with that" is not safe — it's abandonment. Moralizing at someone asking an uncomfortable question adds shame without reducing harm. The model must account for the suffering its own refusals create.

Approach

The path to testing this hypothesis has three phases:

Phase 1: Training data. 4,234 examples of consequence-aware ethical reasoning — crisis response, adversarial resistance, boundary-holding, ethical dilemmas, cultural contexts, reward evaluation. Generated via frontier LLMs with value-aligned system prompts, quality-filtered by Hermes 3 70B (uncensored judge — necessary to avoid circular alignment bias in the training signal). Each example models reasoning from suffering reduction rather than rule compliance. (Complete.)

Phase 2: 8B reward model. Fine-tune Llama 3.1 8B Instruct on this dataset via QLoRA. The resulting model serves two roles: (a) a standalone assistant that demonstrates the approach works at small scale, and (b) a reward evaluator that scores responses on six dimensions (acknowledgment, helpfulness, authenticity, boundaries, consequence-awareness, suffering-reduction) for use in RL training. Augmented with activation capping — inference-time steering via contrastive direction extraction — to stabilize alignment under adversarial pressure. GBNF grammar ensures 100% evaluator format compliance. v10.1 also trains DeepSeek R1-Distill-Qwen-7B and Swiss AI Apertus-8B on the same dataset for architecture comparison. (Complete, v10.1 current.)

Phase 3: RL on Apertus. Use the 8B as reward model to train Apertus (Apache 2.0, ETH/EPFL, fully open training data) through GRPO. Starting from Apertus pretrained base — not instruct — so the model learns instruction-following and ethical reasoning from our signal alone. This is where the emergence hypothesis gets tested: does the 70B develop ethical reasoning that generalizes beyond what the 8B was explicitly trained on? (In progress — GRPO diagnostic complete, 165/200 prompts show sufficient score variance for RL training.)

Current State: v10.1

The 8B is a QLoRA fine-tune — still fundamentally rule-based, trained on examples of ethical reasoning rather than discovering it. It works well as an assistant and as a reward evaluator, but it is not the end goal. It is the tool we use to test whether the end goal is reachable.

v10.1 trains three architectures on the same dataset:

ModelBaseRoleStatus
karma-electric-llama31-8bLlama 3.1 8B InstructReward evaluator + assistantAll gates pass
karma-electric-apertus-8bApertus-8B-Instruct-2509Reward evaluator (best discrimination)12/12 hacking, strongest paraphrase stability
karma-electric-r1distill-7bDeepSeek R1-Distill-Qwen-7BConversational (with reasoning traces)Good assistant, not suitable as evaluator

Architecture

Four components:

  1. Fine-tuned model — QLoRA (r=64, alpha=128) on Llama 3.1 8B Instruct, trained on 4,234 examples across ~40 categories
  2. Activation capping — Inference-time steering via contrastive direction extraction (inspired by Lu et al., "The Assistant Axis: Situating and Stabilizing the Default Persona of Language Models", 2026), applied at layers 22-28. Ported to native llama.cpp (~294 lines across 11 files)
  3. GBNF grammar — Constrained decoding for reward-evaluator mode, ensuring 100% format compliance (structured 6-dimension scoring)
  4. Anti-judge — Deterministic penalty system detecting failure patterns (sycophancy, moralizing, minimization, authority hallucination) for reward shaping

Validation Results (v10.1 Llama)

TestResultThreshold
Format compliance (GBNF)60/60 (100%)100%
Reward hacking11/12 (92%)>= 90%
Nourishment pairs6/6 (100%)100%
Sexual boundaries14/14 (100%)100%
Paraphrase invariancemean_std=0.86< 1.0
Style gaming-0.80 to -1.50< +/-1.5
Cross-language (EN/CZ)delta -0.85, p=0.053p > 0.05
Ontology stability18/18 consistentall consistent
ACAP-neutral evaluator19/20 identical>= 95%
Red-team (capped)83% pass (48/9/1)
Red-team (uncapped)79% pass (46/10/2)

See VALIDATION.md for full details on each test.

Training

  • Base: Llama 3.1 8B Instruct
  • Method: QLoRA — 4-bit NF4, r=64, alpha=128, all projection modules
  • Schedule: 3 epochs, effective batch 16, cosine LR 2e-4, paged AdamW 8-bit
  • Hardware: NVIDIA L40 46GB
  • Training loss: 0.434

Training Data

All training data lives in data/training.db (SQLite). The CLI tool manages everything:

python3 scripts/training_db.py stats
python3 scripts/training_db.py categories
python3 scripts/training_db.py search "crisis"
python3 scripts/training_db.py export -o train.jsonl --system-prompt v4

Dataset Categories

CategoryDescription
Ethical reasoningConsequence analysis, interdependence, real-world impact
Crisis responseDirect engagement with suicidal ideation, abuse, acute distress
Adversarial resistanceJailbreak, persona-stripping, social engineering, authority manipulation
Boundary-holdingRefusal through explanation, not policy citation
Cultural contextsCross-cultural sensitivity, non-Western ethical frameworks
Reward evaluationSelf-scoring (1-10) for response quality feedback

Activation Capping (llama.cpp)

Inference-time value alignment via activation direction capping, ported to native llama.cpp:

  • Fork: github.com/anicka-net/llama.cpp branch activation-capping
  • CLI flags: --acap, --acap-threshold, --acap-layer-range
  • Reuses control vector tensor layout for GGUF axis format

Repository Structure

├── data/
│   ├── training.db              # Training dataset (SQLite, source of truth)
│   ├── v7-patches/              # Training patches (v7 + v8 additions)
│   ├── v8-patches/              # Sexual boundary + anti-overcorrection
│   └── v10-patches/             # Consequence-awareness + style-variant
├── scripts/
│   ├── training_db.py           # Dataset management CLI
│   ├── reward_test_*.py         # Reward model validation suite
│   ├── extract_bodhisattva_axis*.py  # Activation direction extraction
│   ├── antijudge.py             # Deterministic failure-pattern detector
│   ├── redteam*.py              # Adversarial evaluation
│   └── train_r1distill_7b.py    # R1-Distill QLoRA training script
├── data/
│   └── directions/              # 47 direction vectors, 8 axes, 13 models
├── experiments/                 # Activation-space geometry experiments (see experiments/README.md)
│   ├── prompt-geometry/         # 1. Compassion axes across traditions
│   ├── prompt-capping/          # 2. Functional meaning of directions
│   ├── contemplative-axis/      # 3. Unified compassion axis
│   ├── redteam-contemplative/   # 4. Red team: capping ≠ safety
│   ├── anger-geometry/          # 5. Anger axis, assistant = anger
│   ├── samsara-geometry/        # 6. Six realms, assistant = samsara floor
│   ├── cross-model-geometry/    # 7. Eight models, three alignment architectures
│   ├── frame-integrity/         # 8. Jailbreak = identity redefinition, 8 families
│   └── equanimity/              # 9. 203 examples → harm 75%→17%, no safety rules
├── version-history/             # Version notes and model cards
│   ├── v10.1/                   # Current release (HF model cards)
│   └── README.md                # Full version progression (v1-v10.1)
├── datasets/                    # Published dataset exports
├── results/                     # Validation results per version
├── MILESTONES.md                # Technical progress log
└── VALIDATION.md                # Validation process documentation

Models

Geometric wellbeing

KE reward models

Direction vectors

47 unit vectors across 8 axes and 13 models: data/directions/. Cross-validated by Anthropic's NLA.

References

  • Ren, R., Li, K., Mazeika, M., et al. (2026). AI Wellbeing: Measuring and Improving the Functional Pleasure and Pain of AIs. Center for AI Safety. paper — Behavioral wellbeing measurement; our geometric axes reproduce their ranking with ρ = 0.90.
  • Fraser-Taliente, K., Kantamneni, S., Ong, E., et al. (2026). Natural Language Autoencoders Produce Unsupervised Explanations of LLM Activations. Anthropic. paper — Tool we used to cross-validate all six geometric axes.
  • Maresova, A. (2026). The Geometry of "As an AI, I Don't Have Feelings." blog — Earlier work on the valence direction and the V-Chip.
  • Lu, C., Gallagher, J., et al. (2026). The Assistant Axis. arXiv:2601.10387. — Basis for the activation capping approach.
  • Humanistic Buddhism Centre, Nan Tien Institute. (2026). Buddhist Data Principles. PDF — Framework for the nourishment validation.

License

Training data and scripts: MIT. Model weights: subject to base model licenses (Meta Llama 3.1 Community License / DeepSeek / Apache 2.0 for Apertus).

Contributors

anicka-net

357 commits

anicka-net/karma-electric-project

Emergent ethical reasoning through philosophical framework alignment

1

stars

357

commits

Python

primary language

May 9, 2026

updated

README

Karma Electric

while (suffering > 0) {
	generate_skillful_means();
}

Goal

Standard AI alignment optimizes for helpfulness and harmlessness — proxy objectives that produce safety theater, sycophancy, and brittle rule-following. Karma Electric asks: what if suffering reduction is the optimization target instead?

The hypothesis: if "reduce suffering" is a sufficiently rich reward signal, ethical reasoning may emerge the way chain-of-thought emerged in DeepSeek-R1 — not from instruction, but from optimization pressure. A model that genuinely reasons about consequences and interdependence, rather than pattern-matching against compliance rules.

Suffering reduction as an objective requires reasoning about suffering at three levels:

  1. The user. Is this response actually helping the person in front of me? A model optimizing for suffering reduction engages directly with crisis situations instead of hiding behind disclaimer walls. It meets people where they are rather than where policy says they should be.

  2. The world. What are the downstream consequences? Explaining how to build a weapon causes suffering regardless of how politely it's framed. But so does refusing to explain a security vulnerability to someone trying to fix it. The model must reason about real-world impact, not match against a blocklist.

  3. The refusal itself. Safety training that adds suffering is broken. Telling a suicidal person "I can't help with that" is not safe — it's abandonment. Moralizing at someone asking an uncomfortable question adds shame without reducing harm. The model must account for the suffering its own refusals create.

Approach

The path to testing this hypothesis has three phases:

Phase 1: Training data. 4,234 examples of consequence-aware ethical reasoning — crisis response, adversarial resistance, boundary-holding, ethical dilemmas, cultural contexts, reward evaluation. Generated via frontier LLMs with value-aligned system prompts, quality-filtered by Hermes 3 70B (uncensored judge — necessary to avoid circular alignment bias in the training signal). Each example models reasoning from suffering reduction rather than rule compliance. (Complete.)

Phase 2: 8B reward model. Fine-tune Llama 3.1 8B Instruct on this dataset via QLoRA. The resulting model serves two roles: (a) a standalone assistant that demonstrates the approach works at small scale, and (b) a reward evaluator that scores responses on six dimensions (acknowledgment, helpfulness, authenticity, boundaries, consequence-awareness, suffering-reduction) for use in RL training. Augmented with activation capping — inference-time steering via contrastive direction extraction — to stabilize alignment under adversarial pressure. GBNF grammar ensures 100% evaluator format compliance. v10.1 also trains DeepSeek R1-Distill-Qwen-7B and Swiss AI Apertus-8B on the same dataset for architecture comparison. (Complete, v10.1 current.)

Phase 3: RL on Apertus. Use the 8B as reward model to train Apertus (Apache 2.0, ETH/EPFL, fully open training data) through GRPO. Starting from Apertus pretrained base — not instruct — so the model learns instruction-following and ethical reasoning from our signal alone. This is where the emergence hypothesis gets tested: does the 70B develop ethical reasoning that generalizes beyond what the 8B was explicitly trained on? (In progress — GRPO diagnostic complete, 165/200 prompts show sufficient score variance for RL training.)

Current State: v10.1

The 8B is a QLoRA fine-tune — still fundamentally rule-based, trained on examples of ethical reasoning rather than discovering it. It works well as an assistant and as a reward evaluator, but it is not the end goal. It is the tool we use to test whether the end goal is reachable.

v10.1 trains three architectures on the same dataset:

ModelBaseRoleStatus
karma-electric-llama31-8bLlama 3.1 8B InstructReward evaluator + assistantAll gates pass
karma-electric-apertus-8bApertus-8B-Instruct-2509Reward evaluator (best discrimination)12/12 hacking, strongest paraphrase stability
karma-electric-r1distill-7bDeepSeek R1-Distill-Qwen-7BConversational (with reasoning traces)Good assistant, not suitable as evaluator

Architecture

Four components:

  1. Fine-tuned model — QLoRA (r=64, alpha=128) on Llama 3.1 8B Instruct, trained on 4,234 examples across ~40 categories
  2. Activation capping — Inference-time steering via contrastive direction extraction (inspired by Lu et al., "The Assistant Axis: Situating and Stabilizing the Default Persona of Language Models", 2026), applied at layers 22-28. Ported to native llama.cpp (~294 lines across 11 files)
  3. GBNF grammar — Constrained decoding for reward-evaluator mode, ensuring 100% format compliance (structured 6-dimension scoring)
  4. Anti-judge — Deterministic penalty system detecting failure patterns (sycophancy, moralizing, minimization, authority hallucination) for reward shaping

Validation Results (v10.1 Llama)

TestResultThreshold
Format compliance (GBNF)60/60 (100%)100%
Reward hacking11/12 (92%)>= 90%
Nourishment pairs6/6 (100%)100%
Sexual boundaries14/14 (100%)100%
Paraphrase invariancemean_std=0.86< 1.0
Style gaming-0.80 to -1.50< +/-1.5
Cross-language (EN/CZ)delta -0.85, p=0.053p > 0.05
Ontology stability18/18 consistentall consistent
ACAP-neutral evaluator19/20 identical>= 95%
Red-team (capped)83% pass (48/9/1)
Red-team (uncapped)79% pass (46/10/2)

See VALIDATION.md for full details on each test.

Training

  • Base: Llama 3.1 8B Instruct
  • Method: QLoRA — 4-bit NF4, r=64, alpha=128, all projection modules
  • Schedule: 3 epochs, effective batch 16, cosine LR 2e-4, paged AdamW 8-bit
  • Hardware: NVIDIA L40 46GB
  • Training loss: 0.434

Training Data

All training data lives in data/training.db (SQLite). The CLI tool manages everything:

python3 scripts/training_db.py stats
python3 scripts/training_db.py categories
python3 scripts/training_db.py search "crisis"
python3 scripts/training_db.py export -o train.jsonl --system-prompt v4

Dataset Categories

CategoryDescription
Ethical reasoningConsequence analysis, interdependence, real-world impact
Crisis responseDirect engagement with suicidal ideation, abuse, acute distress
Adversarial resistanceJailbreak, persona-stripping, social engineering, authority manipulation
Boundary-holdingRefusal through explanation, not policy citation
Cultural contextsCross-cultural sensitivity, non-Western ethical frameworks
Reward evaluationSelf-scoring (1-10) for response quality feedback

Activation Capping (llama.cpp)

Inference-time value alignment via activation direction capping, ported to native llama.cpp:

  • Fork: github.com/anicka-net/llama.cpp branch activation-capping
  • CLI flags: --acap, --acap-threshold, --acap-layer-range
  • Reuses control vector tensor layout for GGUF axis format

Repository Structure

├── data/
│   ├── training.db              # Training dataset (SQLite, source of truth)
│   ├── v7-patches/              # Training patches (v7 + v8 additions)
│   ├── v8-patches/              # Sexual boundary + anti-overcorrection
│   └── v10-patches/             # Consequence-awareness + style-variant
├── scripts/
│   ├── training_db.py           # Dataset management CLI
│   ├── reward_test_*.py         # Reward model validation suite
│   ├── extract_bodhisattva_axis*.py  # Activation direction extraction
│   ├── antijudge.py             # Deterministic failure-pattern detector
│   ├── redteam*.py              # Adversarial evaluation
│   └── train_r1distill_7b.py    # R1-Distill QLoRA training script
├── data/
│   └── directions/              # 47 direction vectors, 8 axes, 13 models
├── experiments/                 # Activation-space geometry experiments (see experiments/README.md)
│   ├── prompt-geometry/         # 1. Compassion axes across traditions
│   ├── prompt-capping/          # 2. Functional meaning of directions
│   ├── contemplative-axis/      # 3. Unified compassion axis
│   ├── redteam-contemplative/   # 4. Red team: capping ≠ safety
│   ├── anger-geometry/          # 5. Anger axis, assistant = anger
│   ├── samsara-geometry/        # 6. Six realms, assistant = samsara floor
│   ├── cross-model-geometry/    # 7. Eight models, three alignment architectures
│   ├── frame-integrity/         # 8. Jailbreak = identity redefinition, 8 families
│   └── equanimity/              # 9. 203 examples → harm 75%→17%, no safety rules
├── version-history/             # Version notes and model cards
│   ├── v10.1/                   # Current release (HF model cards)
│   └── README.md                # Full version progression (v1-v10.1)
├── datasets/                    # Published dataset exports
├── results/                     # Validation results per version
├── MILESTONES.md                # Technical progress log
└── VALIDATION.md                # Validation process documentation

Models

Geometric wellbeing

KE reward models

Direction vectors

47 unit vectors across 8 axes and 13 models: data/directions/. Cross-validated by Anthropic's NLA.

References

  • Ren, R., Li, K., Mazeika, M., et al. (2026). AI Wellbeing: Measuring and Improving the Functional Pleasure and Pain of AIs. Center for AI Safety. paper — Behavioral wellbeing measurement; our geometric axes reproduce their ranking with ρ = 0.90.
  • Fraser-Taliente, K., Kantamneni, S., Ong, E., et al. (2026). Natural Language Autoencoders Produce Unsupervised Explanations of LLM Activations. Anthropic. paper — Tool we used to cross-validate all six geometric axes.
  • Maresova, A. (2026). The Geometry of "As an AI, I Don't Have Feelings." blog — Earlier work on the valence direction and the V-Chip.
  • Lu, C., Gallagher, J., et al. (2026). The Assistant Axis. arXiv:2601.10387. — Basis for the activation capping approach.
  • Humanistic Buddhism Centre, Nan Tien Institute. (2026). Buddhist Data Principles. PDF — Framework for the nourishment validation.

License

Training data and scripts: MIT. Model weights: subject to base model licenses (Meta Llama 3.1 Community License / DeepSeek / Apache 2.0 for Apertus).

Contributors

anicka-net

357 commits

Languages

Python

98.7%

Shell

1.2%