run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
36.91k stars 5.29k forks source link

[Bug]: Neo4j Property Graph Index doesn't seem to be working? #16352

Open tituslhy opened 1 month ago

tituslhy commented 1 month ago

Bug Description

I was following this link. After setting up my PropertyGraphIndex.from_documents(), I navigated to the Neo4j browser on localhost:7474 and typed match n=() return n but saw nothing - the data didn't get ingested?

Version

0.11.14

Steps to Reproduce

Here's my code

  1. Setup neo4j Spin up neo4j instance
    docker run \
    -p 7474:7474 -p 7687:7687 \
    -v $PWD/data:/data -v $PWD/plugins:/plugins \
    --name neo4j-apoc \
    -e NEO4J_apoc_export_file_enabled=true \
    -e NEO4J_apoc_import_file_enabled=true \
    -e NEO4J_apoc_import_file_use__neo4j__config=true \
    -e NEO4JLABS_PLUGINS=\[\"apoc\"\] \
    neo4j:latest

    I navigated to localhost:7474 and changed my password to llamaindex like the cookbook

Type the following in the notebook

from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore

# Note: used to be `Neo4jPGStore`
graph_store = Neo4jPropertyGraphStore(
    username="neo4j",
    password="llamaindex",
    url="bolt://localhost:7687",
)

Finishing this cell yielded the message eceived notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The procedure has a deprecated field. ('config' used by 'apoc.meta.graphSample' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: "CALL apoc.meta.graphSample() YIELD nodes, relationships RETURN nodes, [rel in relationships | {name:apoc.any.property(rel, 'type'), count: apoc.any.property(rel, 'count')}] AS relationships"

  1. Setup Qdrant Client Spin up Qdrant instance
    docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant

    Type in notebook

    
    from llama_index.vector_stores.qdrant import QdrantVectorStore
    from qdrant_client import QdrantClient, AsyncQdrantClient

client = QdrantClient(host="localhost", port=6333) aclient = AsyncQdrantClient(host="localhost", port=6333)

delete collection if it exists

if client.collection_exists("PaulGraham"): client.delete_collection("PaulGraham")

vector_store = QdrantVectorStore( "Titus_Resume", client = client, aclient = aclient, fastembed_sparse_model="Qdrant/bm42-all-minilm-l6-v2-attentions", )


3. Ingest documents

from llama_index.core import SimpleDirectoryReader

docs = SimpleDirectoryReader(input_files=["../../../data/paul_graham_essay.txt"]).load_data()


4. Setup PropertyGraphIndex

from llama_index.core import ( Settings, StorageContext, load_index_from_storage ) from llama_index.core.indices import PropertyGraphIndex from llama_index.core.indices.property_graph import ( SimpleLLMPathExtractor, ImplicitPathExtractor ) from llama_index.llms.ollama import Ollama from llama_index.embeddings.ollama import OllamaEmbedding

simple_path_extractor = SimpleLLMPathExtractor( max_paths_per_chunk=10, num_workers=4, ) implicit_path_extractor = ImplicitPathExtractor() Settings.llm = Ollama("llama3.2") Settings.embed_model = OllamaEmbedding("nomic-embed-text") index = PropertyGraphIndex.from_documents( docs, property_graph = graph_store, vector_store = vector_store, embed_kg_nodes = True, kg_extractors = [ simple_path_extractor, implicit_path_extractor ] )


After this I went to look at the Neo4j graph on the UI and nothing showed up.

### Relevant Logs/Tracbacks

```shell
No logs at all. Everything ran fine in terminal and on the notebook aside from the warning message by Neo4j (pasting here for convenience)

Finishing this cell yielded the message `Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The procedure has a deprecated field. ('config' used by 'apoc.meta.graphSample' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: "CALL apoc.meta.graphSample() YIELD nodes, relationships RETURN nodes, [rel in relationships | {name:apoc.any.property(rel, 'type'), count: apoc.any.property(rel, 'count')}] AS relationships"
dosubot[bot] commented 1 month ago

The issue you're experiencing with data not appearing in the Neo4j browser after using PropertyGraphIndex.from_documents() could be due to several factors. Here are some steps to troubleshoot and verify the data ingestion:

  1. Check Neo4j Connection: Ensure that the Neo4j instance is running and accessible at the specified URL (bolt://localhost:7687). Verify that the credentials (username and password) are correct.

  2. Verify Data Ingestion: Double-check that the PropertyGraphIndex.from_documents() method is correctly configured to ingest data into the Neo4j database. Ensure that the property_graph parameter is set to your Neo4jPropertyGraphStore instance.

  3. Inspect Logs: Although you mentioned there are no logs, try enabling more detailed logging to capture any potential issues during the ingestion process. This can help identify if there are any silent errors.

  4. Schema and Constraints: Ensure that the necessary constraints and indexes are created in the Neo4j database. The Neo4jPropertyGraphStore should handle this, but you can manually verify by checking the database schema.

  5. Deprecation Warning: The warning message you received about a deprecated feature in Neo4j might not directly affect data ingestion, but it's worth checking if the version of Neo4j or the APOC library you're using is compatible with the LlamaIndex library.

  6. Data Verification: After running the ingestion, try executing a simple query in the Neo4j browser to check for any nodes or relationships, such as MATCH (n) RETURN n LIMIT 10.

If these steps do not resolve the issue, consider reviewing the configurations and ensuring that all components (Neo4j, LlamaIndex, and any dependencies) are correctly set up and compatible.

To continue talking to Dosu, mention @dosu.