Optionally expose feedback from RelevancyEvaluator #5147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
The RelevancyEvaluator is a black box at the moment, which evaluates the content without providing any explanation about why it came to such conclusion. Furthermore the code relies on dated method of forcing the LLM to respond in a structured manner without using the spring-ai's structured output option.
Solution:
Modify the RelevancyEvaluator in a backwards compatible way to offer a new
feedbackEnabled(boolean feedbackEnabled)method in theBuilder, which would enable the evaluator to use structured output with a response type that offer both the answer, and the accompanying reasoning behind it.The reasoning is then mapped to
EvaluationResponse's existingfeedbackfield, which was currently unused and always left as an empty String.The existing solution is kept working by default so that the change would not break existing flows or change the nature of the LLM calls, potentially disrupting token usage and bias in the prompt.
Additional notes
FactCheckingEvaluator faces a similar problem, but I didn't want to change it unless the method is validated by the maintainers as useful and worth doing.
Example request body, when
feedbackEnabledis set true.