entity_resolution_prompt.py
Overview
This file defines a single constant string, ENTITY_RESOLUTION_PROMPT, which serves as a templated prompt for use in natural language processing (NLP) tasks related to entity resolution. Entity resolution involves determining whether two references (e.g., product names, place names) refer to the same real-world entity.
The prompt is designed to instruct an AI or language model to:
Identify individual questions within a text.
Answer each question by comparing two entities (e.g., "Product A" vs "Product B").
Use domain knowledge to determine if the entities are the same or different.
Format the output as a list of answers separated by a custom delimiter.
This prompt is highly structured and includes:
A clear goal and step-by-step instructions.
Two detailed examples illustrating how to resolve entities for different domains (Products and Toponyms).
Placeholders for dynamic text insertion, such as delimiters and input text.
The file is intended for use as a prompt template in an AI-driven entity resolution pipeline or system, where it can be programmatically filled and passed to a language model for inference.
Contents
Constant
ENTITY_RESOLUTION_PROMPT
Type:
strDescription: A comprehensive prompt template string for entity resolution tasks.
Purpose: To guide a language model in answering multiple entity comparison questions within an input text, producing structured outputs.
Key Features:
Defines the goal and steps for the task.
Provides two domain-specific examples with demonstrations.
Uses placeholders enclosed in curly braces (
{}) for:record_delimiter: Delimiter for separating each answer record in the output list.entity_index_delimiter: Delimiter marking the question index in the output.resolution_result_delimiter: Delimiter marking the result (yes/no) in the output.input_text: Placeholder for the real input questions to be resolved.
Usage Example:
from entity_resolution_prompt import ENTITY_RESOLUTION_PROMPT
record_delimiter = "\n"
entity_index_delimiter = "#"
resolution_result_delimiter = "~"
input_text = '''name of Product A is : "laptop", name of Product B is :"notebook"
name of Product A is : "chair", name of Product B is :"table"'''
# Fill in the placeholders
prompt = ENTITY_RESOLUTION_PROMPT.format(
record_delimiter=record_delimiter,
entity_index_delimiter=entity_index_delimiter,
resolution_result_delimiter=resolution_result_delimiter,
input_text=input_text
)
print(prompt)
This example shows how to dynamically insert the delimiters and input text into the prompt before sending it to a language model.
Implementation Details
The prompt is written as a multiline string using triple quotes (
"""...""").The prompt includes two major example blocks for different entity types: Products and Toponyms.
Each example shows:
A question statement.
Demonstrations with example entity pairs and the correct resolution.
Instructions on how to format answers.
The prompt instructs the model to return answers as a list separated by the specified
record_delimiter.The placeholders enable flexible integration with different systems that may require different delimiters or input strings.
Interaction with Other System Components
Input Provider: Another part of the system provides the dynamic
input_textcontaining the actual entity comparison questions.Prompt Formatter: A module or function formats
ENTITY_RESOLUTION_PROMPTwith appropriate delimiters and input text before passing it on.Language Model Interface: This prompt is sent to a language model (e.g., GPT or other LLM) to generate entity resolution answers.
Output Parser: After receiving model output, another component parses the structured answers using the
record_delimiterand extracts resolution results.Downstream Applications: The results can be used for deduplication, data cleansing, or knowledge graph construction in the InfiniFlow system.
Visual Diagram
The following Mermaid class diagram represents the structure and relationships within this file:
classDiagram
class entity_resolution_prompt.py {
<<constant>>
+ENTITY_RESOLUTION_PROMPT: str
}
Note: This file contains only a single constant, so the diagram is simple, showing the constant as the main artifact.
Summary
entity_resolution_prompt.py is a utility file providing a detailed prompt template for entity resolution tasks.
It is designed for use with language models, guiding them to analyze and compare entity pairs.
The prompt is parameterized with placeholders for delimiters and input questions, enabling flexible integration.
This file plays a foundational role in the InfiniFlow entity resolution pipeline by providing the textual instruction set that drives AI reasoning.
If you need further details about how to integrate this prompt in your system or examples of prompt usage in code, please let me know!