Find answers from the community

Updated 3 months ago

Entity and relation properties shared across all entities

Hi! For entity and relation properties, looking through the code it looks like you define a single str list of properties. Does this mean that all the properties are shared between all the entities? (For PropertyGraphIndex and extractors)
L
k
17 comments
define a single str list of properties -- can you maybe clarify where you see this?

By default, the nodes/relationships are inheriting the source node metadata as properties
Ah. Sorry I'm looking at specifically property graph index and those associated extractors.
For example this part of the code in DynamicLLMPathExtractor.

Plain Text
allowed_entity_props (Optional[Union[List[str], List[Tuple[str, str]]]]):
Attachment
image.png
I'm going to test adding descriptions to the entities to say which entities a property is associated with for now. It would be great to get confirmation. I couldn't find any documentation related to this. Thank you in advance!
I also realized that the SchemaLLMPathExtractor allows you to input a list of possible props but never actually input them in the extract prompt as far as I can tell?
Yea thats basically what thats for,
No it does use them, in get_relation_class and get_entity_class when building the pydantic model
If it is not in the extract prompt does the pydantic model get referenced when prompting the LLM?
Dosa is telling me
The SchemaLLMPathExtractor does not extract properties directly from the node itself. Instead, it uses the _prune_invalid_triplets method to filter and validate the extracted triplets based on the defined schema and properties. The properties are not extracted from the node but are used to prune and validate the properties that are inherited or associated with the triplets during the extraction process

in which I'm not sure if it's just trying to agree with me for the sake of being a chatbot or it is right.
Yea its wrong. The pydantic model is used in the SchemaLLMPathExtractor as a json schema essentially, which includes all the properties and descriptions, etc.
You can test it yourself actually
schema_extractor.kg_schema_cls.model_dump_json()
thats essentially what the LLM ends up seeing
Thank you for your answers! This has been really helpful. I think I didn't realize the pydantic model was passed along with the prompt.
Yea, defining it as a pydantic model is the way that we can leverage function-calling APIs like openai's or anthropics built-in tool calling
LLMs that don't have tool calling go through a more manual process, just showing them the json schema and getting them to predict back json that we parse
Add a reply
Sign up and join the conversation on Discord