From 94114df995af92576e3a4105834fed5928239c3f Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 4 Sep 2025 14:53:27 +0800 Subject: [PATCH] Improve prompt clarity and structure --- lightrag/prompt.py | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/lightrag/prompt.py b/lightrag/prompt.py index e5fe8aba..d32132b7 100644 --- a/lightrag/prompt.py +++ b/lightrag/prompt.py @@ -11,7 +11,7 @@ PROMPTS["DEFAULT_COMPLETION_DELIMITER"] = "<|COMPLETE|>" PROMPTS["DEFAULT_USER_PROMPT"] = "n/a" PROMPTS["entity_extraction"] = """---Task--- -Given a text document and a list of entity types, identify all entities of those types and all relationships among the identified entities. +For a given text and a list of entity types, extract all entities and their relationships, then return them in the specified {language} and format described below. ---Instructions--- 1. Recognizing definitively conceptualized entities in text. For each identified entity, extract the following information: @@ -49,6 +49,19 @@ Text: ---Output--- """ +PROMPTS["entity_continue_extraction"] = """---Task--- +Identify any missed entities or relationships in the last extraction task. + +---Instructions--- +1. Output the entities and realtionships in the same format as previous extraction task. +2. Do not include entities and relations that have been previously extracted. +3. If the entity doesn't clearly fit in any of`Entity_types` provided, classify it as "Other". +4. Return identified entities and relationships in {language}. +5. Output `{completion_delimiter}` when all the entities and relationships are extracted. + +---Output--- +""" + PROMPTS["entity_extraction_examples"] = [ """[Example 1] @@ -180,28 +193,6 @@ Description List: ---Output--- """ -PROMPTS["entity_continue_extraction"] = """---Task--- -Identify any missed entities or relationships in the last extraction task. - ----Instructions--- -1. Output the entities and realtionships in the same format as previous extraction task. -2. Do not include entities and relations that have been previously extracted. -3. If the entity doesn't clearly fit in any of`Entity_types` provided, classify it as "Other". -4. Return identified entities and relationships in {language}. -5. Output `{completion_delimiter}` when all the entities and relationships are extracted. - ----Output--- -""" - -# TODO: Deprecated -PROMPTS["entity_if_loop_extraction"] = """ ----Goal---' - -Check if it appears some entities may have still been missed. Output "Yes" if so, otherwise "No". - ----Output--- -Output:""" - PROMPTS["fail_response"] = ( "Sorry, I'm not able to provide an answer to that question.[no-context]" )