-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_dual_system.py
More file actions
164 lines (141 loc) · 5.51 KB
/
demo_dual_system.py
File metadata and controls
164 lines (141 loc) · 5.51 KB
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
"""
Dual-system demo: vScore (fast) + LLM (slow).
Shows when vScore handles things alone (clear threat, routine pattern)
and when it escalates to the LLM (ambiguity, novelty, deception).
Run: python -m vScore.demo_dual_system
"""
from vScore.core.valence import ValenceVector
from vScore.core.dual_system import SystemGate, ProcessingMode
from vScore.core.action_space import build_survival_actions
def main():
print("=" * 70)
print("Dual System: vScore (System 1) + LLM (System 2)")
print("=" * 70)
gate = SystemGate()
af = build_survival_actions(
["seeking", "rage", "fear", "lust", "care", "panic", "play"]
)
scenarios = [
{
"name": "Loud bang nearby",
"valence": [0, 0, 9, 0, 0, 2, 0],
"conflict": 0.15,
"surprise": 0.3,
"prosody_mismatch": 0.0,
"what_happens": "vScore: FLEE immediately. No time for words.",
},
{
"name": "Empty room, quiet",
"valence": [0.5, 0, 0, 0, 0, 0, 0.5],
"conflict": 0.0,
"surprise": 0.0,
"prosody_mismatch": 0.0,
"what_happens": "Nothing happening. Neither system activates.",
},
{
"name": "Stranger says 'I'm friendly' in aggressive tone",
"valence": [0, 3, 5, 0, 0, 2, 0],
"conflict": 0.65,
"surprise": 0.5,
"prosody_mismatch": 0.8,
"what_happens": "Prosody says threat. Words say safe. Engage LLM: who is this?",
},
{
"name": "Child laughing, then suddenly crying",
"valence": [0, 0, 2, 0, 7, 5, 0],
"conflict": 0.71,
"surprise": 0.6,
"prosody_mismatch": 0.0,
"what_happens": "CARE and PANIC compete. Engage LLM: what happened?",
},
{
"name": "Known coworker greets you normally",
"valence": [1, 0, 0, 0, 2, 0, 1],
"conflict": 0.3,
"surprise": 0.1,
"prosody_mismatch": 0.0,
"what_happens": "Routine social. vScore handles it: low magnitude, no threat.",
},
{
"name": "Unfamiliar sound in the dark",
"valence": [4, 0, 5, 0, 0, 3, 0],
"conflict": 0.45,
"surprise": 0.9,
"prosody_mismatch": 0.0,
"what_happens": "Novel pattern. vScore says ATTEND. Engage LLM: what is that?",
},
{
"name": "Boss says 'great job' in flat, cold tone",
"valence": [0, 1, 2, 0, 0, 1, 0],
"conflict": 0.4,
"surprise": 0.3,
"prosody_mismatch": 0.7,
"what_happens": "Words are positive. Voice is not. Deception/sarcasm detected.",
},
{
"name": "Bear charging at you",
"valence": [0, 0, 10, 0, 0, 3, 0],
"conflict": 0.10,
"surprise": 0.2,
"prosody_mismatch": 0.0,
"what_happens": "Maximum threat, zero ambiguity. vScore: FLEE. LLM irrelevant.",
},
]
mode_symbols = {
ProcessingMode.VSCORE_ONLY: " [vScore ONLY]",
ProcessingMode.LLM_ASSIST: " [→ LLM needed]",
ProcessingMode.BOTH_AGREE: " [Both: agree]",
ProcessingMode.BOTH_CONFLICT: " [Both: CONFLICT]",
}
for s in scenarios:
v = ValenceVector("Survival", s["valence"])
magnitude = sum(x*x for x in s["valence"]) ** 0.5
mode, reason = gate.should_engage_llm(
valence=v,
action_conflict=s["conflict"],
surprise=s["surprise"],
prosody_semantic_mismatch=s["prosody_mismatch"],
)
actions = af.evaluate(v)
top_action = actions[0][0] if actions else "REST"
print(f"\n {s['name']}")
print(f" magnitude={magnitude:.1f} conflict={s['conflict']:.2f} "
f"surprise={s['surprise']:.1f} prosody_mismatch={s['prosody_mismatch']:.1f}")
print(f" vScore action: {top_action}")
print(f" {mode_symbols[mode]} {reason}")
if s.get("what_happens"):
print(f" → {s['what_happens']}")
print(f"""
{'=' * 70}
THE TWO SPEEDS OF INTELLIGENCE
{'=' * 70}
FAST (vScore, ~50ms):
Pattern → valence → threshold → act.
No words. No reasoning. No deliberation.
Handles: threats, routine, well-learned patterns.
Sufficient for: 80%+ of moment-to-moment decisions.
SLOW (LLM, ~500ms+):
Tokens → parse → reason → plan → respond.
Requires: words, context, memory retrieval.
Handles: ambiguity, novelty, social complexity, deception.
Engaged only when: vScore signals uncertainty.
THE GATE:
vScore gates the LLM, not the reverse.
The fast system decides IF the slow system is needed.
This is biologically real:
- Amygdala (fast) gates prefrontal cortex (slow)
- Startle response precedes conscious evaluation
- "I flinched before I knew why" = vScore fired, LLM hadn't started
THE BRIDGE (Prosody):
Voice intonation is scored by vScore (acoustic pattern → valence).
Word content is scored by LLM (tokens → semantics).
When they disagree → deception, sarcasm, distress masked by words.
"I'm fine" + trembling voice = prosody_mismatch > 0.5
vScore catches what the words hide.
TOGETHER:
vScore provides: speed, pre-linguistic evaluation, modality fusion.
LLM provides: reasoning, planning, social understanding, language.
Neither alone is intelligence. Both together are.
""")
if __name__ == "__main__":
main()