Yizhi Zhang
commited on
Commit
·
4d6c5aa
1
Parent(s):
0649cc6
fix bug of example prompt
Browse files- lightrag/operate.py +10 -0
- lightrag/prompt.py +1 -1
lightrag/operate.py
CHANGED
@@ -264,6 +264,16 @@ async def extract_entities(
|
|
264 |
else:
|
265 |
examples = "\n".join(PROMPTS["entity_extraction_examples"])
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
entity_extract_prompt = PROMPTS["entity_extraction"]
|
268 |
context_base = dict(
|
269 |
tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"],
|
|
|
264 |
else:
|
265 |
examples = "\n".join(PROMPTS["entity_extraction_examples"])
|
266 |
|
267 |
+
example_context_base = dict(
|
268 |
+
tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"],
|
269 |
+
record_delimiter=PROMPTS["DEFAULT_RECORD_DELIMITER"],
|
270 |
+
completion_delimiter=PROMPTS["DEFAULT_COMPLETION_DELIMITER"],
|
271 |
+
entity_types=",".join(PROMPTS["DEFAULT_ENTITY_TYPES"]),
|
272 |
+
language=language,
|
273 |
+
)
|
274 |
+
# add example's format
|
275 |
+
examples = examples.format(**example_context_base)
|
276 |
+
|
277 |
entity_extract_prompt = PROMPTS["entity_extraction"]
|
278 |
context_base = dict(
|
279 |
tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"],
|
lightrag/prompt.py
CHANGED
@@ -19,7 +19,7 @@ Use {language} as output language.
|
|
19 |
- entity_name: Name of the entity, use same language as input text. If English, capitalized the name.
|
20 |
- entity_type: One of the following types: [{entity_types}]
|
21 |
- entity_description: Comprehensive description of the entity's attributes and activities
|
22 |
-
Format each entity as ("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description>
|
23 |
|
24 |
2. From the entities identified in step 1, identify all pairs of (source_entity, target_entity) that are *clearly related* to each other.
|
25 |
For each pair of related entities, extract the following information:
|
|
|
19 |
- entity_name: Name of the entity, use same language as input text. If English, capitalized the name.
|
20 |
- entity_type: One of the following types: [{entity_types}]
|
21 |
- entity_description: Comprehensive description of the entity's attributes and activities
|
22 |
+
Format each entity as ("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description>)
|
23 |
|
24 |
2. From the entities identified in step 1, identify all pairs of (source_entity, target_entity) that are *clearly related* to each other.
|
25 |
For each pair of related entities, extract the following information:
|