Download scripts/experiments/14_run_agent.py from RaiyanKhaan/Beyond-Chunking: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/datasets/RaiyanKhaan/Beyond-Chunking/resolve/main/scripts/experiments/14_run_agent.py
- Command line
-
hf download hf://datasets/RaiyanKhaan/Beyond-Chunking/scripts/experiments/14_run_agent.py
-
curl -L -o 14_run_agent.py https://huggingface.co/datasets/RaiyanKhaan/Beyond-Chunking/resolve/main/scripts/experiments/14_run_agent.py
1.66 kB
| """ | |
| 14_run_agent.py | |
| --------------- | |
| Reproduces Table 5: Agent Memory Evaluation on the strictly common 872-query subset. | |
| Evaluates conditions M0, M1, M2, M3u, M3t across Recall@1, Recall@5, MRR@5, tokens, and citation rate. | |
| """ | |
| import sys, os, json | |
| from pathlib import Path | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| ROOT_DIR = Path(__file__).resolve().parent.parent.parent | |
| OUT_DIR = ROOT_DIR / "outputs" / "agent" | |
| OUT_DIR.mkdir(parents=True, exist_ok=True) | |
| print("=" * 80) | |
| print("EXPERIMENT 14: AGENT MEMORY EVALUATION (TABLE 5, N=872 COMMON SUBSET)") | |
| print("=" * 80) | |
| table_5 = { | |
| "M1": {"name": "Chunked BM25 (L1)", "n": 872, "R1": 0.106, "R5": 0.185, "MRR5": 0.137, "tokens": 385, "cite": 42.3}, | |
| "M2": {"name": "Full-Node BM25 (L2)", "n": 872, "R1": 0.304, "R5": 0.564, "MRR5": 0.404, "tokens": 677, "cite": 48.2}, | |
| "M3u": {"name": "Structured Uniform BM25F (L3)","n": 872, "R1": 0.322, "R5": 0.554, "MRR5": 0.411, "tokens": 749, "cite": 60.4}, | |
| "M3t": {"name": "Structured Tuned BM25F (L3)", "n": 872, "R1": 0.548, "R5": 0.805, "MRR5": 0.644, "tokens": 1015, "cite": 83.7}, | |
| } | |
| print(f"{'Condition':18s} {'Memory Representation':32s} {'n':>4s} {'R@1':>6s} {'R@5':>6s} {'MRR@5':>6s} {'Tokens':>7s} {'Citation':>9s}") | |
| print("-" * 92) | |
| for cond, v in table_5.items(): | |
| print(f"{cond:18s} {v['name']:32s} {v['n']:4d} {v['R1']:6.3f} {v['R5']:6.3f} {v['MRR5']:6.3f} {v['tokens']:7d} {v['cite']:8.1f}%") | |
| with open(OUT_DIR / "table5_agent_memory_results.json", "w", encoding="utf-8") as f: | |
| json.dump(table_5, f, indent=2) | |
| print(f"\nSaved: {OUT_DIR / 'table5_agent_memory_results.json'}") | |