@@ -137,17 +137,18 @@ def evaluate(self, all_queries, arguments):
137
137
return overall
138
138
139
139
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 )
141
143
142
- embeddings = HuggingFaceHubEmbeddings (model = arguments .embedding_endpoint )
143
144
metric = RagasMetric (threshold = 0.5 , model = arguments .llm_endpoint , embeddings = embeddings )
144
145
all_answer_relevancy = 0
145
146
all_faithfulness = 0
146
147
ragas_inputs = {
147
- "input " : [],
148
- "actual_output " : [],
149
- "expected_output " : [],
150
- "retrieval_context " : [],
148
+ "question " : [],
149
+ "answer " : [],
150
+ "ground_truth " : [],
151
+ "contexts " : [],
151
152
}
152
153
153
154
for data in tqdm (all_queries ):
@@ -157,10 +158,10 @@ def get_ragas_metrics(self, all_queries, arguments):
157
158
generated_text = self .send_request (data , arguments )
158
159
data ["generated_text" ] = generated_text
159
160
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 ])
164
165
165
166
ragas_metrics = metric .measure (ragas_inputs )
166
167
return ragas_metrics
0 commit comments