File size: 1,419 Bytes
4a0f6a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b6f412
4a0f6a5
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Batch runner for the cross-domain benchmark datasets."""
from __future__ import annotations

import subprocess
import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve()
while REPO_ROOT != REPO_ROOT.parent and not (REPO_ROOT / "src").exists():
    REPO_ROOT = REPO_ROOT.parent

SCRIPT_ROOT = REPO_ROOT / "scripts" / "inference"
DATASETS = [
    "DS06_External_core_balanced_v1",
    "DS07_External_long_v1",
]


def run(command: list[str]) -> None:
    print(">>>", " ".join(command))
    subprocess.run(command, cwd=REPO_ROOT, check=True)


def main() -> None:
    infer_qwen = SCRIPT_ROOT / "infer_qwen_adapters.py"
    infer_plm = SCRIPT_ROOT / "infer_bert_roberta.py"
    zero_shot = SCRIPT_ROOT / "run_zero_shot_detectors.py"
    cross_domain = SCRIPT_ROOT / "run_cross_domain_ensemble.py"

    for dataset in DATASETS:
        print("=" * 80)
        print(f"dataset: {dataset}")
        print("=" * 80)
        run([sys.executable, str(infer_qwen), "--dataset", dataset])
        run([sys.executable, str(infer_plm), "--dataset", dataset])
        run([sys.executable, str(zero_shot), "--dataset", dataset])
        run([
            sys.executable,
            str(cross_domain),
            "--dataset",
            dataset,
            "--fallback-dataset",
            "DS06_External_core_balanced_v1",
            "--force-fallback",
        ])


if __name__ == "__main__":
    main()