Skip to content

Commit

Permalink
fix issue because of ragas change. (#111)
Browse files Browse the repository at this point in the history
Co-authored-by: root <[email protected]>
  • Loading branch information
lkk12014402 and root authored Sep 6, 2024
1 parent 65a0a5b commit 6abbe40
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions evals/evaluation/rag_eval/examples/eval_multihop.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,18 @@ def evaluate(self, all_queries, arguments):
return overall

def get_ragas_metrics(self, all_queries, arguments):
from langchain_community.embeddings import HuggingFaceHubEmbeddings
from langchain_huggingface import HuggingFaceEndpointEmbeddings

embeddings = HuggingFaceEndpointEmbeddings(model=arguments.embedding_endpoint)

embeddings = HuggingFaceHubEmbeddings(model=arguments.embedding_endpoint)
metric = RagasMetric(threshold=0.5, model=arguments.llm_endpoint, embeddings=embeddings)
all_answer_relevancy = 0
all_faithfulness = 0
ragas_inputs = {
"input": [],
"actual_output": [],
"expected_output": [],
"retrieval_context": [],
"question": [],
"answer": [],
"ground_truth": [],
"contexts": [],
}

for data in tqdm(all_queries):
Expand All @@ -157,10 +158,10 @@ def get_ragas_metrics(self, all_queries, arguments):
generated_text = self.send_request(data, arguments)
data["generated_text"] = generated_text

ragas_inputs["input"].append(data["query"])
ragas_inputs["actual_output"].append(generated_text)
ragas_inputs["expected_output"].append(data["answer"])
ragas_inputs["retrieval_context"].append(retrieved_documents[:3])
ragas_inputs["question"].append(data["query"])
ragas_inputs["answer"].append(generated_text)
ragas_inputs["ground_truth"].append(data["answer"])
ragas_inputs["contexts"].append(retrieved_documents[:3])

ragas_metrics = metric.measure(ragas_inputs)
return ragas_metrics
Expand Down

0 comments on commit 6abbe40

Please sign in to comment.