Commit
·
0169c26
1
Parent(s):
82f1e62
Add atoms.
Browse files
app.py
CHANGED
|
@@ -459,15 +459,49 @@ ATOMS_COMMENTARY = (
|
|
| 459 |
# -------------------------
|
| 460 |
# Static Gradio UI
|
| 461 |
# -------------------------
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
gr.Markdown(
|
| 465 |
-
|
| 466 |
-
gr.
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
|
| 472 |
if __name__ == "__main__":
|
| 473 |
demo.launch()
|
|
|
|
| 459 |
# -------------------------
|
| 460 |
# Static Gradio UI
|
| 461 |
# -------------------------
|
| 462 |
+
# --- Static Gradio UI with Tabs ---
|
| 463 |
+
with gr.Blocks(title="PSL Minimal-Circuit • Static") as demo:
|
| 464 |
+
gr.Markdown("## PSL Minimal-Circuit • Static Overview")
|
| 465 |
+
|
| 466 |
+
with gr.Tabs():
|
| 467 |
+
with gr.Tab("Rules & Model"):
|
| 468 |
+
gr.Markdown(f"**JVM status:**\n\n{JVM_STATUS}")
|
| 469 |
+
gr.Markdown(COMMENTARY_MD)
|
| 470 |
+
gr.Image(value=GRAPH_PATH, label="Rule Graph (green = positive head, red dashed = negated head)")
|
| 471 |
+
gr.Markdown(MODEL_SUMMARY_MD)
|
| 472 |
+
|
| 473 |
+
with gr.Tab("Atoms"):
|
| 474 |
+
ATOMS_COMMENTARY = (
|
| 475 |
+
"### Facts/Atoms Overview\n"
|
| 476 |
+
"- **Observations** are known inputs (fixed evidence).\n"
|
| 477 |
+
"- **Targets** are latent atoms the model will **infer** "
|
| 478 |
+
"(e.g., whether `C1`, `C2`, `C3` are `Minimal`).\n"
|
| 479 |
+
"- **Truth** (if provided) is held-out gold used to **evaluate** performance; "
|
| 480 |
+
"it is not used during inference.\n"
|
| 481 |
+
"_Note: the same ground atom must not appear in both Observations and Targets._"
|
| 482 |
+
)
|
| 483 |
+
gr.Markdown(ATOMS_COMMENTARY)
|
| 484 |
+
|
| 485 |
+
# compact counts table: rows=predicate, cols=Observations/Targets/Truth
|
| 486 |
+
def _atoms_summary_table(atoms=ATOMS):
|
| 487 |
+
rows = []
|
| 488 |
+
for pname, parts in atoms.items():
|
| 489 |
+
obs = len(parts.get("OBS", pd.DataFrame()))
|
| 490 |
+
tgt = len(parts.get("TARGETS", pd.DataFrame()))
|
| 491 |
+
tru = len(parts.get("TRUTH", pd.DataFrame()))
|
| 492 |
+
rows.append({
|
| 493 |
+
"Predicate": pname,
|
| 494 |
+
"Observations": obs,
|
| 495 |
+
"Targets": tgt,
|
| 496 |
+
"Truth": tru
|
| 497 |
+
})
|
| 498 |
+
return pd.DataFrame(rows).sort_values("Predicate").reset_index(drop=True)
|
| 499 |
+
|
| 500 |
+
gr.Dataframe(
|
| 501 |
+
value=_atoms_summary_table(ATOMS),
|
| 502 |
+
label="Atoms Summary (counts)",
|
| 503 |
+
interactive=False
|
| 504 |
+
)
|
| 505 |
|
| 506 |
if __name__ == "__main__":
|
| 507 |
demo.launch()
|