Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat(benchmarks): add sampling seed for reproducible benchmark question selection (#4516)

LearningCircuitf495410c77a0
diff --git a/changelog.d/4516.feature.md b/changelog.d/4516.feature.md
new file mode 100644
index 0000000000..54cf6a44b2
--- /dev/null
+++ b/changelog.d/4516.feature.md
@@ -0,0 +1 @@
+Added a "Sampling Seed" field to the benchmark configuration (default 42): the same seed and example counts now select the same benchmark questions on every run, so accuracy numbers are comparable across runs and configurations. The seed is stored with each benchmark run. Leave the field empty to draw a fresh random sample each run (the previous behavior).
diff --git a/src/local_deep_research/benchmarks/web_api/benchmark_service.py b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
index 0a9c7b27c6..bf10d99d2b 100644
--- a/src/local_deep_research/benchmarks/web_api/benchmark_service.py
+++ b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
@@ -548,7 +548,13 @@ class BenchmarkService:
datasets_config: Dict,
benchmark_run_id: int,
) -> List[Dict]:
- """Create list of tasks to process."""
+ """Create list of tasks to process.
+
+ Each dataset config may carry a "seed" for reproducible sampling:
+ the same seed and count select the same questions on every run,
+ keeping accuracy comparable across runs. Without a seed the sample
+ is random each time.
+ """
tasks: List[Dict[str, Any]] = []
for dataset_name, config in datasets_config.items():
@@ -556,7 +562,7 @@ class BenchmarkService:
dataset = load_dataset(
dataset_type=dataset_name,
num_examples=config["count"],
- seed=None,
+ seed=config.get("seed"),
)
for i, example in enumerate(dataset):
diff --git a/src/local_deep_research/web/templates/pages/benchmark.html b/src/local_deep_research/web/templates/pages/benchmark.html
index 6e402d084f..d19200c237 100644
--- a/src/local_deep_research/web/templates/pages/benchmark.html
+++ b/src/local_deep_research/web/templates/pages/benchmark.html
@@ -136,6 +136,16 @@
<span class="ldr-input-help ldr-text-error">Warning: Expect poor performance - for curiosity testing only</span>
</div>
</div>
+
+ <!-- Sampling Seed -->
+ <div class="ldr-form-group">
+ <label for="sampling_seed">Sampling Seed</label>
+ <input type="number" id="sampling_seed"
+ name="sampling_seed" value="42"
+ min="0" step="1"
+ class="ldr-form-control">
+ <span class="ldr-input-help">Same seed + same counts = same questions on every run, so accuracy stays comparable across configurations. Leave empty to draw a fresh random sample each run.</span>
+ </div>
</fieldset>
</div>
@@ -637,6 +647,14 @@ function getConfigurationData() {
};
}
+ // An empty seed field means a fresh random sample each run
+ const samplingSeed = parseInt(document.getElementById('sampling_seed').value, 10);
+ if (!Number.isNaN(samplingSeed)) {
+ for (const datasetConfig of Object.values(datasets_config)) {
+ datasetConfig.seed = samplingSeed;
+ }
+ }
+
return {
run_name: document.getElementById('run_name').value,
datasets_config: datasets_config
diff --git a/tests/benchmarks/web_api/test_benchmark_service_coverage.py b/tests/benchmarks/web_api/test_benchmark_service_coverage.py
index 04dbea913f..8217a8a479 100644
--- a/tests/benchmarks/web_api/test_benchmark_service_coverage.py
+++ b/tests/benchmarks/web_api/test_benchmark_service_coverage.py
@@ -324,6 +324,40 @@ class TestCreateTaskQueue:
assert tasks[0]["question"] == "Q1?"
assert tasks[0]["dataset_type"] == "simpleqa"
+ @patch(f"{MODULE}.load_dataset")
+ def test_passes_seed_from_dataset_config(self, mock_load):
+ """A "seed" in the dataset config drives reproducible sampling."""
+ svc = _make_service()
+ mock_load.return_value = [
+ {"id": "ex1", "problem": "Q1?", "answer": "A1"},
+ ]
+
+ svc._create_task_queue(
+ {"simpleqa": {"count": 1, "seed": 7}},
+ benchmark_run_id=1,
+ )
+
+ mock_load.assert_called_once_with(
+ dataset_type="simpleqa", num_examples=1, seed=7
+ )
+
+ @patch(f"{MODULE}.load_dataset")
+ def test_no_seed_means_random_sampling(self, mock_load):
+ """Without a configured seed the sample stays random (seed=None)."""
+ svc = _make_service()
+ mock_load.return_value = [
+ {"id": "ex1", "problem": "Q1?", "answer": "A1"},
+ ]
+
+ svc._create_task_queue(
+ {"simpleqa": {"count": 1}},
+ benchmark_run_id=1,
+ )
+
+ mock_load.assert_called_once_with(
+ dataset_type="simpleqa", num_examples=1, seed=None
+ )
+
@patch(f"{MODULE}.load_dataset")
def test_queues_every_sampled_question(self, mock_load):
"""Regression test for #4498: every sampled question becomes a task.