Skip to content

Commit 8fb95a6

Browse files
Fix/community report tuning (#1909)
* Fix community report prompt tuning * Semver * Format ...
1 parent 8c81cc1 commit 8fb95a6

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "Fix Community Report prompt tuning response"
4+
}

graphrag/prompt_tune/generator/entity_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ async def generate_entity_types(
4747

4848
if json_mode:
4949
response = await model.achat(
50-
entity_types_prompt, history=history, json_model=EntityTypesResponse
50+
entity_types_prompt,
51+
history=history,
52+
json=json_mode,
53+
json_model=EntityTypesResponse,
5154
)
5255
parsed_model = response.parsed_response
5356
return parsed_model.entity_types if parsed_model else []

graphrag/prompt_tune/prompt/entity_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@
8484
REAL DATA: The following section is the real data. You should use only this real data to prepare your answer. Generate Entity Types only.
8585
Task: {task}
8686
Text: {input_text}
87-
JSON response:
87+
JSON response format:
8888
{{"entity_types": [<entity_types>] }}
8989
"""

graphrag/prompt_tune/prompt/language.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DETECT_LANGUAGE_PROMPT = """
77
You are an intelligent assistant that helps a human to analyze the information in a text document.
88
Given a sample text, help the user by determining what's the primary language of the provided texts.
9-
Examples are: "English", "Spanish", "Japanese", "Portuguese" among others.
9+
Examples are: "English", "Spanish", "Japanese", "Portuguese" among others. Reply ONLY with the language name.
1010
1111
Text: {input_text}
1212
Language:"""

graphrag/prompt_tune/template/community_report_summarization.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
- DETAILED FINDINGS: A list of 5-10 key insights about the community. Each insight should have a short summary followed by multiple paragraphs of explanatory text grounded according to the grounding rules below. Be comprehensive.
1919
2020
Return output as a well-formed JSON-formatted string with the following format. Don't use any unnecessary escape sequences. The output should be a single JSON object that can be parsed by json.loads.
21-
{{
21+
{{{{
2222
"title": <report_title>,
2323
"summary": <executive_summary>,
2424
"rating": <impact_severity_rating>,
2525
"rating_explanation": <rating_explanation>,
2626
"findings": [
27-
{{
27+
{{{{
2828
"summary":<insight_1_summary>,
2929
"explanation": <insight_1_explanation>
30-
}},
31-
{{
30+
}}}},
31+
{{{{
3232
"summary":<insight_2_summary>,
3333
"explanation": <insight_2_explanation>
34-
}}
34+
}}}}
3535
]
36-
}}
36+
}}}}
3737
3838
# Grounding Rules
3939
Points supported by data should list their data references as follows:
@@ -48,6 +48,7 @@
4848
where 1, 5, 7, 23, 2, 34, 46, and 64 represent the id (not the index) of the relevant data record.
4949
5050
Do not include information where the supporting evidence for it is not provided.
51+
Your answers should be in {language}.
5152
5253
# Example Input
5354
-----------
@@ -70,30 +71,30 @@
7071
43,HARMONY ASSEMBLY,UNITY MARCH,Harmony Assembly is organizing the Unity March
7172
7273
Output:
73-
{{
74+
{{{{
7475
"title": "Verdant Oasis Plaza and Unity March",
7576
"summary": "The community revolves around the Verdant Oasis Plaza, which is the location of the Unity March. The plaza has relationships with the Harmony Assembly, Unity March, and Tribune Spotlight, all of which are associated with the march event.",
7677
"rating": 5.0,
7778
"rating_explanation": "The impact severity rating is moderate due to the potential for unrest or conflict during the Unity March.",
7879
"findings": [
79-
{{
80+
{{{{
8081
"summary": "Verdant Oasis Plaza as the central location",
8182
"explanation": "Verdant Oasis Plaza is the central entity in this community, serving as the location for the Unity March. This plaza is the common link between all other entities, suggesting its significance in the community. The plaza's association with the march could potentially lead to issues such as public disorder or conflict, depending on the nature of the march and the reactions it provokes. [Data: Entities (5), Relationships (37, 38, 39, 40, 41,+more)]"
82-
}},
83-
{{
83+
}}}},
84+
{{{{
8485
"summary": "Harmony Assembly's role in the community",
8586
"explanation": "Harmony Assembly is another key entity in this community, being the organizer of the march at Verdant Oasis Plaza. The nature of Harmony Assembly and its march could be a potential source of threat, depending on their objectives and the reactions they provoke. The relationship between Harmony Assembly and the plaza is crucial in understanding the dynamics of this community. [Data: Entities(6), Relationships (38, 43)]"
86-
}},
87-
{{
87+
}}}},
88+
{{{{
8889
"summary": "Unity March as a significant event",
8990
"explanation": "The Unity March is a significant event taking place at Verdant Oasis Plaza. This event is a key factor in the community's dynamics and could be a potential source of threat, depending on the nature of the march and the reactions it provokes. The relationship between the march and the plaza is crucial in understanding the dynamics of this community. [Data: Relationships (39)]"
90-
}},
91-
{{
91+
}}}},
92+
{{{{
9293
"summary": "Role of Tribune Spotlight",
9394
"explanation": "Tribune Spotlight is reporting on the Unity March taking place in Verdant Oasis Plaza. This suggests that the event has attracted media attention, which could amplify its impact on the community. The role of Tribune Spotlight could be significant in shaping public perception of the event and the entities involved. [Data: Relationships (40)]"
94-
}}
95+
}}}}
9596
]
96-
}}
97+
}}}}
9798
9899
# Real Data
99100

0 commit comments

Comments
 (0)