Repository: explodinggradients/ragas
Issue: The metric NoiseSensitivity always timeout
Root cause: Resource Mishandling

[ ] I checked the [documentation](https://docs.ragas.io/) and related resources and couldn't find an answer to my question.

**Your Question**
﻿﻿When calculating the metirc 'NoiseSensitivity', it reports a timeout

![Image](https://github.com/user-attachments/assets/a3b64cbc-7c5c-41fb-a22a-ab34c189f6f6)


**Code Examples**
`llm = ChatOpenAI(
      openai_api_key=llm_config['openai_api_key'],
      base_url=llm_config['base_url'],
      request_timeout=3000000
  )`


**Additional context**
I see gt_statements and ans_statements are generated normally
`gt_statements = await self._decompose_answer_into_statements(
      row["reference"], row["user_input"], callbacks
  )
  ans_statements = await self._decompose_answer_into_statements(
      row["response"], row["user_input"], callbacks
  )`

but while executing the following code, it was not completed. The length of row ["retrieved_cexts"] is 10, and I noticed that the log was only executed up to 4 times. Theoretically, it should have been executed 20 times
`        for ctx in row["retrieved_contexts"]:
            verdicts = await self._evaluate_statement_faithfulness(
                gt_statements, ctx, callbacks
            )
            gt_verdictslist.append(np.array(verdicts))

            verdicts = await self._evaluate_statement_faithfulness(
                ans_statements, ctx, callbacks
            )
            ans_verdictslist.append(np.array(verdicts))`


The overall code is as follows：
`    async def _ascore(self, row: t.Dict, callbacks: Callbacks) -> float:
        """
        returns the NLI score for each (q, c, a) pair
        """
        assert self.llm is not None, "LLM is not set"

        gt_statements = await self._decompose_answer_into_statements(
            row["reference"], row["user_input"], callbacks
        )
        ans_statements = await self._decompose_answer_into_statements(
            row["response"], row["user_input"], callbacks
        )
        gt_verdictslist = []
        ans_verdictslist = []

        for ctx in row["retrieved_contexts"]:
            verdicts = await self._evaluate_statement_faithfulness(
                gt_statements, ctx, callbacks
            )
            gt_verdictslist.append(np.array(verdicts))

            verdicts = await self._evaluate_statement_faithfulness(
                ans_statements, ctx, callbacks
            )
            ans_verdictslist.append(np.array(verdicts))

        answers = {}
        answers["retrieved2ground_truth"] = np.array(gt_verdictslist).T
        answers["retrieved2answer"] = np.array(ans_verdictslist).T
        answers["ground_truth2answer"] = np.array(
            await self._evaluate_statement_faithfulness(
                ans_statements, row["reference"], callbacks
            )
        )
        answers["ground_truth2answer"] = np.array([answers["ground_truth2answer"]])
        answers = {k: v.astype(bool) for k, v in answers.items()}
        return self._compute_score(answers)`




Is there any update on this issue? I got the same one.

> Is there any update on this issue? I got the same one.

Did you try the new metrics collections? The legacy metrics are being deprecated.