Skip to content

Commit 4432d9f

Browse files
committed
Update build_ragas_data.py
1 parent b4f35b1 commit 4432d9f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

rag/chatbot/build_ragas_data.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,21 @@ def get_rag_answer(question, context, llm, chat_history, ctx_synthesis_strategy,
8989
generated_answer,retrieved_contents = get_rag_answer(anchor, positive, llm, chat_history, ctx_synthesis_strategy, index)
9090
ragas_data.append({
9191
"question": anchor,
92-
"context": positive,
92+
"reference": positive,
9393
"answer": generated_answer,
9494
"relevance": 1.0,
9595
'retrieved_contexts': retrieved_contents
9696
})
9797

98-
for anchor, negative in negative_pairs:
99-
generated_answer,retrieved_contents = get_rag_answer(anchor, negative, llm, chat_history, ctx_synthesis_strategy, index)
100-
ragas_data.append({
101-
"question": anchor,
102-
"context": negative,
103-
"answer": generated_answer,
104-
"relevance": 0.0,
105-
'retrieved_contexts': retrieved_contents
106-
})
98+
# for anchor, negative in negative_pairs:
99+
# generated_answer,retrieved_contents = get_rag_answer(anchor, negative, llm, chat_history, ctx_synthesis_strategy, index)
100+
# ragas_data.append({
101+
# "question": anchor,
102+
# "reference": anchor,
103+
# "answer": generated_answer,
104+
# "relevance": 0.0,
105+
# 'retrieved_contexts': retrieved_contents
106+
# })
107107

108108
# # JSON 파일 저장
109109
# output_path = file_path / "ragas_eval_data.json"
@@ -119,7 +119,7 @@ def get_rag_answer(question, context, llm, chat_history, ctx_synthesis_strategy,
119119
dataset = Dataset.from_list(data_list)
120120
# 🔹 RAGAS 평가 실행
121121
# dataset = Dataset.from_list(file_path / "ragas_eval_data.json")
122-
results = evaluate(dataset, metrics=[faithfulness, context_precision]) #answer_relevancy
122+
results = evaluate(dataset, metrics=[faithfulness,answer_relevancy, context_precision]) #answer_relevancy
123123

124124
print("📊 RAGAS 평가 결과:")
125125
print(results)

0 commit comments

Comments
 (0)