Merge pull request #384 from Ecocytus/main

fix examples' prompt bug
This commit is contained in:
zrguo
2024-12-04 11:17:07 +08:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -264,6 +264,16 @@ async def extract_entities(
else: else:
examples = "\n".join(PROMPTS["entity_extraction_examples"]) examples = "\n".join(PROMPTS["entity_extraction_examples"])
example_context_base = dict(
tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"],
record_delimiter=PROMPTS["DEFAULT_RECORD_DELIMITER"],
completion_delimiter=PROMPTS["DEFAULT_COMPLETION_DELIMITER"],
entity_types=",".join(PROMPTS["DEFAULT_ENTITY_TYPES"]),
language=language,
)
# add example's format
examples = examples.format(**example_context_base)
entity_extract_prompt = PROMPTS["entity_extraction"] entity_extract_prompt = PROMPTS["entity_extraction"]
context_base = dict( context_base = dict(
tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"], tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"],

View File

@@ -19,7 +19,7 @@ Use {language} as output language.
- entity_name: Name of the entity, use same language as input text. If English, capitalized the name. - entity_name: Name of the entity, use same language as input text. If English, capitalized the name.
- entity_type: One of the following types: [{entity_types}] - entity_type: One of the following types: [{entity_types}]
- entity_description: Comprehensive description of the entity's attributes and activities - entity_description: Comprehensive description of the entity's attributes and activities
Format each entity as ("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description> Format each entity as ("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description>)
2. From the entities identified in step 1, identify all pairs of (source_entity, target_entity) that are *clearly related* to each other. 2. From the entities identified in step 1, identify all pairs of (source_entity, target_entity) that are *clearly related* to each other.
For each pair of related entities, extract the following information: For each pair of related entities, extract the following information: