Repository navigation
Conversation
A str eval_template was wrapped into a PromptTemplate and then immediately overwritten by the catalog/default template, since the isinstance check that followed ran independently of the str branch. Make the branches exclusive so a str input keeps the custom template, matching the other evaluators.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Summary
FaithfulnessEvaluatorsilently ignored a customeval_templatepassed as a plain string: the constructor wrapped it into aPromptTemplate, then immediately overwrote it with the catalog/default template.Why
The constructor used two independent
ifstatements instead ofif/elif(llama-index-core/llama_index/core/evaluation/faithfulness.py:129-137, before this change):For a
strinput, the secondisinstancecheck wasFalse, so itselsebranch replaced the just-assigned custom template withTEMPLATES_CATALOG.get(model_name, DEFAULT_EVAL_TEMPLATE). This contradicts the class docstring, which declareseval_templateasOptional[Union[str, BasePromptTemplate]](faithfulness.py:110-111), and the sibling evaluators, which already handle thestrcase correctly (e.g.evaluation/relevancy.py:67-71,evaluation/multi_modal/faithfulness.py:108-111). No existing issue covers this; found by direct inspection.Changes
elifso the three cases are exclusive:str->PromptTemplate(eval_template),BasePromptTemplate-> used as-is,None-> catalog/default lookup (unchanged).llama-index-core/tests/evaluation/test_faithfulness.pycovering all three constructor paths viaget_prompts().New Package?
Version Bump?
Type of Change
How Has This Been Tested?
Run in
llama-index-core:main:pytest tests/evaluation/test_faithfulness.py->test_faithfulness_eval_template_from_strFAILED (custom template replaced by the default template); with this change:3 passed.pytest tests/evaluation/->50 passed.make lintandmake formatat the repo root -> all hooks passed (ruff, ruff-format, mypy, codespell), no files modified.Suggested Checklist:
uv run make format; uv run make lintto appease the lint gods