Find answers from the community

Updated 3 months ago

Hello everyone,

Hello everyone,
I am triying to create a knowledge graph using PropertyGraphIndex with SchemaLLMPathExtractor for extracting triplets from certain documents in v0.11.4
The graph has been created perfectly and seems somewhat meaningful, however, when performing a retrieval, it returns an empty list.
Plain Text
index_schema = PropertyGraphIndex.from_documents(
            documents,
            kg_extractors=[kg_extractor],
            property_graph_store=pg_store,
            vec_store=vec_store,
            show_progress=True
        )

retriever = index_schema.as_retriever().retrieve(query)


And if i try to retrieve the same kg loading it using .from_existing() from Neo4j, it appears the following empty error:

Plain Text
AssertionError:


What can i do?
L
d
4 comments
Theres probably some traceback that will be helpful here
To know where in the code an error happens
I resolved this issue. The problem was that I had installed llama_index==0.11.5, but the llama_index_core package installed by default was 0.11.8, so there were some incompatibilities.
What seems strange to me @Logan M , is that the SchemaLLMPathExtractor is hallucinating deliberately, introducing invented nodes that have no relation to the documents.

From two documents, it introduces 3 entities, and on top of that, they have nothing to do with the content. What could I be doing wrong?

Plain Text
entities = Literal["MISSION", "ORGANIZATION", "VEHICLE", "TECHNOLOGY", "EVENT", "LOCATION"]
relations = Literal["CONDUCTS", "DEVELOPS", "OCCURS_AT", "IMPLEMENTS", "PARTICIPATES_IN", "EXPLORES", "HIGHLIGHTS", "SPONSORS", "TARGETS", "CELEBRATES", "HOSTS"]
schema = [
    ('ORGANIZATION', 'CONDUCTS', 'MISSION'),
    ('ORGANIZATION', 'DEVELOPS', 'TECHNOLOGY'),
    ('EVENT', 'OCCURS_AT', 'LOCATION'),
    ('MISSION', 'IMPLEMENTS', 'TECHNOLOGY'),
    ('ORGANIZATION', 'PARTICIPATES_IN', 'EVENT'),
    ('MISSION', 'EXPLORES', 'LOCATION'),
    ('EVENT', 'HIGHLIGHTS', 'TECHNOLOGY'),
    ('ORGANIZATION', 'SPONSORS', 'EVENT'),
    ('MISSION', 'TARGETS', 'LOCATION'),
    ('EVENT', 'CELEBRATES', 'MISSION'),
    ('LOCATION', 'HOSTS', 'EVENT')
]
extract_prompt=""" 
You are a data scientist working for a company that is interested in understanding the relationship between different entities in a knowledge graph.
You have been tasked with extracting the relationship between entities in a knowledge graph.
IMPORTANT: All entities must be extracted from the documents provided.
"""
kg_extractor = SchemaLLMPathExtractor(
    llm= llm,
    num_workers=4,
    max_triplets_per_chunk=10,
    possible_entities=entities,
    possible_relations=relations,
    kg_validation_schema=schema,
    strict=True,
    extract_prompt= PromptTemplate(extract_prompt) 
)
Add a reply
Sign up and join the conversation on Discord