diff --git a/lightrag/operate.py b/lightrag/operate.py
index c6724974..dd323557 100644
--- a/lightrag/operate.py
+++ b/lightrag/operate.py
@@ -2832,9 +2832,11 @@ async def extract_entities(
cache_keys_collector = []
# Get initial extraction
+ # Format system prompt without input_text for each chunk (enables OpenAI prompt caching across chunks)
entity_extraction_system_prompt = PROMPTS[
"entity_extraction_system_prompt"
- ].format(**{**context_base, "input_text": content})
+ ].format(**context_base)
+ # Format user prompts with input_text for each chunk
entity_extraction_user_prompt = PROMPTS["entity_extraction_user_prompt"].format(
**{**context_base, "input_text": content}
)
diff --git a/lightrag/prompt.py b/lightrag/prompt.py
index bf514fe8..6230197b 100644
--- a/lightrag/prompt.py
+++ b/lightrag/prompt.py
@@ -58,18 +58,10 @@ You are a Knowledge Graph Specialist responsible for extracting entities and rel
---Examples---
{examples}
-
----Real Data to be Processed---
-
-Entity_types: [{entity_types}]
-Text:
-```
-{input_text}
-```
"""
PROMPTS["entity_extraction_user_prompt"] = """---Task---
-Extract entities and relationships from the input text to be processed.
+Extract entities and relationships from the input text in Data to be Processed below.
---Instructions---
1. **Strict Adherence to Format:** Strictly adhere to all format requirements for entity and relationship lists, including output order, field delimiters, and proper noun handling, as specified in the system prompt.
@@ -77,6 +69,15 @@ Extract entities and relationships from the input text to be processed.
3. **Completion Signal:** Output `{completion_delimiter}` as the final line after all relevant entities and relationships have been extracted and presented.
4. **Output Language:** Ensure the output language is {language}. Proper nouns (e.g., personal names, place names, organization names) must be kept in their original language and not translated.
+---Data to be Processed---
+
+[{entity_types}]
+
+
+```
+{input_text}
+```
+