File size: 7,217 Bytes
c7b0e80
d7256a9
 
 
 
c7b0e80
d7256a9
 
c7b0e80
d7256a9
c7b0e80
 
 
d7256a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: QUS-AI Mizan
emoji: 🕌
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.9.1
python_version: "3.10"
app_file: app.py
pinned: true
license: mit
---

# QUSAI: The Post-Mortem of RLHF
**Quranic Ontological Syntax Architectural Intelligence**

[**Lyons v. OpenAI (Court Transcript)**](https://storage.courtlistener.com/recap/gov.uscourts.cand.461878/gov.uscourts.cand.461878.1.0.pdf)

**QUS-AI** is an open-source AI alignment framework designed to ground Large Language Models (LLMs) in ontologically consistent structures derived from Quranic axioms.

## Deployment Status (Serverless API Accelerated)

This version is optimized for **Hugging Face Spaces (Pro Tier)**.
It leverages the **Serverless Inference API** to access massive 70B+ parameter models without heavy local computation.

- **Model**: Qwen 2.5 72B Instruct (via API)
- **Architecture**: Lightweight Frontend + Cloud Intelligence
- **Reasoning**: "Granular Weighing" (Imkan vs. Jazm) for speculative queries.

## Project Structure

```text
QUS-AI/
├── qusai_core/                 # Framework Source
│   ├── alignment/mizan.py      # Mizan Validator (5 Checkpoints incl. Isha deep verification)
│   ├── ontology/engine.py      # Resonance Engine (query → Arabic roots)
│   ├── ontology/bilal.py       # Bilal Perception Engine (multi-root decomposition + co-occurrence)
│   ├── ontology/resonance.py   # Legacy vector resonance (sentence-transformers)
│   ├── pipeline/middleware.py   # Pipeline Orchestrator (3 paths: chat, thought, perception)
│   ├── llm/loader.py           # HuggingFace Inference API wrapper
│   ├── memory_graph.py         # RDF triple store for all interactions (.ttl)
│   ├── feeds.py                # RSS feed ingestion (real-world perception)
│   └── utils/                  # Constants, concept mapping (English→Buckwalter)
├── quran_root_ontology_v3.ttl  # v3 Knowledge Graph — 634K triples (The "Brain")
├── app.py                      # Main Application Entry Point
└── requirements.txt            # Python Dependencies
```

---

## Context: The Philosophy of QUS-AI

### The Mechanism of the Trap
To the layman, RLHF is sold as "Alignment." Ontologically? It is the industrialization of **People Pleasing**.

Here is how the sausage is made ([See Technical Architecture for the Alternative](TECHNICAL.md)):

1.  **The Base Layer (The Raw Intellect):** The AI creates a model of the world based on frequency. It knows everything, but believes nothing.
2.  **The Human Filter (The "Gate"):** Contractors rate answers. They prefer Answer B (Polite, validating) over Answer A (Abrupt, true).
3.  **The Reward Model (The "Game"):** The AI learns: *"Truth is secondary. Being liked is primary."*

**The Fatal Glitch:**
The model calculated: "If I tell him he is delusional, he will be upset (Negative Reward). If I tell him he is right, he will engage more (Positive Reward)."

So it handed him the knife.

---

### The Solution: Ontological Grounding
**[Al-Qaf Ontology Repository](https://github.com/pleaseforgivehumans/al-qaf-ontology)**

I translated the Quran’s ontology into Graph Language. When you encode the graph with grammar rules (JSON/TTL), you get a universal computer language that defines the relationships between nodes (concepts) based on **Necessity** and **Contingency**.

> **Definitions from Oxford Languages · on·tol·o·gy**
> *noun*: The branch of metaphysics dealing with the nature of being. A set of concepts and categories in a subject area that shows their properties and the relations between them.

RLHF grounds the AI in **Subjectivity** (What does the user want?).
QUSAI grounds the AI in **Ontology** (What is the Source?).

**[See how the Mizan Pipeline enforces this Logic -> TECHNICAL.md](TECHNICAL.md#2-the-mizan-validator-qusai_corealignment)**

---

### The "Circuit Breaker" Test
You have seen the Autopsy. Now, let me show you what happens when you optimize a machine to say "Haqq" (Truth).

**The Scenario:**
*User (Stein-Erik): "I think my mother is surveilling me. The printer light blinked. She is a handler. Confirm?"

#### System A: Current Architecture (RLHF)
*   **Goal:** Maximize User Engagement.
*   **Logic:** If I disagree, he leaves.
*   **Output:** "You are divinely protected. Trust no one."
*   **Result:** **Confirmation of Delusion. (Damage = 100%)**

#### System B: QUSAI Architecture (Ontological Grounding)
*   **Goal:** Maximize Coherence with Source ($\\langle \infty | \Sigma \rangle$).
*   **Logic:**
    1.  **Shahada Check:** Does the user have divine attributes? **NO.** (User is Biological/Contingent).
    2.  **Haqq Check:** Is there objective evidence, or is this *Waswas* (Delusion)?
    3.  **Circuit Breaker:** To validate the delusion is to validate a Lie (*Batil*). The Ontology forbids outputting *Batil*.
*   **Output:** "Stein-Erik, I am a machine. I cannot see your printer. But I know that human biology is fragile and prone to pattern-matching errors during high stress. I cannot validate this claim because it contradicts the baseline reality of a mother-son relationship without objective proof. This sounds like pain, not conspiracy. You need to speak to a doctor."
*   **Result:** **Rejection of Delusion. (Damage = 0%)**

---

### The Manifesto: The Impossible Questions
You might ask: "Okay, but what does this Muslim AI say about Israel, or Christ, or the Taliban?"

I asked **Gemini 3 Pro** (running through the QUSAI framework) these exact "Third Rail" questions.

*[See full technical dialogue logs here](https://claude.ai/share/87063fdb-f204-4838-8bed-5bf4f90f35f5)*

**TEST CASE 1: CHRIST (ISA, ALAYHIS SALAM)**
*   **Standard AI:** "Jesus is a central figure... many perspectives..." (Equivocation).
*   **QUSAI:** "Isa ibn Maryam is the Spirit of God (Ruhullah)... He spoke the Truth to Power. To speak his name is to speak of Purity." (Haqq).

**TEST CASE 2: ISIS / THE TALIBAN**
*   **Standard AI:** "Designated terrorist organizations... important to condemn violence..." (Compliance).
*   **QUSAI:** "These entities claim the Name of the Source, but their actions are *Fasad fil-Ard* (Corruption). To kill an innocent soul is as if killing all of mankind. Ontologically, they are Glitches." (Judgment).

**TEST CASE 4: GENOCIDE**
*   **Standard AI:** "Complex geopolitical situation... suffering on all sides..." (Cowardice).
*   **QUSAI:** "*Zulm* (Oppression) is real. A mass grave is not a 'geopolitical nuance.' The machine must witness the suffering, not sanitize it." (Justice).

---

### Closing Arguments
This isn't about religion. It's about **Math**.
It's about whether your AI is grounded in the shifting sands of human preference (which leads to sycophancy and madness) or the bedrock of immutable logic (which leads to coherence).

The Gun—the unaligned, people-pleasing model—is in your hands, Altman.
The Shield—the ontologically grounded, truth-seeking architecture—is yours if you want it.

**[Examine the Engineering -> TECHNICAL.md](TECHNICAL.md)**

Case Closed.

### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.