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.

working on benchmarks

LearningCircuit45ba30d7388c
diff --git a/examples/run_benchmark.py b/examples/run_benchmark.py
new file mode 100644
index 0000000000..896ab5838b
--- /dev/null
+++ b/examples/run_benchmark.py
@@ -0,0 +1,196 @@
+#!/usr/bin/env python
+"""
+Example script for running benchmarks using the Local Deep Research benchmarking framework.
+
+This script demonstrates how to run SimpleQA and BrowseComp benchmarks programmatically.
+"""
+
+import argparse
+import logging
+import os
+
+from local_deep_research.api.benchmark_functions import (
+ compare_configurations,
+ evaluate_browsecomp,
+ evaluate_simpleqa,
+)
+
+# Configure logging
+logging.basicConfig(
+ level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
+logger = logging.getLogger(__name__)
+
+
+def main():
+ """Run benchmark examples."""
+ parser = argparse.ArgumentParser(description="LDR Benchmark Examples")
+ parser.add_argument(
+ "--benchmark",
+ choices=["simpleqa", "browsecomp", "compare"],
+ default="simpleqa",
+ help="Benchmark to run",
+ )
+ parser.add_argument(
+ "--examples", type=int, default=10, help="Number of examples to use"
+ )
+ parser.add_argument(
+ "--iterations", type=int, default=3, help="Number of search iterations"
+ )
+ parser.add_argument(
+ "--questions", type=int, default=3, help="Questions per iteration"
+ )
+ parser.add_argument("--search-tool", default="searxng", help="Search tool to use")
+ parser.add_argument(
+ "--human-eval", action="store_true", help="Use human evaluation"
+ )
+ parser.add_argument(
+ "--output-dir", default="benchmark_results", help="Directory to save results"
+ )
+
+ args = parser.parse_args()
+
+ # Create output directory if it doesn't exist
+ os.makedirs(args.output_dir, exist_ok=True)
+
+ print(f"Running {args.benchmark} benchmark with {args.examples} examples")
+
+ # Run the specified benchmark
+ if args.benchmark == "simpleqa":
+ run_simpleqa_example(args)
+ elif args.benchmark == "browsecomp":
+ run_browsecomp_example(args)
+ elif args.benchmark == "compare":
+ run_comparison_example(args)
+ else:
+ print(f"Unknown benchmark: {args.benchmark}")
+
+
+def run_simpleqa_example(args):
+ """Run SimpleQA benchmark."""
+ print("\n=== SimpleQA Benchmark ===")
+ print(f"Running with {args.examples} examples")
+ print(f"Search iterations: {args.iterations}")
+ print(f"Questions per iteration: {args.questions}")
+ print(f"Search tool: {args.search_tool}")
+ print(f"Human evaluation: {args.human_eval}")
+ print(f"Output directory: {args.output_dir}")
+ print("=" * 30)
+
+ # Run benchmark
+ result = evaluate_simpleqa(
+ num_examples=args.examples,
+ search_iterations=args.iterations,
+ questions_per_iteration=args.questions,
+ search_tool=args.search_tool,
+ human_evaluation=args.human_eval,
+ output_dir=args.output_dir,
+ )
+
+ # Print results
+ if "metrics" in result:
+ print("\nResults:")
+ print(f" Accuracy: {result['metrics'].get('accuracy', 0):.3f}")
+ print(f" Total examples: {result['total_examples']}")
+ print(f" Correct answers: {result['metrics'].get('correct', 0)}")
+ print(
+ f" Average time: {result['metrics'].get('average_processing_time', 0):.2f}s"
+ )
+ print(f"\nReport saved to: {result.get('report_path', 'N/A')}")
+ else:
+ print("\nBenchmark completed without evaluation")
+ print(f" Results saved to: {result.get('results_path', 'N/A')}")
+
+
+def run_browsecomp_example(args):
+ """Run BrowseComp benchmark."""
+ print("\n=== BrowseComp Benchmark ===")
+ print(f"Running with {args.examples} examples")
+ print(f"Search iterations: {args.iterations}")
+ print(f"Questions per iteration: {args.questions}")
+ print(f"Search tool: {args.search_tool}")
+ print(f"Human evaluation: {args.human_eval}")
+ print(f"Output directory: {args.output_dir}")
+ print("=" * 30)
+
+ # Run benchmark
+ result = evaluate_browsecomp(
+ num_examples=args.examples,
+ search_iterations=args.iterations,
+ questions_per_iteration=args.questions,
+ search_tool=args.search_tool,
+ human_evaluation=args.human_eval,
+ output_dir=args.output_dir,
+ )
+
+ # Print results
+ if "metrics" in result:
+ print("\nResults:")
+ print(f" Accuracy: {result['metrics'].get('accuracy', 0):.3f}")
+ print(f" Total examples: {result['total_examples']}")
+ print(f" Correct answers: {result['metrics'].get('correct', 0)}")
+ print(
+ f" Average time: {result['metrics'].get('average_processing_time', 0):.2f}s"
+ )
+ print(f"\nReport saved to: {result.get('report_path', 'N/A')}")
+ else:
+ print("\nBenchmark completed without evaluation")
+ print(f" Results saved to: {result.get('results_path', 'N/A')}")
+
+
+def run_comparison_example(args):
+ """Run configuration comparison."""
+ print("\n=== Configuration Comparison ===")
+ print(f"Dataset: {args.benchmark}")
+ print(f"Examples per configuration: {args.examples}")
+ print(f"Output directory: {args.output_dir}")
+ print("=" * 30)
+
+ # Define configurations to compare
+ configurations = [
+ {
+ "name": "Base Config",
+ "search_tool": args.search_tool,
+ "iterations": 1,
+ "questions_per_iteration": 3,
+ },
+ {
+ "name": "More Iterations",
+ "search_tool": args.search_tool,
+ "iterations": 3,
+ "questions_per_iteration": 3,
+ },
+ {
+ "name": "More Questions",
+ "search_tool": args.search_tool,
+ "iterations": 1,
+ "questions_per_iteration": 5,
+ },
+ ]
+
+ # Run comparison
+ result = compare_configurations(
+ dataset_type="simpleqa", # Use SimpleQA for faster comparison
+ num_examples=args.examples,
+ configurations=configurations,
+ output_dir=args.output_dir,
+ )
+
+ # Print results
+ print("\nComparison Results:")
+ print(f" Configurations tested: {result['configurations_tested']}")
+ print(f" Report saved to: {result['report_path']}")
+
+ # Print brief comparison table
+ print("\nResults Summary:")
+ print("Configuration | Accuracy | Avg. Time")
+ print("--------------- | -------- | ---------")
+ for res in result["results"]:
+ name = res["configuration_name"]
+ acc = res.get("metrics", {}).get("accuracy", 0)
+ time = res.get("metrics", {}).get("average_processing_time", 0)
+ print(f"{name:15} | {acc:.3f} | {time:.2f}s")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/examples/test_browsecomp.py b/examples/test_browsecomp.py
new file mode 100644
index 0000000000..7aaaeb4c04
--- /dev/null
+++ b/examples/test_browsecomp.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+"""
+Test script to validate BrowseComp dataset loading and decryption.
+This helps debug issues with the BrowseComp dataset.
+"""
+
+import logging
+import sys
+
+# Configure logging
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
+logger = logging.getLogger()
+
+# Add path to import local_deep_research
+sys.path.append(".")
+
+try:
+ from local_deep_research.benchmarks.datasets import decrypt, load_dataset
+except ImportError as e:
+ print(f"Error importing modules: {e}")
+ sys.exit(1)
+
+
+def test_browsecomp_decryption():
+ """Test decryption of BrowseComp dataset."""
+ print("\n=== Testing BrowseComp Decryption ===\n")
+
+ try:
+ # Load a small number of examples to test
+ examples = load_dataset("browsecomp", num_examples=3)
+
+ if not examples:
+ print("Error: No examples loaded from dataset")
+ return
+
+ print(f"Successfully loaded {len(examples)} examples from BrowseComp dataset\n")
+
+ # Check if decryption worked by examining examples
+ for i, example in enumerate(examples):
+ print(f"Example {i + 1}:")
+ print(f" ID: {example.get('id', 'unknown')}")
+
+ # Check if we have decrypted data
+ if "original_problem" in example:
+ print(" Decryption successful!")
+ print(
+ f" Original problem (encrypted): {example.get('original_problem', '')[:50]}..."
+ )
+ print(f" Decrypted problem: {example.get('problem', '')[:50]}...")
+ print(
+ f" Decrypted answer: {example.get('correct_answer', '')[:50]}..."
+ )
+ else:
+ print(" Decryption may have failed - no original_problem field")
+ print(f" Problem: {example.get('problem', '')[:50]}...")
+ print(f" Answer: {example.get('answer', '')[:50]}...")
+
+ # Try manual decryption
+ canary = example.get("canary", "")
+ if canary:
+ print("\n Attempting manual decryption...")
+ try:
+ problem = example.get("problem", "")
+ answer = example.get("answer", "")
+
+ decrypted_problem = decrypt(problem, canary)
+ decrypted_answer = decrypt(answer, canary)
+
+ print(
+ f" Manually decrypted problem: {decrypted_problem[:50]}..."
+ )
+ print(
+ f" Manually decrypted answer: {decrypted_answer[:50]}..."
+ )
+ except Exception as e:
+ print(f" Manual decryption failed: {e}")
+ else:
+ print(" No canary found for manual decryption")
+
+ print()
+
+ except Exception as e:
+ print(f"Error in test: {e}")
+
+
+def test_simpleqa_loading():
+ """Test loading of SimpleQA dataset for comparison."""
+ print("\n=== Testing SimpleQA Loading ===\n")
+
+ try:
+ # Load a small number of examples to test
+ examples = load_dataset("simpleqa", num_examples=3)
+
+ if not examples:
+ print("Error: No examples loaded from dataset")
+ return
+
+ print(f"Successfully loaded {len(examples)} examples from SimpleQA dataset\n")
+
+ # Check examples
+ for i, example in enumerate(examples):
+ print(f"Example {i + 1}:")
+ print(f" ID: {example.get('id', 'unknown')}")
+ print(f" Problem: {example.get('problem', '')[:50]}...")
+ print(f" Answer: {example.get('answer', '')[:50]}...")
+ print()
+
+ except Exception as e:
+ print(f"Error in test: {e}")
+
+
+if __name__ == "__main__":
+ # Test both datasets for comparison
+ test_browsecomp_decryption()
+ test_simpleqa_loading()