Spaces:
Sleeping
Sleeping
File size: 4,055 Bytes
c8fa89c b350371 a345062 eef89e3 b350371 c8fa89c a345062 c8fa89c a345062 c8fa89c eef89e3 c8fa89c a345062 c8fa89c a345062 c8fa89c a345062 c8fa89c a345062 eef89e3 a345062 eef89e3 a345062 c8fa89c a345062 c8fa89c a345062 b350371 a345062 b350371 a345062 b350371 a345062 c8fa89c a345062 b350371 a345062 c8fa89c b350371 c8fa89c b350371 a345062 b350371 c8fa89c a345062 b350371 a345062 b350371 a345062 |
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 |
import gradio as gr
import pandas as pd
import traceback
import sys
from cognitive_mapping_probe.orchestrator_seismograph import run_seismic_analysis
from cognitive_mapping_probe.prompts import RESONANCE_PROMPTS
from cognitive_mapping_probe.utils import dbg
# --- UI Theme and Layout ---
theme = gr.themes.Soft(primary_hue="indigo", secondary_hue="blue").set(
body_background_fill="#f0f4f9",
block_background_fill="white",
)
def run_and_display(
model_id: str,
prompt_type: str,
seed: int,
num_steps: int,
progress=gr.Progress(track_tqdm=True)
):
"""
Führt die neue seismische Analyse durch und visualisiert die internen Dynamiken.
"""
try:
results = run_seismic_analysis(
model_id, prompt_type, int(seed), int(num_steps), progress
)
verdict = results.get("verdict", "Analysis complete.")
stats = results.get("stats", {})
deltas = results.get("state_deltas", [])
# Erstelle einen DataFrame für den Plot
df = pd.DataFrame({
"Internal Step": range(len(deltas)),
"State Change (Delta)": deltas
})
# Erstelle eine Zusammenfassung der Statistiken
stats_md = f"### Statistical Signature\n"
stats_md += f"- **Mean Delta:** {stats.get('mean_delta', 0):.4f} (Avg. cognitive activity)\n"
stats_md += f"- **Std Dev Delta:** {stats.get('std_delta', 0):.4f} (Volatility of thought)\n"
stats_md += f"- **Max Delta:** {stats.get('max_delta', 0):.4f} (Peak cognitive shift)\n"
return f"{verdict}\n\n{stats_md}", df, results
except Exception:
error_str = traceback.format_exc()
return f"### ❌ Analysis Failed\nAn unexpected error occurred:\n\n```\n{error_str}\n```", pd.DataFrame(), {}
# --- Gradio App Definition ---
with gr.Blocks(theme=theme, title="Cognitive Seismograph") as demo:
gr.Markdown("# 🧠 Cognitive Seismograph: Visualizing Internal Dynamics")
gr.Markdown(
"**Neues Paradigma:** Wir akzeptieren, dass der 'stille Denkprozess' nicht konvergiert. Stattdessen messen und visualisieren wir die **Signatur der internen Dynamik** – ein EKG für den Denkprozess des Modells."
)
with gr.Row(variant='panel'):
with gr.Column(scale=1):
gr.Markdown("### Parameters")
model_id_input = gr.Textbox(value="google/gemma-3-1b-it", label="Model ID")
prompt_type_input = gr.Radio(
choices=list(RESONANCE_PROMPTS.keys()),
value="control_long_prose",
label="Prompt Type (Cognitive Load)"
)
seed_input = gr.Slider(1, 1000, 42, step=1, label="Seed")
num_steps_input = gr.Slider(50, 1000, 300, step=10, label="Number of Internal Steps")
run_btn = gr.Button("Run Seismic Analysis", variant="primary")
with gr.Column(scale=2):
gr.Markdown("### Results")
verdict_output = gr.Markdown("Die Analyse der Dynamik erscheint hier.")
plot_output = gr.LinePlot(
x="Internal Step",
y="State Change (Delta)",
title="Internal State Dynamics (Cognitive EKG)",
show_label=True,
height=400,
)
with gr.Accordion("Raw JSON Output", open=False):
raw_json_output = gr.JSON()
run_btn.click(
fn=run_and_display,
inputs=[model_id_input, prompt_type_input, seed_input, num_steps_input],
outputs=[verdict_output, plot_output, raw_json_output]
)
if __name__ == "__main__":
# Die Pre-Flight Checks sind nun entfernt, da das neue Paradigma keine Konvergenz mehr erfordert.
print("="*80)
print("🔬 COGNITIVE SEISMOGRAPH INITIALIZED")
print("="*80)
print("Das experimentelle Paradigma wurde aufgrund der Falsifikation der Konvergenz-Hypothese geändert.")
print("Wir messen nun die Dynamik des nicht-konvergenten Zustands.")
demo.launch(server_name="0.0.0.0", server_port=7860, debug=True)
|