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

Add metric_threshold argument to BootstrapFewShot #412

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

CShorten
Copy link
Collaborator

@CShorten CShorten commented Feb 19, 2024

How it currently works

In line 151 of BootstrapFewShot we currently check examples with:

success = (self.metric is None) or self.metric(example, prediction, trace)

If success == True, we then wrap the predictor, inputs, and outputs in an Example object and append it to name2traces.

This works great if you have a boolean metric, but maybe we want to extend this with a metric_threshold argument for float or int metric return types.

Metric Threshold

  • metric_threshold is added as default None

Then line 151 is replaced with:

if self.metric:
  metric_val = self.metric(example, prediction, trace)
  if self.metric_threshold:
    success = metric_val > self.metric_threshold
  else:
    success = metric_val
else:
  success = True

We can now retain the float metrics like LLM rating metrics or what have you, but also add a little more strength to find high quality examples in BootstrapFewShot.

@insop
Copy link
Contributor

insop commented Feb 19, 2024

I think this good idea for LM metric.
Is there a way to add to add description as a docstring or related markdown file?

Otherwise, LGTM.

@okhat
Copy link
Collaborator

okhat commented Feb 25, 2024

Thanks so much @CShorten ! And thanks for the review @insop !

Just converted this from > threshold to >= threshold... I think that's more intuitive? Unclear but let me know what you think!

@CShorten
Copy link
Collaborator Author

Awesome! Oops, yes much better!

@CShorten CShorten merged commit 399f654 into stanfordnlp:main Feb 26, 2024
1 check passed
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.

3 participants