Overview
TheEntity class represents a node in the knowledge graph. Entities are extracted from documents and represent real-world objects, concepts, or actors mentioned in the text. Each entity can be associated with multiple communities, text units, and has optional embeddings for semantic search.
Entities inherit from the Named base class, which provides id, short_id, and title fields.
Schema
Core fields
Unique identifier for the entity.
Human-readable ID used to refer to this entity in prompts or texts displayed to users, such as in a report text.
The name/title of the entity.
Type of the entity. Can be any string representing the entity category (e.g., “Person”, “Organization”, “Location”).
Textual description of the entity explaining its role, characteristics, or context.
Embeddings
The semantic (text) embedding vector of the entity’s description. Used for similarity search and semantic queries.
The semantic (text) embedding vector of the entity’s name. Used for entity matching and retrieval.
Relationships
List of community IDs that this entity belongs to. Entities can be members of multiple communities at different hierarchical levels.
List of text unit IDs in which the entity appears. Links the entity back to its source text chunks.
Metadata
Rank of the entity, used for sorting and prioritization. Higher rank indicates more important entity. This can be based on centrality metrics or other importance measures.
Additional attributes associated with the entity (e.g., start time, end time, custom metadata). These attributes are included in search prompts.
Example
Creating from dictionary
TheEntity class provides a from_dict() class method to create instances from dictionary data: