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 distance threshold optimizer classes #292

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

rbs333
Copy link
Collaborator

@rbs333 rbs333 commented Feb 27, 2025

  • add base, router, and cache threshold optimizer
  • uses ranx to support eval metrics
  • class is designed to receive a optimizer class in the case where someone wants to supply their own without us having to make a release to support something custom

@tylerhutcherson tylerhutcherson changed the title Feat/raae 602/threshold optimizer Add distance threshold optimizer classes Mar 3, 2025
Copy link
Collaborator

@tylerhutcherson tylerhutcherson left a comment

Choose a reason for hiding this comment

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

Very nice! Left some of my feedback but I am pumped about this.

PRECISION = "precision"
RECALL = "recall"

def __str__(self) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think EvalMetric(str, Enum) would do the trick? See how we handle other enums in the lib

return max(metrics.items(), key=lambda x: (x[1]["score"], -x[0]))[0]


def _grid_search_opt_cache(
Copy link
Collaborator

Choose a reason for hiding this comment

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

any particular reason these aren't members of the class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My thought process is this shows that you can pass in any function that meets this definition not dependant on any class state if you wanted to go a more custom route. It's a little atypical though since it is still an internal method that doesn't really make sense to expose outside of this context.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add imports here similar to vectorizers so we can do from redisvl.utils.threshold_optimizer import CacheThresholdOptimizer

Might also consider just naming it redisvl.utils.optimize to follow the same grammar as redisvl.utils.vectorize

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