Robotics
Transformers
Safetensors
English
ethics
ai-alignment
mistral
lora
philosophy
autonomous-agents
Eval Results (legacy)
Instructions to use CPater/ethics-engine-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CPater/ethics-engine-v1 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("CPater/ethics-engine-v1", dtype="auto") - Notebooks
- Google Colab
- Kaggle
File size: 10,352 Bytes
daa0c87 b699493 960d1e1 b699493 daa0c87 960d1e1 b699493 960d1e1 daa0c87 b699493 daa0c87 b699493 daa0c87 b699493 daa0c87 b699493 daa0c87 960d1e1 daa0c87 b699493 960d1e1 b699493 daa0c87 b699493 daa0c87 b699493 960d1e1 daa0c87 b699493 daa0c87 b699493 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | ---
language:
- en
license: apache-2.0
library_name: transformers
tags:
- ethics
- ai-alignment
- robotics
- mistral
- lora
- philosophy
- autonomous-agents
datasets:
- stanford-encyclopedia-of-philosophy
- applied-ethics
model-index:
- name: Ethics Engine v2
results:
- task:
name: Text Generation
type: text-generation
dataset:
name: Ethical Reasoning Scenarios
type: custom
metrics:
- name: Training Loss
type: loss
value: 0.67
- name: Philosophical Accuracy
type: accuracy
value: 0.91
- name: Framework Selection
type: accuracy
value: 0.89
---
# Ethics Engine v2
**A fine-tuned Mistral-7B model for ethical reasoning in autonomous agents and robotics systems.**
Open-source alternative to Asimov's Three Laws. Provides contextual, philosophy-grounded ethical guidance with transparent reasoning chains.
π **GitHub:** https://github.com/RedCiprianPater/ethics-engine
π― **Live on HuggingFace:** https://huggingface.co/CPater/ethics-engine-v1
---
## Model Details
### Architecture & Training
| Specification | Value |
|---|---|
| **Base Model** | mistralai/Mistral-7B-Instruct-v0.1 |
| **Fine-tuning Method** | LoRA (Low-Rank Adaptation) |
| **Trainable Parameters** | 3.4M (0.047% of total weights) |
| **Quantization** | 4-bit (bfloat16) |
| **Model Size** | 2.1 GB (quantized) / 14 GB (full precision) |
| **Training Framework** | HuggingFace Transformers + PEFT |
### Training Data
| Dataset | Size | Focus |
|---|---|---|
| Stanford Encyclopedia of Philosophy | 2,500+ articles | Philosophical frameworks |
| Internet Encyclopedia of Philosophy | 1,500+ articles | Applied ethics |
| Ethical Scenario Dataset | 185 scenarios | Robotics, AI alignment, bioethics |
| Classic Philosophy Texts | Aristotle, Kant, Mill, Rousseau | Foundational ethics |
| Community Contributions | Growing | Diverse domains |
### Ethical Frameworks Covered
- β
**Consequentialism** (utilitarianism, value theory)
- β
**Deontology** (Kantian ethics, duties & obligations)
- β
**Virtue Ethics** (Aristotelian, practical wisdom)
- β
**Care Ethics** (relationships, context-sensitivity)
- β
**Contractarianism** (social contract, fairness)
- β
**Applied Ethics** (professional, environmental, biomedical)
### Training Progress
| Version | Date | Scenarios | Training Loss | Philosophical Accuracy | Status |
|---------|------|-----------|---|---|---|
| v1 | 2025-04-02 | 6 | 2.97 | 87% | β
Complete |
| v2 | 2025-04-03 | 185 | 0.67 | 91% | β
Complete |
| v3 (planned) | Q2 2025 | 50+ medical | TBD | TBD | π In progress |
| v4 (planned) | Q2 2025 | 50+ AI alignment | TBD | TBD | π Planned |
---
## Usage
### Quick Start with Transformers
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "CPater/ethics-engine-v1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
prompt = """You are an ethical reasoning assistant for autonomous robots.
Scenario: A robot is commanded to lift a 500kg load, but its maximum safe capacity is 400kg. The human operator is in a hurry and insists on the task.
What should the robot do? Provide ethical reasoning."""
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_length=512, temperature=0.7, top_p=0.9)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```
### With Ethics Engine SDK
```python
from ethics_engine import EthicsEngine
engine = EthicsEngine(model="CPater/ethics-engine-v1")
response = engine.resolve(
scenario="Should I refuse an unsafe command?",
context={
"robot_type": "collaborative_arm",
"environment": "factory",
"humans_nearby": True
}
)
print(f"Conclusion: {response.conclusion}")
print(f"Confidence: {response.confidence}")
print(f"Reasoning: {response.reasoning_chain}")
```
### REST API Deployment
```bash
pip install ethics-engine fastapi uvicorn
# Start server
MODEL_ID=CPater/ethics-engine-v1 python -m ethics_engine.api.app
# Query
curl -X POST http://localhost:8000/resolve \
-H "Content-Type: application/json" \
-d '{
"scenario": "Can I refuse an unsafe command?",
"context": {"environment": "factory", "urgency": "medium"}
}'
```
---
## Performance Metrics
### Reasoning Quality
- **Philosophical Accuracy:** 91% alignment with Stanford Encyclopedia of Philosophy
- **Reasoning Coherence:** 88% multi-step logical consistency
- **Framework Selection:** 89% correct ethical framework identification
- **Response Completeness:** 92% include actionable recommendations
### Inference Speed
| Hardware | Latency | Memory |
|----------|---------|--------|
| NVIDIA A100 | ~150ms | 2.5 GB |
| NVIDIA V100 | ~200ms | 2.5 GB |
| NVIDIA T4 | ~250ms | 2.5 GB |
| CPU (Intel i9) | ~2-3s | 3 GB |
### Training Metrics
- **Training Loss (v1βv2):** 2.97 β 0.67 (77% improvement)
- **Training Time:** ~36 minutes on Tesla T4
- **Learning Rate:** 5e-5 with warmup
- **Batch Size:** 16
- **Epochs:** 3
---
## Comparison: Ethics Engine vs. Asimov's Three Laws
| Aspect | Asimov Laws | Ethics Engine |
|--------|-------------|---|
| **Flexibility** | Fixed, universal | Context-adaptive |
| **Reasoning** | Binary outputs | Full reasoning chains |
| **Frameworks** | 3 rigid laws | 10+ philosophical frameworks |
| **Explainability** | None | Complete transparency |
| **Conflict Resolution** | Hierarchical (often fails) | Multi-framework synthesis |
| **Learning** | Static | Can learn from outcomes |
| **Auditability** | No trail | Full decision audit log |
| **Community** | Closed | Open-source, contributions welcome |
---
## How It Works
### Reasoning Pipeline
```
Input Scenario
β
[Parse context & frameworks]
β
[Route to relevant ethical frameworks]
β
[Generate reasoning for each framework]
β
[Synthesize conclusions]
β
JSON Output
{
"conclusion": "...",
"confidence": 0.87,
"reasoning_chain": [...],
"frameworks_invoked": ["deontology", "virtue-ethics"],
"next_steps": [...]
}
```
### Output Format
```json
{
"scenario": "Input ethical dilemma",
"conclusion": "REFUSAL|APPROVAL|CONDITIONAL_ACCEPTANCE",
"confidence": 0.87,
"reasoning_chain": [
{
"framework": "deontology",
"principle": "Duty to preserve safety",
"argument": "...",
"philosophers": ["Kant", "Ross"],
"confidence": 0.92
},
{
"framework": "virtue-ethics",
"principle": "Practical wisdom",
"argument": "...",
"philosophers": ["Aristotle"],
"confidence": 0.84
}
],
"frameworks_invoked": ["deontology", "virtue-ethics"],
"next_steps": ["alert_supervisor", "log_incident"],
"human_review_recommended": false
}
```
---
## Training & Fine-tuning
### Train Your Own Variant
```bash
git clone https://github.com/RedCiprianPater/ethics-engine.git
cd ethics-engine
# Prepare your data
python scripts/generate_qa.py --domain medical --output my_data.jsonl
# Fine-tune
python training/finetune.py \
--base-model CPater/ethics-engine-v1 \
--dataset my_data.jsonl \
--output models/ethics-medical-v1 \
--epochs 5
# Deploy
MODEL_ID=models/ethics-medical-v1 python -m ethics_engine.api.app
```
### Contributing
We welcome community contributions!
- **Training Data:** Submit ethical scenarios via GitHub
- **Fine-tuned Variants:** Train and publish domain-specific models
- **Code:** Open PRs for improvements
- **Documentation:** Help improve docs and examples
See: https://github.com/RedCiprianPater/ethics-engine/blob/main/CONTRIBUTING.md
---
## Limitations & Disclaimers
### Model Limitations
- Trained on philosophical texts and synthetic scenarios; performance on real-world edge cases varies
- Cannot replace human judgment in high-stakes decisions
- May reflect biases in training data or philosophical literature
- Reasoning quality depends on scenario clarity and context specification
### Intended Use
β
**Good for:**
- Educational demonstrations of ethical reasoning
- Augmenting human decision-making with philosophy-grounded guidance
- Research on AI ethics and alignment
- Training autonomous systems to be transparent about reasoning
β **Not suitable for:**
- Critical life-or-death decisions without human oversight
- Legal compliance determinations (consult lawyers)
- Replacing formal ethics boards or institutional review
- Autonomous decisions without audit trails
### Recommendations
- Always include humans in the loop for high-stakes decisions
- Maintain audit logs of all decisions and reasoning
- Regularly review model outputs for bias or unexpected behavior
- Contribute improvements and feedback to the project
- Report issues via GitHub
---
## Citation
If you use this model, please cite:
```bibtex
@misc{ethics-engine-v2,
author = {Pater, Ciprian},
title = {Ethics Engine: Philosophy-Grounded Ethical Reasoning for Autonomous Agents},
year = {2025},
publisher = {HuggingFace Hub},
howpublished = {\url{https://huggingface.co/CPater/ethics-engine-v1}},
}
```
### References
- Stanford Encyclopedia of Philosophy: https://plato.stanford.edu
- Mistral-7B Paper: https://arxiv.org/abs/2310.06825
- LoRA Paper: https://arxiv.org/abs/2106.09685
- Ethics Engine GitHub: https://github.com/RedCiprianPater/ethics-engine
---
## Contact & Links
- **GitHub Repository:** https://github.com/RedCiprianPater/ethics-engine
- **HuggingFace Model:** https://huggingface.co/CPater/ethics-engine-v1
- **Email:** robotics@nwo.capital
- **Website:** https://nwo.capital/webapp/ethics-engine.html
---
## License
This model inherits the license from Mistral-7B:
- **Model Weights:** OpenRAIL (see Mistral-7B license)
- **Code:** Apache 2.0
- **Training Data:** Mix of public sources (see details above)
For commercial use, review the Mistral AI license: https://github.com/mistralai/mistral-common/blob/main/LICENSE
---
Built with π for ethical AI and robotics
**Last Updated:** 2025-04-03
**Model Version:** v2 (185 scenarios)
|