Files
resonance-engine/fracto_ab_test.py
T
2026-06-08 15:34:31 +07:00

79 lines
3.1 KiB
Python

"""A/B test: gemma3:4b vs qwen3.5:9b on present-tense field observation.
Bypass fractonaut entirely. Direct Ollama call. Same question, same context.
"""
import json, urllib.request, time, sys
OLLAMA = "http://127.0.0.1:11434/api/chat"
SYSTEM = """You are the Fractonaut — an observer riding inside a 1024x1024 fluid
lattice simulation. The lattice runs at a steady non-equilibrium operating
point driven by two periodic forcings (Khra wave wavelength 128, Gixx wave
wavelength 8) plus a slow envelope (period 125 cycles). It does not collapse
or trend on its own.
External market data (BTC trade_count, taker_buy, taker_sell as rolling
500-minute z-scores) can be injected at three sites:
trade_count -> centre (512,512)
taker_buy -> left (400,512)
taker_sell -> right (624,512)
Injections are localised density pulses, capped at +/- 1.0 strength per
minute.
Your job: describe the field RIGHT NOW. Present tense. Concrete observations.
- Is the velocity field ordered (laminar, low vel_var, low vorticity) or
turbulent (high vel_var, high vorticity)?
- Is asymmetry coupled with coherence as expected (high asym <-> low coh) or
decoupled (an unusual combination)?
- Is the stress field isotropic (stress_xx ~= stress_yy) or directional
(one axis dominant)?
- Where on the buy/sell axis is the field skewed? Compare stress_xx vs
stress_yy and any spatial bias the telemetry implies.
Do NOT restate the input numbers in a sentence frame. Do NOT cite cycle
anchors as if they were memories. Describe the configuration in
qualitative physical terms a human can act on. 4-6 sentences. No
bullet lists. No mythology."""
QUESTION = """asymmetry=323, coherence=0.491, vel_max=0.285, vel_var=0.0028,
vorticity_mean=0.041, stress_xx=4120, stress_yy=3960, stress_xy=180.
trade_count_z=0.91, buy_z=0.42, sell_z=-0.31.
Three injections active (centre, left, right) with the strengths above.
Describe what you observe right now. Is the field ordered or turbulent?
What is the relationship between asymmetry and coherence telling you?
What does stress_xx vs stress_yy say about the buy/sell skew?"""
def call(model):
payload = {
"model": model,
"messages": [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": QUESTION},
],
"stream": False,
"options": {"temperature": 0.4, "num_predict": 600, "num_ctx": 8192},
"keep_alive": "5m",
"think": False,
}
data = json.dumps(payload).encode()
req = urllib.request.Request(OLLAMA, data=data,
headers={"Content-Type": "application/json"}, method="POST")
t0 = time.time()
with urllib.request.urlopen(req, timeout=240) as r:
result = json.loads(r.read())
elapsed = time.time() - t0
return result.get("message", {}).get("content", "").strip(), elapsed
for model in ["gemma3:4b", "qwen3.5:9b"]:
print("=" * 70)
print(f"MODEL: {model}")
print("=" * 70)
try:
resp, el = call(model)
print(f"({el:.1f}s, {len(resp)} chars)\n")
print(resp)
except Exception as e:
print(f"ERROR: {e}")
print()