Skip to content

ModuleNotFoundError: No module named 'ragas.langchain' #571

Open
@xinyang-handalindah

Description

@xinyang-handalindah

Description of the bug
Using Google Colab. After running !pip install ragas, unable to import RagasEvaluatorChain from ragas.langchain.evalchain.
It was okay last week (v0.0.22).

Ragas version: 0.1.0
Python version: 3.10.12

Code to Reproduce

from ragas.langchain.evalchain import RagasEvaluatorChain
from ragas.metrics import AnswerCorrectness

from ragas.metrics import (
    faithfulness,
    context_precision,
    context_recall
)

# Customise the weight of answer_correctness
answer_correctness = AnswerCorrectness(
    weights = [0.1, 0.9] # 10% factuality and 90% semantic similarity check.
)

def ragas_eval(result):
  """
  Define a chain to evaluate the result in terms of:
  - faithfulness
  - answer correctness
  - context precision
  - context recall

  Then, return the scores.

  """
  metrics = [faithfulness, answer_correctness,
             context_precision, context_recall]
  scores = {}

  for m in metrics:
    eval_result = RagasEvaluatorChain(metric=m)(result)
    scores[f"{m.name}_score"] = round(eval_result[m.name+'_score'],2)
  return scores

Error trace

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-13-d21d7383e19b>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from ragas.langchain import RagasEvaluatorChain
      2 from ragas.metrics import AnswerCorrectness
      3 
      4 from ragas.metrics import (
      5     faithfulness,

ModuleNotFoundError: No module named 'ragas.langchain'

Expected behavior
Last Week I was still able to import the "RagasEvaluatorChain" from ragas.langchain.evalchain, but encounter this error today.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions