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

Quickstart example faithfulness result showing nan #1403

Open
jinnoh47 opened this issue Oct 2, 2024 · 1 comment
Open

Quickstart example faithfulness result showing nan #1403

jinnoh47 opened this issue Oct 2, 2024 · 1 comment
Labels
module-metrics this is part of metrics module question Further information is requested

Comments

@jinnoh47
Copy link

jinnoh47 commented Oct 2, 2024

[ ] I checked the documentation and related resources and couldn't find an answer to my question.

Your Question
I just copied and paste quick start example code on my end everything is good except faithfulness it shows nan.
Is this normal?

Code Examples

from datasets import Dataset
import os
from ragas import evaluate
from ragas.metrics import faithfulness, answer_correctness

os.environ["OPENAI_API_KEY"] = "your-openai-key"

data_samples = {
'question': ['When was the first super bowl?', 'Who won the most super bowls?'],
'answer': ['The first superbowl was held on Jan 15, 1967', 'The most super bowls have been won by The New England Patriots'],
'contexts' : [['The First AFL–NFL World Championship Game was an American football game played on January 15, 1967, at the Los Angeles Memorial Coliseum in Los Angeles,'],
['The Green Bay Packers...Green Bay, Wisconsin.','The Packers compete...Football Conference']],
'ground_truth': ['The first superbowl was held on January 15, 1967', 'The New England Patriots have won the Super Bowl a record six times']
}

dataset = Dataset.from_dict(data_samples)

score = evaluate(dataset,metrics=[faithfulness,answer_correctness])
score.to_pandas()

Additional context
I'm using ragas 0.1.20 version

@jinnoh47 jinnoh47 added the question Further information is requested label Oct 2, 2024
Copy link

dosubot bot commented Oct 2, 2024

The issue of the faithfulness metric showing 'nan' in the quickstart example is likely due to no statements being generated from the answer. This can happen if the number of statements (num_statements) is zero, which results in the score being set to np.nan [1].

To resolve this, ensure that the answer is properly segmented into statements. You might need to check the sentence segmentation process to ensure it is correctly breaking down the response into simpler statements.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the module-metrics this is part of metrics module label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module-metrics this is part of metrics module question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant