Add tail threshold v2 code (numeric quantile tails, no concentration)
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#!/usr/bin/env python3"""Run the v2 tail-threshold experiment with numeric quantile ranges."""
from __future__ import annotations
import argparseimport jsonimport sysfrom pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT))
from src.eval.tail_threshold_v2.runner import DEFAULT_THRESHOLD_PCTS, run_tail_threshold_experiment_v2
def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description="Run tail-threshold v2 diagnostics.") parser.add_argument("--run-tag", type=str, default=None, help="Optional output run tag.") parser.add_argument("--datasets", type=str, default="", help="Optional comma-separated dataset ids. Empty means all datasets.") parser.add_argument( "--root-names", type=str, default="", help="Optional comma-separated synthetic root names. Example: TabQueryBench-SynDataSuccess-main", ) parser.add_argument( "--threshold-percentages", type=str, default=",".join(f"{value:g}" for value in DEFAULT_THRESHOLD_PCTS), help="Comma-separated tail thresholds in percentage points.", ) parser.add_argument("--all-asset-runs", action="store_true", help="Disable latest-only filtering within the same model/server.") parser.add_argument("--max-workers", type=int, default=4, help="Parallel workers across datasets.") parser.add_argument("--numeric-bins", type=int, default=10, help="Reserved for categorical-vs-numeric mode detection.") return parser.parse_args()
def _parse_threshold_percentages(text: str) -> list[float]: values: list[float] = [] for chunk in text.split(","): token = chunk.strip() if token: values.append(float(token)) return values
def main() -> None: args = parse_args() datasets = [item.strip() for item in args.datasets.split(",") if item.strip()] or None root_names = [item.strip() for item in args.root_names.split(",") if item.strip()] or None manifest = run_tail_threshold_experiment_v2( run_tag=args.run_tag, datasets=datasets, latest_only=not args.all_asset_runs, root_names=root_names, threshold_percentages=_parse_threshold_percentages(args.threshold_percentages), max_workers=max(1, args.max_workers), numeric_bins=max(2, args.numeric_bins), ) print(json.dumps(manifest, ensure_ascii=False, indent=2))
if __name__ == "__main__": main()evaluation/tail/tail_threshold_code_v2/scripts/run_tail_threshold_v2.pyAdded+66