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

feat: Enable explanations even w/o explanation template #6190

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

Conversation

anticorrelator
Copy link
Contributor

  • Previously, when passing in a custom template string to llm_classify, provide_explanation doesn't do anything unless a user uses a custom ClassificationTemplate object
  • This PR will append another part to the template that adds an instruction to explain itself

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 28, 2025
Copy link
Contributor

@mikeldking mikeldking 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 we need to be a bit careful here, just adding text at the end forces us to be in charge of building the prompt - which might not be ideal in varying scenarios (different types of models, maybe the template already has system instructions to do this etc.).

Comment on lines +263 to +267
patched_explanation_template_text = (
"*****\n\n"
"After following the previous instructions, add a paragraph that starts with "
"`EXPLANATION: ` and then provide a concise explanation of your reasoning."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

how do we know that the original template doesn't contain this instruction? I think there might be downsides to the fact that now the template is not declarative but constructed inside of the function itself?

The scenario I'm worried about is that Arize is now trying to build templates that are "evaluation" templates. Depending on how you pass it into this, the explanation postfix will now get added (possibly twice).

We should probably be careful here so I'm gonna block for now just to make sure we don't break any workflows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the postfix only gets added if the explanation template isn't provided, it's just fallback behavior

@anticorrelator
Copy link
Contributor Author

@mikeldking yeah we just don't know which is why we didn't implement something like this before. I wanted to just sketch this out in case we think on balance it's worth not simply failing out for custom templates passed to llm_classify as a string. In those cases if users also pass in provide_explanation the results will almost always be NOT_PARSEABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: 👍 Approved
Development

Successfully merging this pull request may close these issues.

2 participants