Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer optimizer #7261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Infer optimizer #7261

wants to merge 1 commit into from

Conversation

arnavsinghvi11
Copy link
Collaborator

BootstrapFewShot defines the behavior behind the "how" in few-shot example selection by differentiating examples and selecting those that meet the metric criteria as "passing examples" in the optimized prompt.

BootstrapInfer takes a next step in exploring the "why" by inducing learned rules from the selected few-shot examples and adding supplementary guidance within the optimized prompt. The optimizer explores various sets of complementary rules + fewshot example combinations, and outputs a final optimal prompt with the original DSPy program instruction, selected few-shot examples and additional natural language rules to guide the task.

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a comment

Choose a reason for hiding this comment

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

@arnavsinghvi11 Interesting one! A few high-level comments:

  • could you install ruff, and enable vscode/cursor auto formatting with ruff? There are many lint issues, but most of them can be automatically resolved.
  • can we add some explanation on this optimizer with code examples? With a quick scan, I am wondering if this optimizer is only suitable for use cases where there are strong patterns.

from dspy.evaluate.evaluate import Evaluate
import dspy

class BootstrapFewShotInfer(BootstrapFewShot):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add docstring to explain what this optimizer do? like what's the key improvement from BTFS, and when this optimizer should be used.

score, _ = evaluate(program, metric=self.metric)
return score

class RulesInductionProgram(dspy.Module):
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe just call this RuleExtractor?

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.

2 participants