Spaces:
Running
Running
Sibam commited on
Commit ·
c3314b1
1
Parent(s): 350b447
feat: add primary descriptive headline and ensure entirely emoji-free UI
Browse files38 unmodified lines394041424344454647484911 unmodified lines6162636465666718 unmodified lines8687888990919233 unmodified lines12612712812913013113213313413513613713813938 unmodified linesimport gradio as grwith gr.Blocks() as blocks:gr.Markdown("## Agent Learning Dashboard")gr.Markdown("This dashboard transforms the basic interface into an intelligent view of the RLHF agent's decision-making process. ""You can observe reward signals, evaluation rationale, and training progression.")with gr.Row():with gr.Column(scale=2):reward_plot = gr.LinePlot(11 unmodified linesimprovement_tip = gr.Textbox(label="Agent Suggestion", lines=2)with gr.Column(scale=1):refresh_btn = gr.Button("Sync Agent State", variant="primary")agent_thinking = gr.Markdown("### Agent Process:\n"18 unmodified lines# Always ensure graph shows at least one pointif not data:df = pd.DataFrame({"Step": [0], "Reward": [0.0]})return df, "Awaiting first agent action...", "Waiting...", "Dataset: <b>Pending</b>", "### Episode Summary\n_No steps yet._"df = pd.DataFrame(data)latest_reward = data[-1]["Reward"]33 unmodified linesf"- **Improvement:** {improvement:+.1f}%\n"f"- **Steps:** {latest_step}")return df, exp, tip, f"Dataset: <b>{dataset_str.upper()}</b>", summary# Manual safe refresh mappingrefresh_btn.click(fn=update_dashboard,inputs=None,outputs=[reward_plot, reward_explanation, improvement_tip, dataset_vis, session_summary])return blocks38 unmodified lines394041424344454647484950515253545511 unmodified lines67686970717273747518 unmodified lines94959697989910033 unmodified lines13413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021138 unmodified linesimport gradio as grwith gr.Blocks() as blocks:gr.Markdown("## Agent Learning Dashboard")gr.Markdown("**This system simulates how RLHF agents learn from human feedback in real time.**")gr.Markdown("This dashboard transforms the basic interface into an intelligent view of the RLHF agent's decision-making process. ""You can observe reward signals, evaluation rationale, and training progression.")with gr.Row():best_reward_disp = gr.Markdown("### Best Reward: --")reward_delta_disp = gr.Markdown("### Recent Delta: --")confidence_disp = gr.Markdown("### Confidence: --")with gr.Row():with gr.Column(scale=2):reward_plot = gr.LinePlot(11 unmodified linesimprovement_tip = gr.Textbox(label="Agent Suggestion", lines=2)with gr.Column(scale=1):with gr.Row():refresh_btn = gr.Button("Sync Agent State", variant="primary")demo_btn = gr.Button("Run Guided Demo", variant="secondary")agent_thinking = gr.Markdown("### Agent Process:\n"18 unmodified lines# Always ensure graph shows at least one pointif not data:df = pd.DataFrame({"Step": [0], "Reward": [0.0]})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: --"df = pd.DataFrame(data)latest_reward = data[-1]["Reward"]33 unmodified linesf"- **Improvement:** {improvement:+.1f}%\n"f"- **Steps:** {latest_step}")# Dynamic Agent Thinking Enginetask_type = getattr(last_log.observation, "task_type", "unknown") if hasattr(last_log, "observation") else "unknown"thinking = f"### Agent Process (Step {latest_step}):\n"thinking += f"- Received `{task_type}` observation\n"if task_type == "pairwise":thinking += "- Compared Response A and B against Gold Standard\n"elif task_type == "likert":thinking += "- Evaluated response on 4 heuristic axes (Helpfulness, Honesty, etc)\n"elif task_type == "consistency":thinking += "- Checked consistency rankings for transitivity faults\n"else:thinking += "- Parsing standard input features\n"if latest_reward > 0.8:thinking += "- Decision matched gold labels almost perfectly\n"thinking += "- Issuing high positive reinforcement"elif latest_reward > 0.5:thinking += "- Decision showed partial alignment\n"thinking += "- Issuing moderate reinforcement"else:thinking += "- Decision strongly contradicted gold labels\n"thinking += "- Issuing negative reinforcement penalty"# KPI Visualizationsbest_reward = max([d["Reward"] for d in data])if len(data) > 1:delta = latest_reward - data[-2]["Reward"]delta_str = f"+{delta:.2f}" if delta >= 0 else f"{delta:.2f}"else:delta_str = "--"conf = 0.8if hasattr(last_log, "action") and last_log.action is not None:if hasattr(last_log.action, "confidence"):conf = last_log.action.confidenceelif isinstance(last_log.action, dict) and "confidence" in last_log.action:conf = last_log.action["confidence"]conf_str = f"{int(conf * 100)}%"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}"# Manual safe refresh mapping# Manual safe refresh mapping# Manual safe refresh mappingrefresh_btn.click(fn=update_dashboard,inputs=None,outputs=[reward_plot, reward_explanation, improvement_tip, agent_thinking, dataset_vis, session_summary, best_reward_disp, reward_delta_disp, confidence_disp])def run_demo_mode():import timeimport pandas as pd# Step 1df1 = pd.DataFrame([{"Step": 1, "Reward": 0.2}])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%"time.sleep(2)# Step 2df2 = pd.DataFrame([{"Step": 1, "Reward": 0.2}, {"Step": 2, "Reward": 0.55}])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%"time.sleep(2)# Step 3df3 = pd.DataFrame([{"Step": 1, "Reward": 0.2}, {"Step": 2, "Reward": 0.55}, {"Step": 3, "Reward": 0.99}])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%"demo_btn.click(fn=run_demo_mode,inputs=None,outputs=[reward_plot, reward_explanation, improvement_tip, agent_thinking, dataset_vis, session_summary, best_reward_disp, reward_delta_disp, confidence_disp])return blocks
server/app.py+76-4