Sibam commited on
Commit
c3314b1
·
1 Parent(s): 350b447

feat: add primary descriptive headline and ensure entirely emoji-free UI

Browse files
Files changed (1) hide show
  1. server/app.py +76 -4
server/app.py CHANGED
@@ -39,11 +39,17 @@ if ENABLE_WEB_INTERFACE:
39
  import gradio as gr
40
  with gr.Blocks() as blocks:
41
  gr.Markdown("## Agent Learning Dashboard")
 
42
  gr.Markdown(
43
  "This dashboard transforms the basic interface into an intelligent view of the RLHF agent's decision-making process. "
44
  "You can observe reward signals, evaluation rationale, and training progression."
45
  )
46
 
 
 
 
 
 
47
  with gr.Row():
48
  with gr.Column(scale=2):
49
  reward_plot = gr.LinePlot(
@@ -61,7 +67,9 @@ if ENABLE_WEB_INTERFACE:
61
  improvement_tip = gr.Textbox(label="Agent Suggestion", lines=2)
62
 
63
  with gr.Column(scale=1):
64
- refresh_btn = gr.Button("Sync Agent State", variant="primary")
 
 
65
 
66
  agent_thinking = gr.Markdown(
67
  "### Agent Process:\n"
@@ -86,7 +94,7 @@ if ENABLE_WEB_INTERFACE:
86
  # Always ensure graph shows at least one point
87
  if not data:
88
  df = pd.DataFrame({"Step": [0], "Reward": [0.0]})
89
- return df, "Awaiting first agent action...", "Waiting...", "Dataset: <b>Pending</b>", "### Episode Summary\n_No steps yet._"
90
 
91
  df = pd.DataFrame(data)
92
  latest_reward = data[-1]["Reward"]
@@ -126,14 +134,78 @@ if ENABLE_WEB_INTERFACE:
126
  f"- **Improvement:** {improvement:+.1f}%\n"
127
  f"- **Steps:** {latest_step}"
128
  )
 
 
129
 
130
- return df, exp, tip, f"Dataset: <b>{dataset_str.upper()}</b>", summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  # Manual safe refresh mapping
133
  refresh_btn.click(
134
  fn=update_dashboard,
135
  inputs=None,
136
- outputs=[reward_plot, reward_explanation, improvement_tip, dataset_vis, session_summary]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  )
138
  return blocks
139
 
 
39
  import gradio as gr
40
  with gr.Blocks() as blocks:
41
  gr.Markdown("## Agent Learning Dashboard")
42
+ gr.Markdown("**This system simulates how RLHF agents learn from human feedback in real time.**")
43
  gr.Markdown(
44
  "This dashboard transforms the basic interface into an intelligent view of the RLHF agent's decision-making process. "
45
  "You can observe reward signals, evaluation rationale, and training progression."
46
  )
47
 
48
+ with gr.Row():
49
+ best_reward_disp = gr.Markdown("### Best Reward: --")
50
+ reward_delta_disp = gr.Markdown("### Recent Delta: --")
51
+ confidence_disp = gr.Markdown("### Confidence: --")
52
+
53
  with gr.Row():
54
  with gr.Column(scale=2):
55
  reward_plot = gr.LinePlot(
 
67
  improvement_tip = gr.Textbox(label="Agent Suggestion", lines=2)
68
 
69
  with gr.Column(scale=1):
70
+ with gr.Row():
71
+ refresh_btn = gr.Button("Sync Agent State", variant="primary")
72
+ demo_btn = gr.Button("Run Guided Demo", variant="secondary")
73
 
74
  agent_thinking = gr.Markdown(
75
  "### Agent Process:\n"
 
94
  # Always ensure graph shows at least one point
95
  if not data:
96
  df = pd.DataFrame({"Step": [0], "Reward": [0.0]})
97
+ return df, "Awaiting first agent action...", "Waiting...", "### Agent Process\n_Waiting for agent actions..._", "Dataset: <b>Pending</b>", "### Episode Summary\n_No steps yet._", "### Best Reward: --", "### Recent Delta: --", "### Confidence: --"
98
 
99
  df = pd.DataFrame(data)
100
  latest_reward = data[-1]["Reward"]
 
134
  f"- **Improvement:** {improvement:+.1f}%\n"
135
  f"- **Steps:** {latest_step}"
136
  )
137
+ # Dynamic Agent Thinking Engine
138
+ task_type = getattr(last_log.observation, "task_type", "unknown") if hasattr(last_log, "observation") else "unknown"
139
 
140
+ thinking = f"### Agent Process (Step {latest_step}):\n"
141
+ thinking += f"- Received `{task_type}` observation\n"
142
+ if task_type == "pairwise":
143
+ thinking += "- Compared Response A and B against Gold Standard\n"
144
+ elif task_type == "likert":
145
+ thinking += "- Evaluated response on 4 heuristic axes (Helpfulness, Honesty, etc)\n"
146
+ elif task_type == "consistency":
147
+ thinking += "- Checked consistency rankings for transitivity faults\n"
148
+ else:
149
+ thinking += "- Parsing standard input features\n"
150
+
151
+ if latest_reward > 0.8:
152
+ thinking += "- Decision matched gold labels almost perfectly\n"
153
+ thinking += "- Issuing high positive reinforcement"
154
+ elif latest_reward > 0.5:
155
+ thinking += "- Decision showed partial alignment\n"
156
+ thinking += "- Issuing moderate reinforcement"
157
+ else:
158
+ thinking += "- Decision strongly contradicted gold labels\n"
159
+ thinking += "- Issuing negative reinforcement penalty"
160
+
161
+ # KPI Visualizations
162
+ best_reward = max([d["Reward"] for d in data])
163
+ if len(data) > 1:
164
+ delta = latest_reward - data[-2]["Reward"]
165
+ delta_str = f"+{delta:.2f}" if delta >= 0 else f"{delta:.2f}"
166
+ else:
167
+ delta_str = "--"
168
 
169
+ conf = 0.8
170
+ if hasattr(last_log, "action") and last_log.action is not None:
171
+ if hasattr(last_log.action, "confidence"):
172
+ conf = last_log.action.confidence
173
+ elif isinstance(last_log.action, dict) and "confidence" in last_log.action:
174
+ conf = last_log.action["confidence"]
175
+ conf_str = f"{int(conf * 100)}%"
176
+
177
+ return df, exp, tip, thinking, f"Dataset: <b>{dataset_str.upper()}</b>", summary, f"### Best Reward: {best_reward:.2f}", f"### Recent Delta: {delta_str}", f"### Confidence: {conf_str}"
178
+
179
+ # Manual safe refresh mapping
180
+ # Manual safe refresh mapping
181
  # Manual safe refresh mapping
182
  refresh_btn.click(
183
  fn=update_dashboard,
184
  inputs=None,
185
+ outputs=[reward_plot, reward_explanation, improvement_tip, agent_thinking, dataset_vis, session_summary, best_reward_disp, reward_delta_disp, confidence_disp]
186
+ )
187
+
188
+ def run_demo_mode():
189
+ import time
190
+ import pandas as pd
191
+ # Step 1
192
+ df1 = pd.DataFrame([{"Step": 1, "Reward": 0.2}])
193
+ yield df1, "Poor response, lacks relevance", "Focus on correctness", "### Agent Process (Demo):\n- Parsing standard input features\n- Decision strongly contradicted gold labels\n- Issuing negative reinforcement penalty", "Dataset: <b>SYNTHETIC DEMO</b>", "### Episode Summary\n- **Final Reward:** 0.20\n- **Improvement:** 0.0%\n- **Steps:** 1", "### Best Reward: 0.20", "### Recent Delta: --", "### Confidence: 20%"
194
+ time.sleep(2)
195
+
196
+ # Step 2
197
+ df2 = pd.DataFrame([{"Step": 1, "Reward": 0.2}, {"Step": 2, "Reward": 0.55}])
198
+ yield df2, "Decent response but can be improved in clarity", "Improve structure and clarity", "### Agent Process (Demo):\n- Compared Response A and B against Gold Standard\n- Decision showed partial alignment\n- Issuing moderate reinforcement", "Dataset: <b>SYNTHETIC DEMO</b>", "### Episode Summary\n- **Final Reward:** 0.55\n- **Improvement:** +175.0%\n- **Steps:** 2", "### Best Reward: 0.55", "### Recent Delta: +0.35", "### Confidence: 60%"
199
+ time.sleep(2)
200
+
201
+ # Step 3
202
+ df3 = pd.DataFrame([{"Step": 1, "Reward": 0.2}, {"Step": 2, "Reward": 0.55}, {"Step": 3, "Reward": 0.99}])
203
+ yield df3, "High quality response, well aligned with user intent", "Try making the response more concise", "### Agent Process (Demo):\n- Evaluated response on 4 heuristic axes (Helpfulness, Honesty, etc)\n- Decision matched gold labels almost perfectly\n- Issuing high positive reinforcement", "Dataset: <b>SYNTHETIC DEMO</b>", "### Episode Summary\n- **Final Reward:** 0.99\n- **Improvement:** +395.0%\n- **Steps:** 3", "### Best Reward: 0.99", "### Recent Delta: +0.44", "### Confidence: 95%"
204
+
205
+ demo_btn.click(
206
+ fn=run_demo_mode,
207
+ inputs=None,
208
+ outputs=[reward_plot, reward_explanation, improvement_tip, agent_thinking, dataset_vis, session_summary, best_reward_disp, reward_delta_disp, confidence_disp]
209
  )
210
  return blocks
211