Skip to content

Nvidia Accuracy calculation code is not consistent with the docs #2000

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

Open
vitorsabbagh opened this issue Apr 8, 2025 · 3 comments · May be fixed by #2007
Open

Nvidia Accuracy calculation code is not consistent with the docs #2000

vitorsabbagh opened this issue Apr 8, 2025 · 3 comments · May be fixed by #2007
Labels
bug Something isn't working module-metrics this is part of metrics module

Comments

@vitorsabbagh
Copy link

[ x ] I have checked the documentation and related resources and couldn't resolve my bug.

Describe the bug
In the Nvidia Accuracy metric calculation, the User Answer and Reference Answer were supposed to be swapped (according to docs) in steps 1 and 2. However, it's not really swapping, as both titles and values are being swapped.

Ragas version: 0.2.14

@vitorsabbagh vitorsabbagh added the bug Something isn't working label Apr 8, 2025
@dosubot dosubot bot added the module-metrics this is part of metrics module label Apr 8, 2025
@sahusiddharth
Copy link
Collaborator

Hi @vitorsabbagh, are you just referring to the example in the docs?

the example calculation is not the best example because both the response and reference is the same.

If we look under the hood, it swapping is happening.

  1. https://github.com/explodinggradients/ragas/blob/main/src/ragas/metrics/_nv_metrics.py#L109
formatted_prompt = StringPromptValue(
                    text=self.template_accuracy1.format(
                        query=sample.user_input,
                        answer0="User Answer",
                        answer1="Reference Answer",
                        sentence_inference=sample.response,
                        sentence_true=sample.reference,
                    )
                )
  1. https://github.com/explodinggradients/ragas/blob/main/src/ragas/metrics/_nv_metrics.py#L132
                formatted_prompt = StringPromptValue(
                    text=self.template_accuracy2.format(
                        query=sample.user_input,
                        answer0="Reference Answer",
                        answer1="User Answer",
                        sentence_inference=sample.reference,
                        sentence_true=sample.response,
                    )
                )

notice answer0 and answer1 they are getting swapped.

@vitorsabbagh
Copy link
Author

Hi @sahusiddharth, you're right! However, notice that sentence_inference and sentence_true are also being swapped. It's a double swap.

@sahusiddharth
Copy link
Collaborator

Yes @vitorsabbagh, you are correct thank-you letting us know. I will raise a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module-metrics this is part of metrics module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants