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.

fix(benchmarks): make xbench-DeepSearch respect the configured number of examples (#4451) (#4494)

LearningCircuitb51dd317aeb6
diff --git a/changelog.d/4451.bugfix.md b/changelog.d/4451.bugfix.md
new file mode 100644
index 0000000000..c5a0dd69c6
--- /dev/null
+++ b/changelog.d/4451.bugfix.md
@@ -0,0 +1 @@
+Fixed benchmark runs with xbench-DeepSearch enabled ignoring the configured number of examples: `XBenchDeepSearchDataset.load()` overrode the base class with its own `num_examples` parameter, so the registry's argument-less `load()` call skipped sampling and queued all 100 (Chinese-language) xbench questions. A run configured for e.g. 50 SimpleQA + 10 xbench questions therefore processed 150 tasks against a recorded total of 60, driving the progress display past 100% and surfacing unexpected Chinese questions. The dataset now samples via the constructor's `num_examples`/`seed` like every other dataset.
diff --git a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
index 313e0725e2..69161e1735 100644
--- a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
+++ b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
@@ -6,7 +6,7 @@ which evaluates deep research and search capabilities.
"""
import base64
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List
from loguru import logger
from .base import BenchmarkDataset
@@ -38,35 +38,34 @@ class XBenchDeepSearchDataset(BenchmarkDataset):
"""Get the default path for the dataset."""
return "xbench/DeepSearch" # Hugging Face dataset identifier
- def load(
- self,
- dataset_path: str = None,
- num_examples: Optional[int] = None,
- seed: int = 42,
- ) -> List[Dict[str, Any]]:
+ def load(self) -> List[Dict[str, Any]]:
"""Override load to handle HuggingFace datasets directly.
- Args:
- dataset_path: Path to dataset (defaults to HuggingFace)
- num_examples: Optional number of examples to limit
- seed: Random seed for sampling
+ Keeps the base-class contract: callers configure sampling via the
+ constructor (``num_examples``/``seed``) and call ``load()`` with no
+ arguments, as ``DatasetRegistry.load_dataset()`` does.
Returns:
List of processed dataset examples
"""
import random
+ if self._is_loaded:
+ return self.examples
+
# Load the data
- data = self.load_data(dataset_path)
+ data = self.load_data(self.dataset_path)
# Sample if requested
- if num_examples and len(data) > num_examples:
+ if self.num_examples and len(data) > self.num_examples:
# Security: seeded random for reproducible benchmark sampling, not security-sensitive
- random.seed(seed)
- data = random.sample(data, num_examples)
+ random.seed(self.seed)
+ data = random.sample(data, self.num_examples)
# Process each example
- return [self.process_example(item) for item in data]
+ self.examples = [self.process_example(item) for item in data]
+ self._is_loaded = True
+ return self.examples
def load_data(
self,
diff --git a/tests/benchmarks/datasets/test_xbench_deepsearch_coverage.py b/tests/benchmarks/datasets/test_xbench_deepsearch_coverage.py
index 5dc339806e..48ead16078 100644
--- a/tests/benchmarks/datasets/test_xbench_deepsearch_coverage.py
+++ b/tests/benchmarks/datasets/test_xbench_deepsearch_coverage.py
@@ -205,13 +205,13 @@ class TestLoad:
{"id": "2", "problem": "P2", "answer": "A2", "canary": ""},
]
with patch.object(ds, "load_data", return_value=raw):
- result = ds.load(dataset_path="dummy/path")
+ result = ds.load()
assert len(result) == 2
assert result[0]["requires_deep_search"] is True
def test_load_with_sampling(self):
"""load() samples when num_examples < total length."""
- ds = _make_dataset()
+ ds = _make_dataset(num_examples=3, seed=42)
raw = [
{
"id": str(i),
@@ -222,13 +222,13 @@ class TestLoad:
for i in range(10)
]
with patch.object(ds, "load_data", return_value=raw):
- result = ds.load(num_examples=3, seed=42)
+ result = ds.load()
assert len(result) == 3
for item in result:
assert item["requires_deep_search"] is True
def test_load_samples_when_num_examples_set(self):
- ds = _make_dataset()
+ ds = _make_dataset(num_examples=3, seed=42)
raw = [
{
"id": str(i),
@@ -239,7 +239,7 @@ class TestLoad:
for i in range(10)
]
with patch.object(ds, "load_data", return_value=raw):
- result = ds.load(num_examples=3, seed=42)
+ result = ds.load()
assert len(result) == 3
def test_load_no_sampling_when_num_examples_none(self):
@@ -272,12 +272,50 @@ class TestLoad:
with patch.object(
ds, "process_example", wraps=ds.process_example
) as mock_process:
- result = ds.load(dataset_path="fake/path")
+ result = ds.load()
mock_load.assert_called_once()
mock_process.assert_called_once_with(raw[0])
assert len(result) == 1
assert result[0]["requires_deep_search"] is True
+ def test_load_caches_results(self):
+ """A second load() returns the cached examples without reloading."""
+ ds = _make_dataset()
+ raw = [{"id": "1", "problem": "P", "answer": "A", "canary": ""}]
+ with patch.object(ds, "load_data", return_value=raw) as mock_load:
+ first = ds.load()
+ second = ds.load()
+ mock_load.assert_called_once()
+ assert first is second
+
+ def test_registry_load_dataset_respects_num_examples(self):
+ """Regression test for #4451: DatasetRegistry.load_dataset() calls
+ load() with no arguments, so sampling must honor the constructor's
+ num_examples instead of loading the full dataset."""
+ from local_deep_research.benchmarks.datasets.base import (
+ DatasetRegistry,
+ )
+ from local_deep_research.benchmarks.datasets.xbench_deepsearch import (
+ XBenchDeepSearchDataset,
+ )
+
+ raw = [
+ {
+ "id": str(i),
+ "problem": f"Q{i}",
+ "answer": f"A{i}",
+ "canary": "",
+ }
+ for i in range(100)
+ ]
+ with patch.object(
+ XBenchDeepSearchDataset, "load_data", return_value=raw
+ ):
+ result = DatasetRegistry.load_dataset(
+ "xbench_deepsearch", num_examples=10, seed=None
+ )
+ assert len(result) == 10
+
# ---------------------------------------------------------------------------
# load_data() – datasets library available, plain text fields