Find answers from the community

Updated 3 months ago

llama_index/llama-index-core/llama_index...

How does the schema in SchemaLLMPathExtractor help in guiding it to extract the graph according to the schema? I look at the source code but the default prompt template doesn't pass any schema into it, then how the LLM know about the schema? https://github.com/run-llama/llama_index/blob/08c748f0111bfa1d772176e68532d1948b30a267/llama-index-core/llama_index/core/indices/property_graph/transformations/schema_llm.py

If I want to modify the prompt, which variables should I include?
L
p
7 comments
The schema (allowed entity and relation names) are used to create a pydantic object on the fly
This pydantic object is provided to the LLM, to inform it what type of graph should be extracted
@Logan M Can you explain a little more on how to customize the prompt. Should I just look at the default prompt above for reference or something else?
With the SchemaLLMPathExtractors, I see no EntityNodes extracted, so really want to understand why.
Additionally, is it possible to define a directional relationships for this schema? I saw that the type for schema - kg_validation_schema (Dict[str, str], optional) - is Dict, so not sure how to make it directional...
I first build the KG with strict=False, then put all the extracted entities and relations there into my schema and set back to strict=True but the it still extracts nothing.... Do you know anyways I could make the models extract more nodes?
If the LLM is not outputting proper json, then there will be no output. This is very common for open-source LLMs

I think you might have an older version, the type for kg_validation_schema is kg_validation_schema: Union[Dict[str, str], List[Triple]], Its directional becaue you can do kg_validation_schema=[("ENTITY1", "REL", "ENTITY2"), ...]
Got it! Thank you!
Add a reply
Sign up and join the conversation on Discord