MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / evaluate_item

Function evaluate_item

evaluate_score.py:1–91  ·  view source on GitHub ↗
(i, query, answer, benchmark, tokenizer)

Source from the content-addressed store, hash-verified

1def evaluate_item(i, query, answer, benchmark, tokenizer):
2 DEEPSEEK_MODEL = "deepseek-v3-250324"
3 DEEPSEEK_URL = "xxxx"
4 client = OpenAI(api_key='xxxx',base_url=DEEPSEEK_URL)
5 sys_prompt="""
6 ---Role---
7 You are an expert tasked with evaluating answer to the question based on four criteria: **Comprehensiveness**, **Diversity**, **Directness** and **Empowerment**.
8 """
9
10 prompt = f"""
11 Your task is to evaluate the following answer based on four criteria. For each criterion, assign a score from 1 to 10 , following the detailed scoring rubric.
12
13 When explaining your score, you must refer directly to specific parts of the answer to justify your reasoning. Avoid general statements — your explanation must be grounded in the content provided.
14
15 - **Comprehensiveness**:
16 How much detail does the answer provide to cover all aspects and details of the question?
17
18 - **Diversity**:
19 How varied and rich is the answer in providing different perspectives and insights on the question?
20
21 - **Empowerment**:
22 How well does the answer help the reader understand and make informed judgments about the topic?
23
24 - **Overall Quality**:
25 Provide an overall evaluation based on the combined performance across all four dimensions. Consider both content quality and answer usefulness to the question.
26
27 Scoring Guidelines:
28
29 "1-2": "Low score description: Clearly deficient in this aspect, with significant issues.",
30 "3-4": "Below average score description: Lacking in several important areas, with noticeable problems.",
31 "5-6": "Average score description: Adequate but not exemplary, meets basic expectations with some minor issues.",
32 "7-8": "Above average score description: Generally strong but with minor shortcomings.",
33 "9-10": "High score description: Outstanding in this aspect, with no noticeable issues."
34
35 Here is the question:
36 {query}
37
38 Here are the answer:
39
40 {answer}
41
42 Evaluate the answer using the criteria listed above and provide detailed explanations for each criterion with reference to the text.
43 Output your evaluation in the following JSON format:
44
45 {{
46 "Comprehensiveness": {{
47 "score": "[1-10]",
48 "Explanation": "[Provide explanation here]"
49 }},
50 "Empowerment": {{
51 "score": "[1-10]",
52 "Explanation": "[Provide explanation here]"
53 }},
54 "Diversity": {{
55 "score": "[1-10]",
56 "Explanation": "[Provide explanation here]"
57 }},
58 "Overall Quality": {{
59 "score": "[1-10]",
60 "Explanation": "[Summarize why this answer is the overall winner based on the three criteria]"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected