MCPcopy Create free account
hub / github.com/InternScience/InternAgent / evaluate_dataset

Function evaluate_dataset

tasks/AutoMem/run_0/code/eval.py:352–523  ·  view source on GitHub ↗

Evaluate the agent on the LoComo dataset with parallel processing. Args: dataset_path: Path to the dataset file model: Name of the model to use output_path: Path to save results ratio: Ratio of dataset to evaluate backend: Backend to use (openai, ollama,

(dataset_path: str, model: str, output_path: Optional[str] = None,
                    ratio: float = 1.0, backend: str = "sglang", temperature_c5: float = 0.5,
                    retrieve_k: int = 10, sglang_host: str = "http://localhost",
                    sglang_port: int = 30000, num_workers: int = 4, out_dir: Optional[str] = None)

Source from the content-addressed store, hash-verified

350 }
351
352def evaluate_dataset(dataset_path: str, model: str, output_path: Optional[str] = None,
353 ratio: float = 1.0, backend: str = "sglang", temperature_c5: float = 0.5,
354 retrieve_k: int = 10, sglang_host: str = "http://localhost",
355 sglang_port: int = 30000, num_workers: int = 4, out_dir: Optional[str] = None) -> dict:
356 """Evaluate the agent on the LoComo dataset with parallel processing.
357
358 Args:
359 dataset_path: Path to the dataset file
360 model: Name of the model to use
361 output_path: Path to save results
362 ratio: Ratio of dataset to evaluate
363 backend: Backend to use (openai, ollama, sglang)
364 temperature_c5: Temperature for category 5 questions
365 retrieve_k: Number of memories to retrieve
366 sglang_host: SGLang server host
367 sglang_port: SGLang server port
368 num_workers: Number of parallel workers
369 """
370 # Generate automatic log filename with timestamp
371 timestamp = datetime.now().strftime("%Y-%m-%d-%H-%M")
372 log_filename = f"eval_ours_{model}_{backend}_ratio{ratio}_parallel_{timestamp}.log"
373 log_path = os.path.join(os.path.dirname(__file__), "logs", log_filename)
374
375 # Create logs directory if it doesn't exist
376 os.makedirs(os.path.dirname(log_path), exist_ok=True)
377
378 logger = setup_logger(log_path)
379 logger.info(f"Loading dataset from {dataset_path}")
380
381 # Load dataset
382 samples = load_locomo_dataset(dataset_path)
383 logger.info(f"Loaded {len(samples)} samples")
384
385 # Select subset of samples based on ratio
386 if ratio < 1.0:
387 num_samples = max(1, int(len(samples) * ratio))
388 samples = samples[:num_samples]
389 logger.info(f"Using {num_samples} samples ({ratio*100:.1f}% of dataset)")
390
391 # Create memories directory
392 memories_dir = os.path.join(
393 os.path.dirname(__file__),
394 f"cached_memories_advanced_{backend}_{model}"
395 )
396 os.makedirs(memories_dir, exist_ok=True)
397
398 allow_categories = [1, 2, 3, 4, 5]
399
400 # Prepare sample data for parallel processing
401 sample_data_list = [(idx, sample) for idx, sample in enumerate(samples)]
402
403 logger.info(f"Starting parallel processing with {num_workers} workers")
404
405 # Use partial to fix the constant arguments
406 process_func = partial(
407 process_single_sample,
408 model=model,
409 backend=backend,

Callers 1

mainFunction · 0.70

Calls 6

load_locomo_datasetFunction · 0.90
aggregate_metricsFunction · 0.90
setup_loggerFunction · 0.70
closeMethod · 0.45
itemsMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected