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: Add ContextRelevanceEvaluator component #7519

Merged
merged 7 commits into from
Apr 22, 2024
Merged

Conversation

julian-risch
Copy link
Member

@julian-risch julian-risch commented Apr 9, 2024

Related Issues

Proposed Changes:

  • Add new ContextRelevanceEvaluator component

How did you test it?

  • Added new unit tests
  • Ran the docstring example locally
  • I also ran the following example with a pipeline containing two evaluators locally:
from haystack import Pipeline
from haystack.components.evaluators import ContextRelevanceEvaluator, FaithfulnessEvaluator

pipeline = Pipeline()
context_relevance_evaluator = ContextRelevanceEvaluator()
faithfulness_evaluator = FaithfulnessEvaluator()
pipeline.add_component("context_relevance_evaluator", context_relevance_evaluator)
pipeline.add_component("faithfulness_evaluator", faithfulness_evaluator)

questions = ["Who created the Python language?"]
contexts = [
    [
        "Python, created by Guido van Rossum in the late 1980s, is a high-level general-purpose programming language. Its design philosophy emphasizes code readability, and its language constructs aim to help programmers write clear, logical code for both small and large-scale software projects."
    ],
]
responses = ["Python is a high-level general-purpose programming language that was created by George Lucas."]


result = pipeline.run(
		{
			"context_relevance_evaluator": {"questions": questions, "contexts": contexts},
	    "faithfulness_evaluator": {"questions": questions, "contexts": contexts, "responses": responses}
    }
)

for evaluator in result:
    print(result[evaluator]["individual_scores"])
# [1.0]
# [0.5]
for evaluator in result:
    print(result[evaluator]["score"])
# 1.0
# 0.5

Notes for the reviewer

Checklist

@github-actions github-actions bot added topic:tests 2.x Related to Haystack v2.0 type:documentation Improvements on the docs labels Apr 9, 2024
@julian-risch julian-risch marked this pull request as ready for review April 9, 2024 16:33
@julian-risch julian-risch requested review from a team as code owners April 9, 2024 16:33
@julian-risch julian-risch requested review from dfokina, masci and shadeMe and removed request for a team and masci April 9, 2024 16:33
@julian-risch julian-risch requested a review from shadeMe April 12, 2024 14:57
@julian-risch
Copy link
Member Author

julian-risch commented Apr 12, 2024

Hi @shadeMe I addressed all your change requests. In addition I added the new evaluator to the api reference config that was merged earlier today.
I will open a separate PR to update the FaithfulnessEvaluator. -> #7548

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 8664013887

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 90.105%

Totals Coverage Status
Change from base Build 8663731064: 0.04%
Covered Lines: 6283
Relevant Lines: 6973

💛 - Coveralls

@julian-risch julian-risch merged commit b12e0db into main Apr 22, 2024
24 checks passed
@julian-risch julian-risch deleted the context-relevance branch April 22, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 topic:eval topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom LLM-based evaluator in Haystack core
3 participants