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

python[patch]: accept simple evaluators #1200

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

Conversation

baskaryan
Copy link
Contributor

can write evaluators like this:

from langsmith import evaluate

def simp(inputs: dict, outputs: dict, reference_outputs: dict) -> dict:
    return {"results": [
        {"score": inputs == outputs, "key": 'identity'}, 
        {"score": outputs == reference_outputs, "key": "correct"}
    ]}

evaluate(
    (lambda x: x),
    data="Sample Dataset 3",
    evaluators=[simp],
)

example experiment: left-tray-86 https://dev.smith.langchain.com/public/e7782ea0-3de5-4352-8cd4-7b2cdbb03e4c/d

Copy link
Collaborator

@hinthornw hinthornw left a comment

Choose a reason for hiding this comment

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

Nice i like the start will re-review this morning

if not (
num_positional in (2, 3) or (num_positional <= 3 and has_positional_var)
):
msg = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit

python/langsmith/evaluation/evaluator.py Outdated Show resolved Hide resolved
@baskaryan baskaryan marked this pull request as ready for review November 12, 2024 01:52
@baskaryan baskaryan changed the title rfc: accept simple evaluators python[patch]: accept simple evaluators Nov 12, 2024
@@ -632,3 +636,70 @@ def comparison_evaluator(
) -> DynamicComparisonRunEvaluator:
"""Create a comaprison evaluator from a function."""
return DynamicComparisonRunEvaluator(func)


def _normalize_evaluator_func(
Copy link
Contributor

Choose a reason for hiding this comment

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

might be nice to add like a couple unit tests on this to make it obvious it's working

Copy link
Contributor

@jakerachleff jakerachleff left a comment

Choose a reason for hiding this comment

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

I think this makes sense, but would add some extra tests in to confirm it works properly

]:
# for backwards compatibility, if args are untyped we assume they correspond to
# Run and Example:
if not (type_hints := get_type_hints(func)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to add debug logs letting you know what function type is being used? Might be helpful since we tell people to enable debug logs for debugging issues in the SDK?

@hinthornw
Copy link
Collaborator

Do we want it to be like pytest where it's all by name?
run, example, inputs, predictions, reference

@baskaryan
Copy link
Contributor Author

Do we want it to be like pytest where it's all by name? run, example, inputs, predictions, reference

yea i like that. for backwards compat can't enforce run/example but can enforce the others

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