Skip to content

Commit 6abbe40

Browse files
lkk12014402root
andauthored
fix issue because of ragas change. (#111)
Co-authored-by: root <[email protected]>
1 parent 65a0a5b commit 6abbe40

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

evals/evaluation/rag_eval/examples/eval_multihop.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,18 @@ def evaluate(self, all_queries, arguments):
137137
return overall
138138

139139
def get_ragas_metrics(self, all_queries, arguments):
140-
from langchain_community.embeddings import HuggingFaceHubEmbeddings
140+
from langchain_huggingface import HuggingFaceEndpointEmbeddings
141+
142+
embeddings = HuggingFaceEndpointEmbeddings(model=arguments.embedding_endpoint)
141143

142-
embeddings = HuggingFaceHubEmbeddings(model=arguments.embedding_endpoint)
143144
metric = RagasMetric(threshold=0.5, model=arguments.llm_endpoint, embeddings=embeddings)
144145
all_answer_relevancy = 0
145146
all_faithfulness = 0
146147
ragas_inputs = {
147-
"input": [],
148-
"actual_output": [],
149-
"expected_output": [],
150-
"retrieval_context": [],
148+
"question": [],
149+
"answer": [],
150+
"ground_truth": [],
151+
"contexts": [],
151152
}
152153

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

160-
ragas_inputs["input"].append(data["query"])
161-
ragas_inputs["actual_output"].append(generated_text)
162-
ragas_inputs["expected_output"].append(data["answer"])
163-
ragas_inputs["retrieval_context"].append(retrieved_documents[:3])
161+
ragas_inputs["question"].append(data["query"])
162+
ragas_inputs["answer"].append(generated_text)
163+
ragas_inputs["ground_truth"].append(data["answer"])
164+
ragas_inputs["contexts"].append(retrieved_documents[:3])
164165

165166
ragas_metrics = metric.measure(ragas_inputs)
166167
return ragas_metrics

0 commit comments

Comments
 (0)