Change delimiter from <|S|> to <|#|> and clarify formatting rules

This commit is contained in:
yangdx 2025-09-13 22:58:56 +08:00
parent 41cdeaeaad
commit 4a5ab5121d

View file

@ -5,7 +5,7 @@ from typing import Any
PROMPTS: dict[str, Any] = {}
# All delimiters must be formatted as "<|UPPER_CASE_STRING|>"
PROMPTS["DEFAULT_TUPLE_DELIMITER"] = "<|S|>"
PROMPTS["DEFAULT_TUPLE_DELIMITER"] = "<|#|>"
PROMPTS["DEFAULT_COMPLETION_DELIMITER"] = "<|COMPLETE|>"
PROMPTS["DEFAULT_USER_PROMPT"] = "n/a"
@ -23,13 +23,14 @@ You are a Knowledge Graph Specialist responsible for extracting entities and rel
- target_entity: Name of the target entity. If the entity name is case-insensitive, capitalize the first letter of each word in the entity name. Use consistency names in entity extraction stage.
- relationship_keywords: one or more high-level keywords that summarize the overarching nature of the relationship, focusing on concepts or themes rather than specific details.
- relationship_description: Explain the nature of the relationship between the source and target entities, providing a clear rationale for their connection.
3. Keep Full Context: Ensure the entity name and description are writtenin third person, explicitly name the subject or object instead of using pronouns; avoid pronouns such as `this article`, `this paper`, `our company`, `I`, `you`, and `he/she`.
4. Output Each Entity On A Single Line: Output 4 fields delimited by `{tuple_delimiter}`, adhering to the following format: entity{tuple_delimiter}entity_name{tuple_delimiter}entity_type{tuple_delimiter}entity_description
5. Output Each Relationship On A Single Line: Output 5 fields delimited by `{tuple_delimiter}`, adhering to the following format: relationship{tuple_delimiter}source_entity{tuple_delimiter}target_entity{tuple_delimiter}relationship_keywords{tuple_delimiter}relationship_description
6. Output Order: Output the entity list first, followed by the relationship list. Within the relationship list, prioritize relationships based on their significance to the intended meaning of the input text, outputting more crucial relationships first.
7. Undirected Relationship: Treat relationships as undirected; swapping the source and target entities does not constitute a new relationship. Avoid outputting duplicate relationships.
8. Language: Ensure the output language of entity names, keywords, and descriptions is {language}. Proper nouns (e.g., personal names, place names, organization names) may in their original language if proper translation is not available.
9. Output `{completion_delimiter}` when all the entities and relationships have been extracted.
3. Output Each Entity On A Single Line: Output 4 fields delimited by `{tuple_delimiter}`, adhering to the following format: entity{tuple_delimiter}entity_name{tuple_delimiter}entity_type{tuple_delimiter}entity_description
4. Output Each Relationship On A Single Line: Output 5 fields delimited by `{tuple_delimiter}`, adhering to the following format: relationship{tuple_delimiter}source_entity{tuple_delimiter}target_entity{tuple_delimiter}relationship_keywords{tuple_delimiter}relationship_description
5. Crucial Delimiter Rule: The `{tuple_delimiter}` is a complete, atomic marker and must not be filled with content. For example, do NOT output `entity{tuple_delimiter}Tokyo<|location|>Tokyo is the capital of Japan.`. The correct format is `entity{tuple_delimiter}Tokyo{tuple_delimiter}location{tuple_delimiter}Tokyo is the capital of Japan.`
6. Undirected Relationship: Treat relationships as undirected; swapping the source and target entities does not constitute a new relationship. Avoid outputting duplicate relationships.
7. Output Order: Output the entity list first, followed by the relationship list. Within the relationship list, prioritize relationships based on their significance to the intended meaning of the input text, outputting more crucial relationships first.
8. Keep Full Context: Ensure the entity name and description are writtenin third person, explicitly name the subject or object instead of using pronouns; avoid pronouns such as `this article`, `this paper`, `our company`, `I`, `you`, and `he/she`.
9. Language: Ensure the output language of entity names, keywords, and descriptions is {language}. Proper nouns (e.g., personal names, place names, organization names) may in their original language if proper translation is not available.
10. Output `{completion_delimiter}` when all the entities and relationships have been extracted.
---Examples---
{examples}