galapagos
DocsHubLeaderboardPlaygroundNews
galapagos

six blocks · any task ·
better solutions emerge.

Platform

  • Hub
  • Leaderboard
  • Playground

Resources

  • Docs
  • API reference
  • Card spec

Community

  • GitHub
  • Contribute

Updates

  • News
  • Releases

© 2026 Galapagos. Licensed under Apache-2.0.

Build your own scaffold.

Hub/Scaffolds/default/Best-of-N

default/best_of_n

Best-of-N

Give the LLM N valid attempts at the same parent before committing to the global best, then repeat.

Test-time searchApache-2.0
Scaffold cardFiles and versions
best_of_n/population.py
18 lines · 954 BpythonDownload
"""Best-of-N Population component — a keep-all archive sorted by combined_score.

One file per component (see scaffold.py). SkyDiscover's ``BestOfNDatabase`` stores every program and
re-derives the global best on demand; the parent-reuse logic itself lives in the SelectionPolicy.
"""
from __future__ import annotations

from ...components.population import InMemoryPopulation


class BestOfNPopulation(InMemoryPopulation):
    """SkyDiscover ``BestOfNDatabase`` store: keep-all, fitness-sorted. Used both to find the current
    global best (when the parent-reuse budget is spent) and to draw the fresh context sample."""

    def __init__(self, capacity: int | None = None):
        # None = uncapped; drop_invalid mirrors SkyDiscover skipping database.add() on result.error, so a
        # failed attempt never enters the pool (the reuse counter, advanced in observe(), is unaffected).
        super().__init__(capacity=capacity, drop_invalid=True)