llm-forensic-timeline 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hudan Studiawan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-forensic-timeline
3
+ Version: 0.0.2
4
+ Summary: Standardized methodology and dataset for evaluating LLM-based digital forensic timeline analysis
5
+ Author: Hudan Studiawan, Frank Breitinger, Mark Scanlon
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Hudan Studiawan
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/studiawan/llm-forensic-timeline
29
+ Project-URL: Repository, https://github.com/studiawan/llm-forensic-timeline
30
+ Project-URL: Issues, https://github.com/studiawan/llm-forensic-timeline/issues
31
+ Project-URL: Documentation, https://llm-forensic-timeline.readthedocs.io
32
+ Project-URL: Dataset, https://zenodo.org/records/15493424
33
+ Project-URL: Paper, https://doi.org/10.1016/j.fsidi.2025.301982
34
+ Keywords: forensics,timeline,llm,evaluation,bleu,rouge,bertscore,plaso
35
+ Classifier: Development Status :: 3 - Alpha
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: Intended Audience :: Information Technology
38
+ Classifier: Intended Audience :: Science/Research
39
+ Classifier: License :: OSI Approved :: MIT License
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Programming Language :: Python :: 3 :: Only
42
+ Classifier: Programming Language :: Python :: 3.10
43
+ Classifier: Programming Language :: Python :: 3.11
44
+ Classifier: Programming Language :: Python :: 3.12
45
+ Classifier: Programming Language :: Python :: 3.13
46
+ Classifier: Topic :: Security
47
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
48
+ Requires-Python: >=3.10
49
+ Description-Content-Type: text/markdown
50
+ License-File: LICENSE
51
+ Requires-Dist: evaluate
52
+ Requires-Dist: rouge_score
53
+ Requires-Dist: absl-py
54
+ Requires-Dist: nltk
55
+ Provides-Extra: bertscore
56
+ Requires-Dist: modern-bert-score; python_version >= "3.12" and extra == "bertscore"
57
+ Provides-Extra: llm
58
+ Requires-Dist: openai; extra == "llm"
59
+ Requires-Dist: python-dotenv; extra == "llm"
60
+ Provides-Extra: all
61
+ Requires-Dist: llm-forensic-timeline[bertscore,llm]; extra == "all"
62
+ Provides-Extra: test
63
+ Requires-Dist: pytest; extra == "test"
64
+ Provides-Extra: docs
65
+ Requires-Dist: sphinx; extra == "docs"
66
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
67
+ Dynamic: license-file
68
+
69
+ # llm-forensic-timeline
70
+
71
+ [![Tests](https://github.com/studiawan/llm-forensic-timeline/actions/workflows/test.yml/badge.svg)](https://github.com/studiawan/llm-forensic-timeline/actions/workflows/test.yml)
72
+ [![Documentation Status](https://readthedocs.org/projects/llm-forensic-timeline/badge/?version=latest)](https://llm-forensic-timeline.readthedocs.io/en/latest/)
73
+ [![PyPI](https://img.shields.io/pypi/v/llm-forensic-timeline.svg)](https://pypi.org/project/llm-forensic-timeline/)
74
+
75
+ A work in progress repository for DFRWS APAC 2025 paper: [A standardized methodology and dataset for evaluating LLM-based digital forensic timeline analysis](https://www.sciencedirect.com/science/article/pii/S2666281725001222).
76
+
77
+ The package covers the two halves of the methodology:
78
+
79
+ - **Run** — upload a log2timeline/Plaso CSV timeline to an LLM, replay the prompts of a task, and save every answer the model generates.
80
+ - **Evaluate** — score those answers against a manually validated ground truth with BLEU, ROUGE, and BERTScore, and write one CSV row per file.
81
+
82
+ Documentation: <https://llm-forensic-timeline.readthedocs.io>
83
+
84
+ # Requirements
85
+
86
+ 1. Create a virtual environment using `venv` (Python 3.10 or newer; BERTScore additionally needs 3.12+):
87
+
88
+ `python3.13 -m venv .venv`
89
+
90
+ 2. Activate the environment:
91
+
92
+ `source .venv/bin/activate` (Windows: `.venv\Scripts\activate`)
93
+
94
+ 3. Install the package:
95
+
96
+ `pip install -e ".[all]"`
97
+
98
+ Or, without cloning: `pip install llm-forensic-timeline[all]`
99
+
100
+ 4. Open dataset repository on [Zenodo](https://zenodo.org/records/15493424)
101
+
102
+ 5. Download `scenario-1.zip` and unzip it
103
+
104
+ 6. Copy all files from `scenario-1/timeline/events` directory to `dataset/event-summarization` directory
105
+
106
+ The extras split the optional halves: `bertscore` adds `modern-bert-score`, `llm` adds `openai` and `python-dotenv`, and `all` adds both. `requirements.txt` still holds the full environment used for the paper.
107
+
108
+ # How to run
109
+
110
+ 1. Add `.env` file in `src` directory. Add your OpenAI API keys in the `.env` file, something like: `OPENAI_API_KEY=sk-proj-xxx`
111
+
112
+ 2. Run the task
113
+
114
+ `llm-forensic-timeline run --task event-summarization`
115
+
116
+ The original script still works: `python src/run.py`
117
+
118
+ # How to evaluate
119
+
120
+ `llm-forensic-timeline evaluate` compares the LLM answers against the ground truth and writes the scores to a CSV file:
121
+
122
+ ```
123
+ llm-forensic-timeline evaluate \
124
+ --groundtruth-dir event-reconstruction/ground-truth-multiple \
125
+ --llm-dir event-reconstruction/chatgpt-with-knowledge-multiple \
126
+ --output event-reconstruction/chatgpt-with-knowledge-multiple-results.csv
127
+ ```
128
+
129
+ The original script still works: edit the `task` and `prediction` variables at the top of `src/evaluation-list.py`, then run it from the directory that contains the task directory.
130
+
131
+ Three metrics are reported per file:
132
+
133
+ 1. **BLEU** and **ROUGE** (ROUGE-1, ROUGE-2, ROUGE-L, ROUGE-Lsum) through the Hugging Face `evaluate` library. Both are n-gram overlap metrics, so they only measure lexical similarity.
134
+
135
+ 2. **BERTScore** through [`modern-bert-score`](https://pypi.org/project/modern-bert-score/), which is semantic-aware and therefore credits an answer that is worded differently but carries the same meaning. This addresses the limitation of BLEU and ROUGE discussed in Sec. 4.4.2 of the paper. The columns `bertscore_precision`, `bertscore_recall`, and `bertscore_f1` hold the mean over all entries of a file.
136
+
137
+ Notes on BERTScore:
138
+
139
+ - The model is `LazerLambda/ModernBERT-large-ModBERTScore-19`, the strongest checkpoint shipped with the package. It is the largest one, and its 8192-token context keeps long JSON entries of a forensic timeline intact, while the RoBERTa checkpoints truncate at 512 tokens. The weights (about 1.6 GB) are downloaded from Hugging Face on the first run and cached afterwards.
140
+ - Scores are rescaled with the baseline of the model, as recommended by the BERTScore authors. Without rescaling, scores of unrelated texts sit near 0.8; with rescaling, they sit near 0 and can be slightly negative, which makes the results easier to read.
141
+ - The script selects CUDA or Apple Silicon (MPS) automatically and falls back to the CPU. Evaluating a large timeline on the CPU is slow.
142
+ - Pass `--no-bertscore` to score with BLEU and ROUGE only, without loading a transformer model.
143
+
144
+ # Development
145
+
146
+ Run the test suite:
147
+
148
+ ```
149
+ pip install -e ".[test]"
150
+ pytest
151
+ ```
152
+
153
+ Build the documentation locally:
154
+
155
+ ```
156
+ pip install -r docs/requirements.txt
157
+ python -m sphinx -W -b html docs/source docs/_build/html
158
+ ```
159
+
160
+ The `Run Tests` workflow runs pytest on Python 3.10 through 3.13 and builds the documentation on every push and pull request to `main`. Pushing a `v*.*.*` tag builds the distributions and publishes them to PyPI through OIDC Trusted Publishing, without any stored credentials.
@@ -0,0 +1,92 @@
1
+ # llm-forensic-timeline
2
+
3
+ [![Tests](https://github.com/studiawan/llm-forensic-timeline/actions/workflows/test.yml/badge.svg)](https://github.com/studiawan/llm-forensic-timeline/actions/workflows/test.yml)
4
+ [![Documentation Status](https://readthedocs.org/projects/llm-forensic-timeline/badge/?version=latest)](https://llm-forensic-timeline.readthedocs.io/en/latest/)
5
+ [![PyPI](https://img.shields.io/pypi/v/llm-forensic-timeline.svg)](https://pypi.org/project/llm-forensic-timeline/)
6
+
7
+ A work in progress repository for DFRWS APAC 2025 paper: [A standardized methodology and dataset for evaluating LLM-based digital forensic timeline analysis](https://www.sciencedirect.com/science/article/pii/S2666281725001222).
8
+
9
+ The package covers the two halves of the methodology:
10
+
11
+ - **Run** — upload a log2timeline/Plaso CSV timeline to an LLM, replay the prompts of a task, and save every answer the model generates.
12
+ - **Evaluate** — score those answers against a manually validated ground truth with BLEU, ROUGE, and BERTScore, and write one CSV row per file.
13
+
14
+ Documentation: <https://llm-forensic-timeline.readthedocs.io>
15
+
16
+ # Requirements
17
+
18
+ 1. Create a virtual environment using `venv` (Python 3.10 or newer; BERTScore additionally needs 3.12+):
19
+
20
+ `python3.13 -m venv .venv`
21
+
22
+ 2. Activate the environment:
23
+
24
+ `source .venv/bin/activate` (Windows: `.venv\Scripts\activate`)
25
+
26
+ 3. Install the package:
27
+
28
+ `pip install -e ".[all]"`
29
+
30
+ Or, without cloning: `pip install llm-forensic-timeline[all]`
31
+
32
+ 4. Open dataset repository on [Zenodo](https://zenodo.org/records/15493424)
33
+
34
+ 5. Download `scenario-1.zip` and unzip it
35
+
36
+ 6. Copy all files from `scenario-1/timeline/events` directory to `dataset/event-summarization` directory
37
+
38
+ The extras split the optional halves: `bertscore` adds `modern-bert-score`, `llm` adds `openai` and `python-dotenv`, and `all` adds both. `requirements.txt` still holds the full environment used for the paper.
39
+
40
+ # How to run
41
+
42
+ 1. Add `.env` file in `src` directory. Add your OpenAI API keys in the `.env` file, something like: `OPENAI_API_KEY=sk-proj-xxx`
43
+
44
+ 2. Run the task
45
+
46
+ `llm-forensic-timeline run --task event-summarization`
47
+
48
+ The original script still works: `python src/run.py`
49
+
50
+ # How to evaluate
51
+
52
+ `llm-forensic-timeline evaluate` compares the LLM answers against the ground truth and writes the scores to a CSV file:
53
+
54
+ ```
55
+ llm-forensic-timeline evaluate \
56
+ --groundtruth-dir event-reconstruction/ground-truth-multiple \
57
+ --llm-dir event-reconstruction/chatgpt-with-knowledge-multiple \
58
+ --output event-reconstruction/chatgpt-with-knowledge-multiple-results.csv
59
+ ```
60
+
61
+ The original script still works: edit the `task` and `prediction` variables at the top of `src/evaluation-list.py`, then run it from the directory that contains the task directory.
62
+
63
+ Three metrics are reported per file:
64
+
65
+ 1. **BLEU** and **ROUGE** (ROUGE-1, ROUGE-2, ROUGE-L, ROUGE-Lsum) through the Hugging Face `evaluate` library. Both are n-gram overlap metrics, so they only measure lexical similarity.
66
+
67
+ 2. **BERTScore** through [`modern-bert-score`](https://pypi.org/project/modern-bert-score/), which is semantic-aware and therefore credits an answer that is worded differently but carries the same meaning. This addresses the limitation of BLEU and ROUGE discussed in Sec. 4.4.2 of the paper. The columns `bertscore_precision`, `bertscore_recall`, and `bertscore_f1` hold the mean over all entries of a file.
68
+
69
+ Notes on BERTScore:
70
+
71
+ - The model is `LazerLambda/ModernBERT-large-ModBERTScore-19`, the strongest checkpoint shipped with the package. It is the largest one, and its 8192-token context keeps long JSON entries of a forensic timeline intact, while the RoBERTa checkpoints truncate at 512 tokens. The weights (about 1.6 GB) are downloaded from Hugging Face on the first run and cached afterwards.
72
+ - Scores are rescaled with the baseline of the model, as recommended by the BERTScore authors. Without rescaling, scores of unrelated texts sit near 0.8; with rescaling, they sit near 0 and can be slightly negative, which makes the results easier to read.
73
+ - The script selects CUDA or Apple Silicon (MPS) automatically and falls back to the CPU. Evaluating a large timeline on the CPU is slow.
74
+ - Pass `--no-bertscore` to score with BLEU and ROUGE only, without loading a transformer model.
75
+
76
+ # Development
77
+
78
+ Run the test suite:
79
+
80
+ ```
81
+ pip install -e ".[test]"
82
+ pytest
83
+ ```
84
+
85
+ Build the documentation locally:
86
+
87
+ ```
88
+ pip install -r docs/requirements.txt
89
+ python -m sphinx -W -b html docs/source docs/_build/html
90
+ ```
91
+
92
+ The `Run Tests` workflow runs pytest on Python 3.10 through 3.13 and builds the documentation on every push and pull request to `main`. Pushing a `v*.*.*` tag builds the distributions and publishes them to PyPI through OIDC Trusted Publishing, without any stored credentials.
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "llm-forensic-timeline"
7
+ version = "0.0.2"
8
+ description = "Standardized methodology and dataset for evaluating LLM-based digital forensic timeline analysis"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [
13
+ { name = "Hudan Studiawan" },
14
+ { name = "Frank Breitinger" },
15
+ { name = "Mark Scanlon" },
16
+ ]
17
+ keywords = ["forensics", "timeline", "llm", "evaluation", "bleu", "rouge", "bertscore", "plaso"]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Developers",
21
+ "Intended Audience :: Information Technology",
22
+ "Intended Audience :: Science/Research",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Security",
31
+ "Topic :: Scientific/Engineering :: Information Analysis",
32
+ ]
33
+ dependencies = [
34
+ "evaluate",
35
+ "rouge_score",
36
+ "absl-py",
37
+ "nltk",
38
+ ]
39
+
40
+ [project.optional-dependencies]
41
+ # BERTScore needs Python 3.12+ because modern-bert-score does.
42
+ bertscore = [
43
+ "modern-bert-score; python_version >= '3.12'",
44
+ ]
45
+ llm = [
46
+ "openai",
47
+ "python-dotenv",
48
+ ]
49
+ all = [
50
+ "llm-forensic-timeline[bertscore,llm]",
51
+ ]
52
+ test = [
53
+ "pytest",
54
+ ]
55
+ docs = [
56
+ "sphinx",
57
+ "sphinx-rtd-theme",
58
+ ]
59
+
60
+ [project.urls]
61
+ Homepage = "https://github.com/studiawan/llm-forensic-timeline"
62
+ Repository = "https://github.com/studiawan/llm-forensic-timeline"
63
+ Issues = "https://github.com/studiawan/llm-forensic-timeline/issues"
64
+ Documentation = "https://llm-forensic-timeline.readthedocs.io"
65
+ Dataset = "https://zenodo.org/records/15493424"
66
+ Paper = "https://doi.org/10.1016/j.fsidi.2025.301982"
67
+
68
+ [project.scripts]
69
+ llm-forensic-timeline = "llm_forensic_timeline.cli:main"
70
+
71
+ [tool.setuptools.packages.find]
72
+ where = ["src"]
73
+ include = ["llm_forensic_timeline*"]
74
+
75
+ [tool.pytest.ini_options]
76
+ pythonpath = ["src", "tests"]
77
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,44 @@
1
+ """Standardized evaluation of LLM-based digital forensic timeline analysis.
2
+
3
+ The package implements the methodology of the DFRWS APAC 2025 paper *Towards a
4
+ standardized methodology and dataset for evaluating LLM-based digital forensic
5
+ timeline analysis*. It drives an LLM over a Plaso timeline and scores the
6
+ answers against a ground truth with BLEU, ROUGE, and BERTScore.
7
+ """
8
+
9
+ from .evaluation import (
10
+ evaluate_directory,
11
+ evaluate_file,
12
+ load_pair,
13
+ read_json_file,
14
+ read_txt_file,
15
+ write_results_csv,
16
+ )
17
+ from .metrics import (
18
+ DEFAULT_BERTSCORE_MODEL,
19
+ BertScoreMetric,
20
+ BleuMetric,
21
+ MetricSuite,
22
+ RougeMetric,
23
+ build_default_suite,
24
+ select_device,
25
+ )
26
+
27
+ __version__ = "0.0.2"
28
+
29
+ __all__ = [
30
+ "BertScoreMetric",
31
+ "BleuMetric",
32
+ "DEFAULT_BERTSCORE_MODEL",
33
+ "MetricSuite",
34
+ "RougeMetric",
35
+ "build_default_suite",
36
+ "evaluate_directory",
37
+ "evaluate_file",
38
+ "load_pair",
39
+ "read_json_file",
40
+ "read_txt_file",
41
+ "select_device",
42
+ "write_results_csv",
43
+ "__version__",
44
+ ]
@@ -0,0 +1,147 @@
1
+ """Command line interface of the package.
2
+
3
+ Two subcommands mirror the two halves of the methodology: ``run`` drives the
4
+ LLM over a timeline, and ``evaluate`` scores the answers it produced against
5
+ the ground truth.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import os
12
+ from typing import List, Optional
13
+
14
+ from .evaluation import evaluate_directory
15
+ from .metrics import DEFAULT_BERTSCORE_MODEL, build_default_suite
16
+ from .runner import DEFAULT_MODEL
17
+
18
+
19
+ def build_parser() -> argparse.ArgumentParser:
20
+ """Build the argument parser.
21
+
22
+ :return: The parser, with the ``run`` and ``evaluate`` subcommands.
23
+ :rtype: argparse.ArgumentParser
24
+ """
25
+ parser = argparse.ArgumentParser(
26
+ prog="llm-forensic-timeline",
27
+ description=(
28
+ "Standardized evaluation of LLM-based digital forensic timeline "
29
+ "analysis."
30
+ ),
31
+ )
32
+ subparsers = parser.add_subparsers(dest="command", required=True)
33
+
34
+ run_parser = subparsers.add_parser(
35
+ "run", help="Send a forensic timeline and its prompts to an LLM"
36
+ )
37
+ run_parser.add_argument(
38
+ "-t", "--task", required=True, help="Task name, e.g. event-summarization"
39
+ )
40
+ run_parser.add_argument(
41
+ "-d", "--dataset-dir", default="dataset", help="Root of the CSV timelines"
42
+ )
43
+ run_parser.add_argument(
44
+ "-p", "--prompts-dir", default="prompt", help="Root of the JSON prompts"
45
+ )
46
+ run_parser.add_argument(
47
+ "-o", "--results-dir", default="results", help="Where to save the answers"
48
+ )
49
+ run_parser.add_argument(
50
+ "-m", "--model", default=DEFAULT_MODEL, help="The OpenAI model to run"
51
+ )
52
+ run_parser.add_argument(
53
+ "--env-file", default=None, help="Path to the .env holding OPENAI_API_KEY"
54
+ )
55
+
56
+ evaluate_parser = subparsers.add_parser(
57
+ "evaluate", help="Score LLM answers against the ground truth"
58
+ )
59
+ evaluate_parser.add_argument(
60
+ "-g", "--groundtruth-dir", required=True, help="Directory of ground truth files"
61
+ )
62
+ evaluate_parser.add_argument(
63
+ "-l", "--llm-dir", required=True, help="Directory of LLM answers"
64
+ )
65
+ evaluate_parser.add_argument(
66
+ "-o", "--output", default=None, help="Where to write the results CSV"
67
+ )
68
+ evaluate_parser.add_argument(
69
+ "--no-bertscore",
70
+ action="store_true",
71
+ help="Score with BLEU and ROUGE only, without loading a transformer model",
72
+ )
73
+ evaluate_parser.add_argument(
74
+ "--bertscore-model",
75
+ default=DEFAULT_BERTSCORE_MODEL,
76
+ help="The BERTScore checkpoint to embed with",
77
+ )
78
+ evaluate_parser.add_argument(
79
+ "--device",
80
+ default=None,
81
+ help="Device for BERTScore: cuda, mps, or cpu. Detected when omitted",
82
+ )
83
+
84
+ return parser
85
+
86
+
87
+ def run_command(args: argparse.Namespace) -> int:
88
+ """Handle the ``run`` subcommand.
89
+
90
+ :param args: The parsed arguments.
91
+ :return: The process exit code.
92
+ :rtype: int
93
+ """
94
+ from .runner import build_client, run_task
95
+
96
+ client = build_client(args.env_file)
97
+ run_task(
98
+ client,
99
+ args.task,
100
+ dataset_dir=args.dataset_dir,
101
+ prompts_dir=args.prompts_dir,
102
+ results_dir=args.results_dir,
103
+ model=args.model,
104
+ )
105
+ return 0
106
+
107
+
108
+ def evaluate_command(args: argparse.Namespace) -> int:
109
+ """Handle the ``evaluate`` subcommand.
110
+
111
+ :param args: The parsed arguments.
112
+ :return: The process exit code.
113
+ :rtype: int
114
+ """
115
+ if not os.path.isdir(args.groundtruth_dir):
116
+ print(f"[!] Ground truth directory not found: {args.groundtruth_dir}")
117
+ return 1
118
+ if not os.path.isdir(args.llm_dir):
119
+ print(f"[!] LLM answer directory not found: {args.llm_dir}")
120
+ return 1
121
+
122
+ suite = build_default_suite(
123
+ with_bertscore=not args.no_bertscore,
124
+ bertscore_model=args.bertscore_model,
125
+ device=args.device,
126
+ )
127
+ evaluate_directory(
128
+ args.groundtruth_dir, args.llm_dir, suite, output_path=args.output
129
+ )
130
+ return 0
131
+
132
+
133
+ def main(argv: Optional[List[str]] = None) -> int:
134
+ """Entry point of the ``llm-forensic-timeline`` command.
135
+
136
+ :param argv: The argument list. ``sys.argv`` is used when omitted.
137
+ :return: The process exit code.
138
+ :rtype: int
139
+ """
140
+ args = build_parser().parse_args(argv)
141
+ if args.command == "run":
142
+ return run_command(args)
143
+ return evaluate_command(args)
144
+
145
+
146
+ if __name__ == "__main__":
147
+ raise SystemExit(main())