Skip to content

fix faulty header of random search selector#70

Merged
finitearth merged 2 commits into
mainfrom
69-keywords-in-randomsearchselectorselect_exemplars
May 13, 2026
Merged

fix faulty header of random search selector#70
finitearth merged 2 commits into
mainfrom
69-keywords-in-randomsearchselectorselect_exemplars

Conversation

@finitearth
Copy link
Copy Markdown
Collaborator

@finitearth finitearth commented May 12, 2026

This is a fix to issue #69, which flagged that we are missing a parameter for the Random Search selector to define how many examples should be searched. Added tests for exemplar selectors.

@finitearth finitearth requested a review from mo374z as a code owner May 12, 2026 14:04
@finitearth finitearth linked an issue May 12, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e647182267

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

seq = result.sequences
prompt_with_examples = Prompt(prompt.instruction, [seq[0][0]])
seq = result.sequences[0]
examples = random.sample(list(seq), n_examples)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard against sampling more exemplars than available

random.sample(list(seq), n_examples) raises ValueError whenever the sampled subsplit has fewer items than n_examples (e.g., small datasets where len(xs) < 5, or any run with config.n_exemplars larger than the subsample size). Because BaseTask.subsample can legitimately return fewer rows than requested, this turns exemplar selection into a hard runtime failure instead of returning a best-effort prompt.

Useful? React with 👍 / 👎.

@finitearth finitearth force-pushed the 69-keywords-in-randomsearchselectorselect_exemplars branch from e647182 to de3b610 Compare May 12, 2026 14:09
@github-actions
Copy link
Copy Markdown

Coverage

Tests Skipped Failures Errors Time
131 0 💤 0 ❌ 0 🔥 2.067s ⏱️

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #69 by updating RandomSearchSelector.select_exemplars() to accept an n_examples parameter, and adds regression/unit tests around exemplar selector behavior. It also updates the README coverage badge.

Changes:

  • Add n_examples parameter to RandomSearchSelector.select_exemplars() and update selection logic to pick multiple exemplars.
  • Add new test suite for exemplar selectors, including regression coverage for the n_examples keyword argument.
  • Update README coverage badge from 95% to 96%.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
promptolution/exemplar_selectors/random_search_selector.py Fix selector API to accept n_examples and sample multiple exemplars per trial.
tests/exemplar_selectors/test_exemplar_selectors.py Add tests validating exemplar selection size, best-trial behavior, and regression for n_examples kwarg.
README.md Update coverage badge percentage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 30 to 32
best_score = 0.0
best_prompt = prompt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finitearth I guess this is a valid point, but probably not the only place where we set it like that? not sure if we have to talk about optimization conventions in general throughout promptolution

Comment on lines +35 to +36
seq = result.sequences[0]
examples = random.sample(list(seq), n_examples)
Comment thread promptolution/exemplar_selectors/random_search_selector.py
@finitearth finitearth merged commit d6e5e17 into main May 13, 2026
4 checks passed
@finitearth finitearth deleted the 69-keywords-in-randomsearchselectorselect_exemplars branch May 13, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

keywords in RandomSearchSelector.select_exemplars()

4 participants