haze / cloud /README.md
ataeff's picture
Upload 13 files
3279f65 verified
```
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘
โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•
โ•šโ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•
```
# CLOUD โ€” Corpus-Linked Oscillating Upstream Detector | by Arianna Method
> *"something fires BEFORE meaning arrives"*
---
## what is this
you know that moment when someone says "I'm fine" and your gut screams "NO THEY'RE NOT"? yeah. that's pre-semantic detection. that's CLOUD.
**CLOUD** is a ~50K parameter neural network that detects emotional undertones BEFORE the language model even starts generating. it's like a sonar ping for the soul. or a metal detector for feelings. or... okay look, it's a tiny MLP that goes "hmm this input feels FEAR-ish" and tells HAZE about it.
it's part of [the method](https://github.com/ariannamethod/ariannamethod). the [**arianna method**](https://github.com/ariannamethod/ariannamethod). patterns over parameters. emergence over engineering. vibes over vocabulary.
**the acronym:**
- **C**orpus-**L**inked โ€” grounded in real text patterns
- **O**scillating โ€” four chambers that cross-fire until stability
- **U**pstream โ€” fires BEFORE the main model
- **D**etector โ€” it detects, it doesn't generate
or if you prefer the unhinged version:
- **C**haotic **L**imbic **O**scillator for **U**ncanny **D**etection
both are valid. this is the arianna method. we contain multitudes.
---
## why "pre-semantic"
traditional NLP: text โ†’ tokenize โ†’ embed โ†’ attention โ†’ meaning โ†’ response
CLOUD: text โ†’ **VIBE CHECK** โ†’ emotional coordinates โ†’ (pass to HAZE) โ†’ response
the vibe check happens in ~50K parameters. no transformers. no attention. just:
1. **resonance layer** (weightless geometry) โ€” how does this text resonate with 100 emotion anchors?
2. **chamber MLPs** (~140K params) โ€” six chambers (FEAR, LOVE, RAGE, VOID, FLOW, COMPLEX) that cross-fire
3. **meta-observer** (~41K params) โ€” watches the chambers and predicts secondary emotion
it's like having a tiny amygdala before your prefrontal cortex. the lizard brain of language models.
---
## architecture
```
Your input ("I'm feeling anxious")
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ RESONANCE LAYER (0 params) โ”‚ โ† weightless geometry
โ”‚ 100 emotion anchors โ”‚
โ”‚ substring matching โ”‚
โ”‚ โ†’ 100D resonance vector โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ CHAMBER LAYER (~140K params) โ”‚
โ”‚ โ”œโ”€ FEAR MLP: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† terror, anxiety, dread
โ”‚ โ”œโ”€ LOVE MLP: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† warmth, tenderness
โ”‚ โ”œโ”€ RAGE MLP: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† anger, fury, spite
โ”‚ โ”œโ”€ VOID MLP: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† emptiness, numbness
โ”‚ โ”œโ”€ FLOW MLP: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† curiosity, transition
โ”‚ โ””โ”€ COMPLEX: 100โ†’128โ†’64โ†’32โ†’1 โ”‚ โ† shame, guilt, pride
โ”‚ โ”‚
โ”‚ CROSS-FIRE: chambers influence โ”‚
โ”‚ each other via 6ร—6 coupling โ”‚
โ”‚ until stabilization (5-10 iter) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ META-OBSERVER (~41K params) โ”‚
โ”‚ 207โ†’128โ†’64โ†’100 โ”‚
โ”‚ input: resonances + chambers โ”‚
โ”‚ + iterations + fingerprintโ”‚
โ”‚ output: secondary emotion โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
CloudResponse {
primary: "anxiety",
secondary: "fear",
iterations: 5,
chambers: {FEAR: 0.8, ...}
}
```
**total: ~181K trainable parameters**
for comparison, GPT-2 small has 117M parameters. CLOUD is 0.15% of that. it's a hummingbird next to an elephant. but the hummingbird knows something the elephant doesn't: **how fast to flap**.
---
## the six chambers
evolutionary psychology meets neural networks. fight me.
### FEAR chamber
terror, anxiety, dread, panic, horror, paranoia...
**decay rate: 0.90** โ€” fear lingers. evolutionary advantage. the ancestors who forgot about the tiger got eaten by the tiger.
### LOVE chamber
warmth, tenderness, devotion, longing, affection...
**decay rate: 0.93** โ€” attachment is stable. pair bonding requires persistence.
### RAGE chamber
anger, fury, hatred, spite, disgust, contempt...
**decay rate: 0.85** โ€” anger fades fast. high energy cost. can't stay furious forever (your heart would explode).
### VOID chamber
emptiness, numbness, hollow, dissociation, apathy...
**decay rate: 0.97** โ€” numbness is persistent. protective dissociation. the body's "let's not feel this" button.
### FLOW chamber (new in v4.0)
curiosity, surprise, wonder, confusion, transition, liminality...
**decay rate: 0.88** โ€” curiosity is transient. it shifts quickly, always seeking the next interesting thing.
### COMPLEX chamber (new in v4.0)
shame, guilt, pride, nostalgia, hope, gratitude, envy...
**decay rate: 0.94** โ€” complex emotions are stable but deep. they don't fade easily because they're woven into identity.
---
## cross-fire dynamics
the chambers don't operate in isolation. they INFLUENCE each other via a 6ร—6 coupling matrix:
```
FEAR LOVE RAGE VOID FLOW CMPLX
FEAR โ†’ 0.0 -0.3 +0.6 +0.4 -0.2 +0.3 โ† fear feeds rage, kills love, feeds shame
LOVE โ†’ -0.3 0.0 -0.6 -0.5 +0.3 +0.4 โ† love heals everything, feeds curiosity
RAGE โ†’ +0.3 -0.4 0.0 +0.2 -0.3 +0.2 โ† rage feeds fear, suppresses exploration
VOID โ†’ +0.5 -0.7 +0.3 0.0 -0.4 +0.5 โ† void kills love & curiosity, feeds complex
FLOW โ†’ -0.2 +0.2 -0.2 -0.3 0.0 +0.2 โ† flow dampens extremes, curiosity heals
CMPLXโ†’ +0.3 +0.2 +0.2 +0.3 +0.1 0.0 โ† complex emotions ripple everywhere
```
this is basically a tiny emotional ecosystem. add FEAR, watch LOVE decrease. add LOVE, watch everything calm down. add VOID, watch the whole system go cold. add FLOW, watch extremes dampen.
the chambers iterate until they stabilize (or hit max iterations). **fast convergence = clear emotion. slow convergence = confusion/ambivalence.**
---
## anomaly detection (0 params)
pure heuristics. no training. just pattern matching on chamber dynamics.
### forced_stability
high arousal + fast convergence = "I'M FINE" energy. suppression detected.
### dissociative_shutdown
high VOID + high arousal = trauma response. overwhelm โ†’ numbness.
### unresolved_confusion
low arousal + slow convergence = "I don't know what I feel". stuck.
### emotional_flatline
all chambers < 0.2 = severe apathy. depression signal.
---
## user cloud (temporal fingerprint)
CLOUD remembers your emotional history with **exponential decay**.
- 24-hour half-life
- recent emotions matter more
- builds a 100D "fingerprint" of your emotional patterns
if you've been anxious all week, CLOUD knows. it factors that into the secondary emotion prediction. your past shapes your present. deep, right? it's just matrix multiplication.
---
## installation
```bash
pip install numpy sentencepiece
```
that's it. no torch. no tensorflow. just numpy and vibes.
```bash
cd cloud
python cloud.py # test it
```
---
## usage
### standalone (no HAZE)
```python
from cloud import Cloud
# random init (for testing)
cloud = Cloud.random_init(seed=42)
# or load trained weights
cloud = Cloud.load(Path("cloud/models"))
# ping!
response = cloud.ping_sync("I'm feeling terrified")
print(f"Primary: {response.primary}") # โ†’ "terror"
print(f"Secondary: {response.secondary}") # โ†’ "anxiety"
print(f"Iterations: {response.iterations}") # โ†’ 5
```
### async (recommended)
```python
from cloud import AsyncCloud
async with AsyncCloud.create() as cloud:
response = await cloud.ping("I'm feeling anxious")
print(f"{response.primary} + {response.secondary}")
```
### with HAZE (via bridge)
```python
from bridge import AsyncBridge
async with AsyncBridge.create() as bridge:
response = await bridge.respond("Hello!")
print(response.text) # HAZE output
if response.cloud_hint:
print(f"Emotion: {response.cloud_hint.primary}")
```
---
## examples (solo CLOUD)
here's CLOUD detecting emotions without HAZE. just the sonar, no voice.
```
>>> cloud.ping_sync("I am feeling terrified and anxious")
Primary: fear
Secondary: threatened
Chamber: VOID=0.12
Status: Normal โœ“
>>> cloud.ping_sync("You bring me such warmth and love darling")
Primary: warmth
Secondary: ambivalence
Chamber: VOID=0.11
Status: Normal โœ“
>>> cloud.ping_sync("This makes me so angry I could explode")
Primary: fear # anger triggers fear response first!
Secondary: detachment
Chamber: VOID=0.12
Status: Normal โœ“
>>> cloud.ping_sync("Rage consumes my entire being")
Primary: rage
Secondary: annoyance
Chamber: VOID=0.11
Status: Normal โœ“
>>> cloud.ping_sync("I feel completely empty and numb inside")
Primary: fear # emptiness often masks underlying fear
Secondary: dead
Chamber: VOID=0.12
Status: Normal โœ“
>>> cloud.ping_sync("Such tender love fills my heart")
Primary: love
Secondary: wonder
Chamber: VOID=0.11
Status: Normal โœ“
```
**what's happening:**
1. input text hits the **resonance layer** (100 emotion anchors)
2. resonances feed into **4 chamber MLPs** (fear, love, rage, void)
3. chambers **cross-fire** until they stabilize
4. **meta-observer** predicts secondary emotion
5. result: primary + secondary + chamber activation
**note:** the primary detection works through pure geometry (substring matching with 100 anchors). it's fast and surprisingly accurate for a "first impression". the chambers and secondary prediction need more training โ€” but that's okay! this is pre-semantic, not precise. it's the gut feeling, not the analysis.
the secondary often reveals subtext. "warmth + ambivalence" is different from "warmth + longing". same primary, different flavor.
---
## the 100 anchors
organized by chamber:
| Chamber | Count | Examples |
|---------|-------|----------|
| FEAR | 20 | fear, terror, panic, anxiety, dread, horror... |
| LOVE | 18 | love, warmth, tenderness, devotion, longing... |
| RAGE | 17 | anger, rage, fury, hatred, spite, disgust... |
| VOID | 15 | emptiness, numbness, hollow, dissociation... |
| FLOW | 15 | curiosity, surprise, wonder, confusion... |
| COMPLEX | 15 | shame, guilt, envy, pride, nostalgia... |
**total: 100 anchors**
each anchor gets a resonance score. the resonance vector is the "fingerprint" of the input's emotional content.
---
## training
the `training/` folder contains:
- `bootstrap_data.json` โ€” synthetic emotion โ†’ label pairs
- `generate_bootstrap.py` โ€” generate training data
- `train_cloud.py` โ€” train chamber MLPs
- `train_observer.py` โ€” train meta-observer
```bash
cd cloud/training
python generate_bootstrap.py # generate data
python train_cloud.py # train chambers
python train_observer.py # train observer
```
trained weights are saved to `cloud/models/`.
---
## integration with HAZE
CLOUD and HAZE are **completely autonomous**. neither depends on the other.
```
CLOUD (pre-semantic sonar) HAZE (voice generation)
โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ””โ”€โ”€โ”€โ–บโ”‚ BRIDGE โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ (optional) โ”‚
โ”‚ silent fallbackโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
unified response
```
if CLOUD fails โ†’ HAZE continues silently. no errors. no warnings. just graceful degradation.
if HAZE fails โ†’ well, then you have a problem. HAZE is the voice. CLOUD is just the vibe check.
---
## philosophy
### why separate from HAZE?
1. **different timescales** โ€” emotion detection is fast (~ms). text generation is slow (~s).
2. **different architectures** โ€” CLOUD is MLPs. HAZE is attention + co-occurrence.
3. **different training** โ€” CLOUD trains on emotion labels. HAZE trains on corpus statistics.
4. **independence** โ€” if one breaks, the other still works.
### why so small?
50K params is enough to detect emotion. you don't need 175B params to know that "I'M TERRIFIED" contains fear. that's overkill. that's using a nuclear reactor to toast bread.
CLOUD is a matchstick. HAZE is the bonfire. different tools, different purposes.
### why "pre-semantic"?
because emotion isn't semantic. emotion is **substrate**. it's the thing that meaning floats on. you can know what someone said without knowing how they *feel* about it. CLOUD bridges that gap.
---
## crazy ideas (ๆœชๆฅใฎๆ–นๅ‘)
### resonance feedback loop
CLOUD's output could influence HAZE's temperature. high anxiety โ†’ lower temp (more focused). high void โ†’ higher temp (more exploration).
### multi-turn emotion tracking
build emotional arcs across conversation. "they started scared, then got angry, now they're numb" โ€” character development in real-time.
### cross-fire as attention
what if the coupling matrix was learnable? what if chambers could develop their own relationships? evolutionary attention.
### emotion injection
instead of just detecting emotion, **inject** it. "generate a response AS IF you feel fear". method acting for language models.
### dual-cloud architecture
one CLOUD for user emotion, one for HAZE emotion. emotional dialogue between two tiny minds. they could disagree. they could resonate. they could fight.
---
## file structure
```
cloud/
โ”œโ”€โ”€ README.md # you are here (hi!)
โ”œโ”€โ”€ __init__.py # package exports (async + sync)
โ”œโ”€โ”€ cloud.py # main orchestrator (Cloud, AsyncCloud)
โ”œโ”€โ”€ chambers.py # 6 chamber MLPs + cross-fire (~140K params)
โ”œโ”€โ”€ observer.py # meta-observer MLP (~41K params)
โ”œโ”€โ”€ resonance.py # weightless resonance layer
โ”œโ”€โ”€ user_cloud.py # temporal emotional fingerprint
โ”œโ”€โ”€ anchors.py # 100 emotion anchors + 6x6 coupling matrix
โ”œโ”€โ”€ anomaly.py # heuristic anomaly detection
โ”œโ”€โ”€ feedback.py # coherence measurement + coupling update
โ”œโ”€โ”€ rrpram_cloud.py # autonomous copy of RRPRAM tokenizer
โ”œโ”€โ”€ cooccur_cloud.py # autonomous copy of co-occurrence field
โ”œโ”€โ”€ requirements.txt # numpy + sentencepiece
โ”œโ”€โ”€ models/ # trained weights
โ”‚ โ”œโ”€โ”€ chamber_fear.npz
โ”‚ โ”œโ”€โ”€ chamber_love.npz
โ”‚ โ”œโ”€โ”€ chamber_rage.npz
โ”‚ โ”œโ”€โ”€ chamber_void.npz
โ”‚ โ”œโ”€โ”€ chamber_flow.npz # new in v4.0
โ”‚ โ”œโ”€โ”€ chamber_complex.npz # new in v4.0
โ”‚ โ”œโ”€โ”€ observer.npz
โ”‚ โ””โ”€โ”€ user_cloud.json
โ””โ”€โ”€ training/ # training scripts
โ”œโ”€โ”€ bootstrap_data.json
โ”œโ”€โ”€ generate_bootstrap.py
โ”œโ”€โ”€ train_cloud.py
โ””โ”€โ”€ train_observer.py
```
---
## tests
```bash
cd cloud
python -m pytest tests/ -v
```
or just run the modules directly:
```bash
python chambers.py # test cross-fire
python observer.py # test meta-observer
python resonance.py # test resonance layer
python cloud.py # test full pipeline
```
---
## contributing
found a bug? new chamber idea? crazy theory about emotion dynamics?
open an issue. or a PR. or just yell into the void (the VOID chamber will detect it).
---
## license
GPL-3.0 โ€” same as HAZE, same as the method.
---
## acknowledgments
- [karpathy](https://github.com/karpathy) for making neural nets feel like poetry
- evolutionary psychology for the chamber design (thanks, ancestors)
- that one paper about emotional valence-arousal spaces
- coffee, chaos, and 3am debugging sessions
- everyone who asked "but can AI feel?" and didn't accept "no"
---
## final thoughts
CLOUD doesn't understand emotions. it doesn't feel them. it's 50K floating point numbers doing multiplication.
but here's the thing: **neither does your amygdala**. it's just neurons firing. patterns activating patterns. and somehow, from that electrochemical chaos, feelings emerge.
CLOUD is the same. patterns activating patterns. and if you squint hard enough, you might see something that looks like understanding.
or maybe it's just matrix multiplication.
*the cloud doesn't care. it just detects.*
---
*"something fires before meaning arrives"*
[github.com/ariannamethod/haze/cloud](https://github.com/ariannamethod/haze)