sync ctt proxy feature mode code 2026-07-03
Browse files
workspace/scripts/eval_ctt_proxy.py
CHANGED
|
@@ -44,6 +44,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 44 |
thresholds = [float(item) for item in args.thresholds.split(",") if item.strip()]
|
| 45 |
checkpoint = torch.load(args.checkpoint, map_location="cpu")
|
| 46 |
config = CTTConfig(**checkpoint["config"])
|
|
|
|
| 47 |
encoder = ChartEncoder(config.chart_feature_dim, output_dim=config.chart_dim)
|
| 48 |
ctt = CausalTangentTransport(config)
|
| 49 |
encoder.load_state_dict(checkpoint["chart_encoder"])
|
|
@@ -52,14 +53,23 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 52 |
ctt.eval()
|
| 53 |
normalizer = TangentNormalizer.from_dict(checkpoint["normalizer"])
|
| 54 |
|
| 55 |
-
source_charts, source_index = load_charts(
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
_validate_indexes(args.source_index, source_index, args.target_index, target_index)
|
| 58 |
rows = []
|
| 59 |
log_lines = [
|
| 60 |
f"source_charts={len(source_charts)} target_charts={len(target_charts)} k={args.k}",
|
| 61 |
f"source_index={args.source_index}",
|
| 62 |
f"target_index={args.target_index}",
|
|
|
|
| 63 |
]
|
| 64 |
source_by_task: dict[str, list[Any]] = {}
|
| 65 |
for chart in source_charts:
|
|
@@ -141,6 +151,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 141 |
"data_hash": source_index.get("content_hash"),
|
| 142 |
"split_hash": source_index.get("split_hash"),
|
| 143 |
"target_split_hash": target_index.get("split_hash"),
|
|
|
|
| 144 |
}
|
| 145 |
(out_dir / "metrics.json").write_text(json.dumps(metrics, indent=2, sort_keys=True) + "\n")
|
| 146 |
(out_dir / "metrics_by_task.json").write_text(json.dumps(_by_task(rows, metric_names), indent=2, sort_keys=True) + "\n")
|
|
|
|
| 44 |
thresholds = [float(item) for item in args.thresholds.split(",") if item.strip()]
|
| 45 |
checkpoint = torch.load(args.checkpoint, map_location="cpu")
|
| 46 |
config = CTTConfig(**checkpoint["config"])
|
| 47 |
+
chart_feature_mode = str(checkpoint.get("chart_feature_mode", "base"))
|
| 48 |
encoder = ChartEncoder(config.chart_feature_dim, output_dim=config.chart_dim)
|
| 49 |
ctt = CausalTangentTransport(config)
|
| 50 |
encoder.load_state_dict(checkpoint["chart_encoder"])
|
|
|
|
| 53 |
ctt.eval()
|
| 54 |
normalizer = TangentNormalizer.from_dict(checkpoint["normalizer"])
|
| 55 |
|
| 56 |
+
source_charts, source_index = load_charts(
|
| 57 |
+
args.source_index,
|
| 58 |
+
max_charts=None,
|
| 59 |
+
chart_feature_mode=chart_feature_mode,
|
| 60 |
+
)
|
| 61 |
+
target_charts, target_index = load_charts(
|
| 62 |
+
args.target_index,
|
| 63 |
+
max_charts=args.max_target_charts,
|
| 64 |
+
chart_feature_mode=chart_feature_mode,
|
| 65 |
+
)
|
| 66 |
_validate_indexes(args.source_index, source_index, args.target_index, target_index)
|
| 67 |
rows = []
|
| 68 |
log_lines = [
|
| 69 |
f"source_charts={len(source_charts)} target_charts={len(target_charts)} k={args.k}",
|
| 70 |
f"source_index={args.source_index}",
|
| 71 |
f"target_index={args.target_index}",
|
| 72 |
+
f"chart_feature_mode={chart_feature_mode}",
|
| 73 |
]
|
| 74 |
source_by_task: dict[str, list[Any]] = {}
|
| 75 |
for chart in source_charts:
|
|
|
|
| 151 |
"data_hash": source_index.get("content_hash"),
|
| 152 |
"split_hash": source_index.get("split_hash"),
|
| 153 |
"target_split_hash": target_index.get("split_hash"),
|
| 154 |
+
"chart_feature_mode": chart_feature_mode,
|
| 155 |
}
|
| 156 |
(out_dir / "metrics.json").write_text(json.dumps(metrics, indent=2, sort_keys=True) + "\n")
|
| 157 |
(out_dir / "metrics_by_task.json").write_text(json.dumps(_by_task(rows, metric_names), indent=2, sort_keys=True) + "\n")
|