-
Notifications
You must be signed in to change notification settings - Fork 649
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
AnswerCorrectness raises the AssertionError: "AssertionError: AnswerSimilarity must be set" #1336
Comments
To resolve the Here is the relevant part of the code that checks for the if self.answer_similarity is None and self.weights[1] != 0:
self.answer_similarity = AnswerSimilarity(
llm=self.llm, embeddings=self.embeddings
) Make sure that the def init(self, run_config: RunConfig):
super().init(run_config)
if self.answer_similarity is None and self.weights[1] != 0:
self.answer_similarity = AnswerSimilarity(
llm=self.llm, embeddings=self.embeddings
) Ensure that you call the Here is an example of how you might initialize and use the from ragas.run_config import RunConfig
from ragas.metrics._answer_correctness import AnswerCorrectness
# Create a RunConfig object with necessary parameters
run_config = RunConfig(llm=your_llm, embeddings=your_embeddings)
# Initialize the AnswerCorrectness metric
answer_correctness = AnswerCorrectness()
answer_correctness.init(run_config)
# Now you can use the answer_correctness metric without encountering the AssertionError Replace |
@dosu |
To resolve the Here is the relevant part of the code: def init(self, run_config: RunConfig):
super().init(run_config)
if self.answer_similarity is None and self.weights[1] != 0:
self.answer_similarity = AnswerSimilarity(
llm=self.llm, embeddings=self.embeddings
) Make sure that the Here is an example of how you might initialize and use the from ragas.run_config import RunConfig
from ragas.metrics._answer_correctness import AnswerCorrectness
# Assuming llm and embeddings are already initialized
run_config = RunConfig(llm=your_llm, embeddings=your_embeddings)
answer_correctness_metric = AnswerCorrectness()
answer_correctness_metric.init(run_config) This ensures that the |
[ ] I have checked the documentation and related resources and couldn't resolve my bug.
Hi experts,
I use the answer_correctness as the metric, but it failed due to AssertionError: "AssertionError: AnswerSimilarity must be set".
Ragas version: 0.1.16
Python version: 3.11.9
Code to Reproduce
I want to call the answer_correctness, here is the test code, and, this aserror occurs occasionally.:
Error trace
Additional context
I noticed that the AnswerSimilarity will be inited:
The text was updated successfully, but these errors were encountered: