~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: integrate xbench-DeepSearch benchmark support
LearningCircuit50986eab8855
diff --git a/pyproject.toml b/pyproject.tomlindex 7fba1e7a4e..bfa8990c0d 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -80,6 +80,8 @@ dependencies = ["lxml-html-clean>=0.4.2","weasyprint>=66.0","markdown>=3.9",+ "datasets>=2.14.0",+ "pyarrow>=12.0.0",][project.optional-dependencies]diff --git a/src/local_deep_research/api/benchmark_functions.py b/src/local_deep_research/api/benchmark_functions.pyindex 3fc9e8a488..4933b9b008 100644--- a/src/local_deep_research/api/benchmark_functions.py+++ b/src/local_deep_research/api/benchmark_functions.py@@ -14,6 +14,7 @@ from ..benchmarks import (run_benchmark,run_browsecomp_benchmark,run_simpleqa_benchmark,+ run_xbench_deepsearch_benchmark,)@@ -129,6 +130,64 @@ def evaluate_browsecomp(return results+def evaluate_xbench_deepsearch(+ num_examples: int = 100,+ search_iterations: int = 4,+ questions_per_iteration: int = 3,+ search_tool: str = "searxng",+ human_evaluation: bool = False,+ evaluation_model: Optional[str] = None,+ evaluation_provider: Optional[str] = None,+ output_dir: str = "benchmark_results",+) -> Dict[str, Any]:+ """+ Run xbench-DeepSearch benchmark evaluation.++ Args:+ num_examples: Number of examples to evaluate (default 100 - full dataset)+ search_iterations: Number of search iterations per query+ questions_per_iteration: Number of questions per iteration+ search_tool: Search engine to use (e.g., 'searxng', 'wikipedia')+ human_evaluation: Whether to use human evaluation+ evaluation_model: Optional custom model for evaluation+ evaluation_provider: Optional custom provider for evaluation+ output_dir: Directory to save results++ Returns:+ Dictionary with benchmark results+ """+ logger.info(+ f"Starting xbench-DeepSearch benchmark with {num_examples} examples"+ )++ # Set up search configuration+ search_config = {+ "iterations": search_iterations,+ "questions_per_iteration": questions_per_iteration,+ "search_tool": search_tool,+ }++ # Set up evaluation configuration if needed+ evaluation_config = None+ if evaluation_model or evaluation_provider:+ evaluation_config = {}+ if evaluation_model:+ evaluation_config["model_name"] = evaluation_model+ if evaluation_provider:+ evaluation_config["provider"] = evaluation_provider++ # Run the benchmark+ results = run_xbench_deepsearch_benchmark(+ num_examples=num_examples,+ output_dir=output_dir,+ search_config=search_config,+ evaluation_config=evaluation_config,+ human_evaluation=human_evaluation,+ )++ return results++def get_available_benchmarks() -> List[Dict[str, str]]:"""Get information about available benchmarks.@@ -149,6 +208,12 @@ def get_available_benchmarks() -> List[Dict[str, str]]:"description": "Benchmark for web browsing comprehension","recommended_examples": 100,},+ {+ "id": "xbench_deepsearch",+ "name": "xbench-DeepSearch",+ "description": "Benchmark for deep search and investigation queries",+ "recommended_examples": 100,+ },]@@ -285,6 +350,7 @@ __all__ = ["compare_configurations","evaluate_browsecomp","evaluate_simpleqa",+ "evaluate_xbench_deepsearch","generate_report","get_available_benchmarks","run_benchmark", # For advanced usersdiff --git a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.pyindex 3228656dd4..8b3787950a 100644--- a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py+++ b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py@@ -67,11 +67,18 @@ class XBenchDeepSearchDataset(BenchmarkDataset):# Process each examplereturn [self.process_example(item) for item in data]- def load_data(self, dataset_path: str = None) -> List[Dict[str, Any]]:+ def load_data(+ self,+ dataset_path: str = None,+ num_examples: int = None,+ seed: int = None,+ ) -> List[Dict[str, Any]]:"""Load the xbench-DeepSearch dataset from Hugging Face.Args:dataset_path: Path to dataset (defaults to Hugging Face)+ num_examples: Optional number of examples to limit+ seed: Random seed for samplingReturns:List of questions from xbench-DeepSearch@@ -83,7 +90,7 @@ class XBenchDeepSearchDataset(BenchmarkDataset):"datasets library not installed. Run: pip install datasets")# Fallback to direct download- return self._load_from_url()+ return self._load_from_url(num_examples, seed)dataset_path = dataset_path or self.get_default_dataset_path()@@ -138,18 +145,42 @@ class XBenchDeepSearchDataset(BenchmarkDataset):}formatted_questions.append(formatted_item)- logger.info(- f"Loaded {len(formatted_questions)} questions from xbench-DeepSearch"- )+ # Apply sampling if num_examples is specified+ if num_examples and num_examples < len(formatted_questions):+ import random++ # Use provided seed or None for random sampling+ if seed is not None:+ random.seed(seed)+ formatted_questions = random.sample(+ formatted_questions, num_examples+ )+ logger.info(+ f"Sampled {num_examples} questions from xbench-DeepSearch (total available: {len(dataset)})"+ )+ else:+ logger.info(+ f"Loaded {len(formatted_questions)} questions from xbench-DeepSearch"+ )return formatted_questionsexcept Exception as e:logger.warning(f"Failed to load via datasets library: {e}")logger.info("Falling back to direct download")- return self._load_from_url()+ return self._load_from_url(num_examples, seed)++ def _load_from_url(+ self, num_examples: int = None, seed: int = None+ ) -> List[Dict[str, Any]]:+ """Load dataset directly from URL without datasets library.- def _load_from_url(self) -> List[Dict[str, Any]]:- """Load dataset directly from URL without datasets library."""+ Args:+ num_examples: Optional number of examples to limit+ seed: Random seed for sampling++ Returns:+ List of questions from xbench-DeepSearch+ """import pandas as pdtry:@@ -202,9 +233,21 @@ class XBenchDeepSearchDataset(BenchmarkDataset):})- logger.info(- f"Loaded {len(questions)} questions via direct download"- )+ # Apply sampling if num_examples is specified+ if num_examples and num_examples < len(questions):+ import random++ # Use provided seed or None for random sampling+ if seed is not None:+ random.seed(seed)+ questions = random.sample(questions, num_examples)+ logger.info(+ f"Sampled {num_examples} questions via direct download (total available: {len(questions)})"+ )+ else:+ logger.info(+ f"Loaded {len(questions)} questions via direct download"+ )return questionsexcept Exception:diff --git a/src/local_deep_research/benchmarks/web_api/benchmark_service.py b/src/local_deep_research/benchmarks/web_api/benchmark_service.pyindex ac5ba5024f..664996e59b 100644--- a/src/local_deep_research/benchmarks/web_api/benchmark_service.py+++ b/src/local_deep_research/benchmarks/web_api/benchmark_service.py@@ -1174,38 +1174,39 @@ class BenchmarkService:results = current_resultsrunning_accuracy = None- simpleqa_accuracy = None- browsecomp_accuracy = None+ # Dynamic per-dataset accuracy tracking+ dataset_accuracies = {}if results:# Overall running accuracycorrect_count = sum(1 for r in results if r.is_correct)running_accuracy = (correct_count / len(results)) * 100- # Per-dataset accuracy- simpleqa_results = [- r for r in results if r.dataset_type.value == "simpleqa"- ]- if simpleqa_results:- simpleqa_correct = sum(- 1 for r in simpleqa_results if r.is_correct- )- simpleqa_accuracy = (- simpleqa_correct / len(simpleqa_results)- ) * 100-- browsecomp_results = [- r- for r in results- if r.dataset_type.value == "browsecomp"- ]- if browsecomp_results:- browsecomp_correct = sum(- 1 for r in browsecomp_results if r.is_correct- )- browsecomp_accuracy = (- browsecomp_correct / len(browsecomp_results)- ) * 100+ # Calculate accuracy for each dataset type dynamically+ from collections import defaultdict++ dataset_results = defaultdict(list)++ # Group results by dataset type+ for r in results:+ dataset_results[r.dataset_type.value].append(r)++ # Calculate accuracy for each dataset+ for (+ dataset_type,+ dataset_result_list,+ ) in dataset_results.items():+ if dataset_result_list:+ correct = sum(+ 1 for r in dataset_result_list if r.is_correct+ )+ accuracy = (+ correct / len(dataset_result_list)+ ) * 100+ # Store with _accuracy suffix for consistency+ dataset_accuracies[f"{dataset_type}_accuracy"] = (+ accuracy+ )# Calculate time estimates and reliability metricsestimated_time_remaining = None@@ -1288,8 +1289,6 @@ class BenchmarkService:"overall_accuracy": benchmark_run.overall_accuracyor running_accuracy, # Use running accuracy if final not calculated"running_accuracy": running_accuracy, # Current running accuracy- "simpleqa_accuracy": simpleqa_accuracy, # Per-dataset accuracy- "browsecomp_accuracy": browsecomp_accuracy,"processing_rate": benchmark_run.processing_rate,"estimated_time_remaining": estimated_time_remaining, # seconds"total_elapsed_time": total_elapsed_time, # seconds@@ -1305,12 +1304,14 @@ class BenchmarkService:if benchmark_run.end_timeelse None,"error_message": benchmark_run.error_message,+ # Add all per-dataset accuracies dynamically+ **dataset_accuracies,}logger.info(f"Benchmark {benchmark_run_id} status - completed: {benchmark_run.completed_examples}, "- f"running_acc: {running_accuracy}, simpleqa_acc: {simpleqa_accuracy}, "- f"browsecomp_acc: {browsecomp_accuracy}, avg_time: {avg_time_per_example}"+ f"running_acc: {running_accuracy}, dataset_accuracies: {dataset_accuracies}, "+ f"avg_time: {avg_time_per_example}")return status_datadiff --git a/src/local_deep_research/database/models/benchmark.py b/src/local_deep_research/database/models/benchmark.pyindex e4f5286039..b9817bb7f6 100644--- a/src/local_deep_research/database/models/benchmark.py+++ b/src/local_deep_research/database/models/benchmark.py@@ -39,6 +39,7 @@ class DatasetType(enum.Enum):SIMPLEQA = "simpleqa"BROWSECOMP = "browsecomp"+ XBENCH_DEEPSEARCH = "xbench_deepsearch"CUSTOM = "custom"diff --git a/src/local_deep_research/web/templates/pages/benchmark.html b/src/local_deep_research/web/templates/pages/benchmark.htmlindex 9dfc807ca5..bd7c55437d 100644--- a/src/local_deep_research/web/templates/pages/benchmark.html+++ b/src/local_deep_research/web/templates/pages/benchmark.html@@ -1026,6 +1026,9 @@ let evalModelData = null;let evalTempData = null;let evalEndpointData = null;+// Global variables for providers loaded from API+let EVAL_MODEL_PROVIDERS = [];+// Charts for performance trackinglet accuracyChart = null;let timingChart = null;@@ -1860,34 +1863,56 @@ function initializeCharts() {}};+ // Define dataset configurations in one place+ const datasetConfigs = [+ {+ key: 'overall',+ label: 'Overall Accuracy',+ borderColor: '#4caf50',+ backgroundColor: 'rgba(76, 175, 80, 0.1)',+ fill: true+ },+ {+ key: 'simpleqa',+ label: 'SimpleQA Accuracy',+ borderColor: '#2196f3',+ backgroundColor: 'rgba(33, 150, 243, 0.1)',+ fill: false+ },+ {+ key: 'browsecomp',+ label: 'BrowseComp Accuracy',+ borderColor: '#ff9800',+ backgroundColor: 'rgba(255, 152, 0, 0.1)',+ fill: false+ },+ {+ key: 'xbench_deepsearch',+ label: 'xbench-DeepSearch Accuracy',+ borderColor: '#9c27b0',+ backgroundColor: 'rgba(156, 39, 176, 0.1)',+ fill: false+ }+ // Add new datasets here - just add a new object with key, label, and colors+ ];++ // Build chart datasets from configuration+ const chartDatasets = datasetConfigs.map(config => ({+ label: config.label,+ data: [],+ borderColor: config.borderColor,+ backgroundColor: config.backgroundColor,+ tension: 0.4,+ fill: config.fill || false+ }));+// Accuracy Chartconst accuracyCtx = document.getElementById('accuracy-chart').getContext('2d');accuracyChart = new Chart(accuracyCtx, {type: 'line',data: {labels: [],- datasets: [{- label: 'Overall Accuracy',- data: [],- borderColor: '#4caf50',- backgroundColor: 'rgba(76, 175, 80, 0.1)',- tension: 0.4,- fill: true- }, {- label: 'SimpleQA Accuracy',- data: [],- borderColor: '#2196f3',- backgroundColor: 'rgba(33, 150, 243, 0.1)',- tension: 0.4,- fill: false- }, {- label: 'BrowseComp Accuracy',- data: [],- borderColor: '#ff9800',- backgroundColor: 'rgba(255, 152, 0, 0.1)',- tension: 0.4,- fill: false- }]+ datasets: chartDatasets},options: {...chartOptions,@@ -1982,33 +2007,49 @@ function updateCharts(status) {if (currentExample <= 0) return;console.log('updateCharts called with status:', status);- console.log('Accuracy values - overall:', status.overall_accuracy, 'running:', status.running_accuracy,- 'simpleqa:', status.simpleqa_accuracy, 'browsecomp:', status.browsecomp_accuracy);++ // Collect all accuracy values from status+ const accuracyValues = {};+ for (const key in status) {+ if (key.endsWith('_accuracy') || key === 'overall_accuracy' || key === 'running_accuracy') {+ accuracyValues[key] = status[key];+ }+ }+ console.log('Found accuracy values:', accuracyValues);console.log('Timing value - avg_time_per_example:', status.avg_time_per_example);// Update accuracy chart- if (status.overall_accuracy !== undefined || status.running_accuracy !== undefined ||- status.simpleqa_accuracy !== undefined || status.browsecomp_accuracy !== undefined) {+ if (Object.keys(accuracyValues).length > 0) {// Add new data pointconst labels = accuracyChart.data.labels;- const overallAcc = status.overall_accuracy !== null && status.overall_accuracy !== undefined ?- status.overall_accuracy :- (status.running_accuracy !== null && status.running_accuracy !== undefined ? status.running_accuracy : 0);- const simpleqaAcc = status.simpleqa_accuracy !== null && status.simpleqa_accuracy !== undefined ? status.simpleqa_accuracy : 0;- const browsecompAcc = status.browsecomp_accuracy !== null && status.browsecomp_accuracy !== undefined ? status.browsecomp_accuracy : 0;++ // Map configuration keys to status keys and extract values+ const dataPoints = datasetConfigs.map((config, idx) => {+ if (config.key === 'overall') {+ // Handle overall accuracy specially+ return status.overall_accuracy !== null && status.overall_accuracy !== undefined ?+ status.overall_accuracy :+ (status.running_accuracy !== null && status.running_accuracy !== undefined ? status.running_accuracy : 0);+ } else {+ // Handle dataset-specific accuracies+ const accuracyKey = `${config.key}_accuracy`;+ return status[accuracyKey] !== null && status[accuracyKey] !== undefined ? status[accuracyKey] : 0;+ }+ });if (!labels.includes(currentExample)) {labels.push(currentExample);- accuracyChart.data.datasets[0].data.push(overallAcc);- accuracyChart.data.datasets[1].data.push(simpleqaAcc);- accuracyChart.data.datasets[2].data.push(browsecompAcc);+ // Push data for each dataset+ dataPoints.forEach((value, idx) => {+ accuracyChart.data.datasets[idx].data.push(value);+ });} else {// Update existing data pointconst index = labels.indexOf(currentExample);if (index >= 0) {- accuracyChart.data.datasets[0].data[index] = overallAcc;- accuracyChart.data.datasets[1].data[index] = simpleqaAcc;- accuracyChart.data.datasets[2].data[index] = browsecompAcc;+ dataPoints.forEach((value, idx) => {+ accuracyChart.data.datasets[idx].data[index] = value;+ });}}@@ -2064,10 +2105,18 @@ async function loadHistoricalChartData() {// Generate some sample points for the chartfor (let i = 1; i <= totalCompleted; i += Math.max(1, Math.floor(totalCompleted / 20))) {accuracyChart.data.labels.push(i);- // Use current accuracy as approximation (in real implementation, store historical values)- accuracyChart.data.datasets[0].data.push(status.overall_accuracy || 0);- accuracyChart.data.datasets[1].data.push(status.simpleqa_accuracy || 0);- accuracyChart.data.datasets[2].data.push(status.browsecomp_accuracy || 0);++ // Use the same dynamic approach as updateCharts+ datasetConfigs.forEach((config, idx) => {+ let value;+ if (config.key === 'overall') {+ value = status.overall_accuracy || 0;+ } else {+ const accuracyKey = `${config.key}_accuracy`;+ value = status[accuracyKey] || 0;+ }+ accuracyChart.data.datasets[idx].data.push(value);+ });timingChart.data.labels.push(i);timingChart.data.datasets[0].data.push(status.avg_time_per_example || 0);@@ -2330,8 +2379,8 @@ function populateEvaluationProviders() {// Clear existing optionsevaluationProviderSelect.innerHTML = '';- // Provider options (same as research page)- const providers = [+ // Use EVAL_MODEL_PROVIDERS if loaded from API, otherwise use defaults+ let providers = EVAL_MODEL_PROVIDERS.length > 0 ? EVAL_MODEL_PROVIDERS : [{ value: 'ollama', label: 'Ollama (Local)' },{ value: 'openai', label: 'OpenAI (Cloud)' },{ value: 'anthropic', label: 'Anthropic (Cloud)' },@@ -2377,11 +2426,12 @@ function setupEvaluationModelDropdown() {function() {// Get models dynamically based on current providerconst provider = evaluationProviderSelect ? evaluationProviderSelect.value : 'openai_endpoint';+ const providerKey = provider.toLowerCase();// Use loaded models if available- if (window.evaluationModels && window.evaluationModels[provider]) {- console.log(`Returning ${window.evaluationModels[provider].length} loaded models for ${provider}`);- return window.evaluationModels[provider];+ if (window.evaluationModels && window.evaluationModels[providerKey]) {+ console.log(`Returning ${window.evaluationModels[providerKey].length} loaded models for ${providerKey}`);+ return window.evaluationModels[providerKey];}// Otherwise return defaults@@ -2422,6 +2472,14 @@ function setupEvaluationModelDropdown() {console.log('Force refresh received model data:', data);if (data && data.providers) {+ // Store provider options if available+ if (data.provider_options && Array.isArray(data.provider_options)) {+ EVAL_MODEL_PROVIDERS = data.provider_options;+ console.log('Updated EVAL_MODEL_PROVIDERS from API:', EVAL_MODEL_PROVIDERS);+ // Re-populate the provider dropdown with new options+ populateEvaluationProviders();+ }+// Store the formatted modelswindow.evaluationModels = {};@@ -2464,12 +2522,14 @@ function setupEvaluationModelDropdown() {function getEvaluationModelOptions() {const provider = evaluationProviderSelect ? evaluationProviderSelect.value : 'openai_endpoint';- console.log('Getting evaluation model options for provider:', provider);+ // Convert to lowercase for model lookup since the backend uses lowercase+ const providerKey = provider.toLowerCase();+ console.log('Getting evaluation model options for provider:', provider, '(key:', providerKey, ')');// Check if we have loaded models- if (window.evaluationModels && window.evaluationModels[provider] && window.evaluationModels[provider].length > 0) {- console.log(`Returning ${window.evaluationModels[provider].length} cached models for ${provider}`);- return window.evaluationModels[provider];+ if (window.evaluationModels && window.evaluationModels[providerKey] && window.evaluationModels[providerKey].length > 0) {+ console.log(`Returning ${window.evaluationModels[providerKey].length} cached models for ${providerKey}`);+ return window.evaluationModels[providerKey];}// Load models from API if not already loading@@ -2537,6 +2597,14 @@ const loadEvaluationModelsFromAPI = debounce(function(forceRefresh = false) {console.log('Received model data:', data);if (data && data.providers) {+ // Store provider options if available+ if (data.provider_options && Array.isArray(data.provider_options)) {+ EVAL_MODEL_PROVIDERS = data.provider_options;+ console.log('Updated EVAL_MODEL_PROVIDERS from API (initial load):', EVAL_MODEL_PROVIDERS);+ // Re-populate the provider dropdown with new options+ populateEvaluationProviders();+ }+// Store the formatted models in a temporary variablewindow.evaluationModels = {};@@ -2614,10 +2682,12 @@ function filterModelsForProvider(models, provider) {function refreshEvaluationModels() {const provider = evaluationProviderSelect ? evaluationProviderSelect.value : 'openai_endpoint';- const options = window.evaluationModels && window.evaluationModels[provider] ?- window.evaluationModels[provider] : [];+ // Convert to lowercase for model lookup since the backend uses lowercase+ const providerKey = provider.toLowerCase();+ const options = window.evaluationModels && window.evaluationModels[providerKey] ?+ window.evaluationModels[providerKey] : [];- console.log(`Refreshing evaluation dropdown with ${options.length} options for provider ${provider}`);+ console.log(`Refreshing evaluation dropdown with ${options.length} options for provider ${provider} (key: ${providerKey})`);// If we have the updateDropdownOptions function and the inputif (window.updateDropdownOptions && evaluationModelInput) {@@ -2639,14 +2709,19 @@ function setupEvaluationEventHandlers() {// Show/hide endpoint URL fieldif (evaluationEndpointInput && evaluationEndpointInput.parentNode) {evaluationEndpointInput.parentNode.style.display =- provider === 'openai_endpoint' ? 'block' : 'none';+ provider === 'openai_endpoint' || provider === 'OPENAI_ENDPOINT' ? 'block' : 'none';}// Update model options for new providerrefreshEvaluationModels();+ // Convert provider value to lowercase for backend compatibility+ // The API returns uppercase values but the backend expects lowercase+ const backendProvider = provider.toLowerCase();+ console.log('Saving provider to backend as:', backendProvider);+// Save provider setting- saveEvaluationSetting('benchmark.evaluation.provider', provider);+ saveEvaluationSetting('benchmark.evaluation.provider', backendProvider);});}@@ -2689,14 +2764,27 @@ function loadEvaluationSettings() {// Set providerif (evaluationProviderSelect && evalProviderData && evalProviderData.settings) {- const providerValue = evalProviderData.settings.value || 'openai_endpoint';+ let providerValue = evalProviderData.settings.value || 'openai_endpoint';++ // The backend stores lowercase values but the UI might use uppercase+ // Try to find a matching uppercase value first+ const uppercaseValue = providerValue.toUpperCase();+ const providerOptions = Array.from(evaluationProviderSelect.options);+ const matchingOption = providerOptions.find(opt =>+ opt.value === uppercaseValue || opt.value === providerValue+ );++ if (matchingOption) {+ providerValue = matchingOption.value;+ }+console.log('Setting evaluation provider to:', providerValue);evaluationProviderSelect.value = providerValue;// Show/hide endpoint fieldif (evaluationEndpointInput && evaluationEndpointInput.parentNode) {evaluationEndpointInput.parentNode.style.display =- providerValue === 'openai_endpoint' ? 'block' : 'none';+ (providerValue === 'openai_endpoint' || providerValue === 'OPENAI_ENDPOINT') ? 'block' : 'none';}}@@ -2718,8 +2806,9 @@ function loadEvaluationSettings() {// Wait for models to be loaded, then set the valueconst setModelValue = () => {const provider = evaluationProviderSelect ? evaluationProviderSelect.value : 'openai_endpoint';- const models = window.evaluationModels && window.evaluationModels[provider] ?- window.evaluationModels[provider] : [];+ const providerKey = provider.toLowerCase();+ const models = window.evaluationModels && window.evaluationModels[providerKey] ?+ window.evaluationModels[providerKey] : [];// Find the matching model to get the labelconst matchingModel = models.find(m => m.value === modelValue);