run-llama / llama_index

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

[Bug]: Getting deprecation message for Neo4jPropertyGraphStore #14093

Open rajib76 opened 5 months ago

rajib76 commented 5 months ago

Bug Description

getting the below deprecation 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"

Version

latest

Steps to Reproduce

Run the below code `import os

from dotenv import load_dotenv from llama_index.core import SimpleDirectoryReader, PropertyGraphIndex from typing import Literal from llama_index.core.indices.property_graph import SchemaLLMPathExtractor from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore from llama_index.legacy.embeddings import HuggingFaceEmbedding from llama_index.llms.openai import OpenAI

load_dotenv() OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY') NEO4J_URI = os.environ.get('NEO4J_URI') NEO4J_USERNAME = os.environ.get("NEO4J_USERNAME") NEO4J_PASSWORD = os.environ.get("NEO4J_PASSWORD") documents = SimpleDirectoryReader("/Users/joyeed/langmodel/langmodel/data").load_data()

best practice to use upper-case

entities = Literal["PERSON", "SKILL", "EMPLOYER","ADDRESS","PROFILE","PHONE"] relations = Literal["HAS", "PART_OF", "EMPLOYED","BELONGS_TO","WORKED_FOR","WORKED_FROM","WORKED_TILL"]

define which entities can have which relations

validation_schema = { "PERSON": ["HAS", "PART_OF","WORKED_FOR","WORKED_FROM","WORKED_TILL"], "ADDRESS":["BELONGS_TO"], "PROFILE":["HAS"], "PHONE":["BELONGS_TO"], "SKILL": ["HAS","BELONGS_TO"], "EMPLOYER": ["EMPLOYED"], }

kg_extractor = SchemaLLMPathExtractor( llm=OpenAI(), possible_entities=entities, possible_relations=relations, kg_validation_schema=validation_schema,

if false, allows for values outside of the schema

# useful for using the schema as a suggestion
strict=True,

) graph_store = Neo4jPropertyGraphStore( username=NEO4J_USERNAME, password=NEO4J_PASSWORD, url=NEO4J_URI, ) vec_store = None index = PropertyGraphIndex.from_documents( documents, kg_extractors=[kg_extractor], embed_model=HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5"), property_graph_store=graph_store, vector_store=vec_store, show_progress=True, )`

Relevant Logs/Tracbacks

No response

rajib76 commented 5 months ago

Also getting the below message. Does Llamaindex use langchain /Users/joyeed/langmodel/langmodel/venv/lib/python3.11/site-packages/langchain/_api/module_import.py:92: LangChainDeprecationWarning: Importing ChatMessageHistory from langchain.memory is deprecated. Please replace deprecated imports:

logan-markewich commented 5 months ago

LlamaIndex does not use langchain by default, but you can use langchain llms/embeddings with llamaindex.

(Just uninstall it if you aren't using it)

rajib76 commented 5 months ago

Thanks the fresh install removed the langchain deprecation error, but the NEO4J deprecation message is still there

rajib76 commented 5 months ago

Also noticed that lot of hallucination happening while creating the nodes using gpt-3.5. if I use GPT-4, it does not create any relation only nodes. I think the prompt may not be tuned

IshanRattan commented 4 months ago

The Hound of the Baskervilles.txt

Also noticed that lot of hallucination happening while creating the nodes using gpt-3.5. if I use GPT-4, it does not create any relation only nodes. I think the prompt may not be tuned

True, the graph isn't getting constructed. It gives vague relationships having name entities like "Bob", "Alice", "Philz" etc which are not even there in my dataset! I am using Neo4j version 5.20.0. I wonder what is causing this issue?

Note: I am using Llama3 instead of ChatGPT.

Following is my code:


from llama_index.core import KnowledgeGraphIndex, SimpleDirectoryReader
from llama_index.core import StorageContext
from llama_index.core import Settings
from llama_index.graph_stores.neo4j import Neo4jGraphStore
from llama_index.llms.huggingface import HuggingFaceLLM
from llama_index.embeddings.huggingface import HuggingFaceEmbedding

llm = HuggingFaceLLM(
    model_name="meta-llama/Meta-Llama-3-8B",
    device_map='mps'
)
embed_model = HuggingFaceEmbedding(
    model_name="BAAI/bge-small-en-v1.5",
    trust_remote_code=True,
    device='mps'
)

Settings.embed_model = embed_model
Settings.llm = llm

documents = SimpleDirectoryReader(input_files = ['data/The Hound of the Baskervilles.txt']).load_data()
print(len(documents))
print(f"Document Metadata: {documents[0].metadata}")

graph_store = Neo4jGraphStore(
    username="neo4j",
    password='Pwd@0001',
    url="bolt://localhost:7687",
    database='test',
)

storage_context = StorageContext.from_defaults(graph_store=graph_store)

# NOTE: can take a while!
index = KnowledgeGraphIndex.from_documents(
    documents,
    storage_context=storage_context,
    max_triplets_per_chunk=2,
)

The graph:

Screenshot 2024-07-21 at 12 57 27 PM
reddiamond1234 commented 3 months ago

any solution?

cognetics-ai commented 3 months ago

Also noticed that lot of hallucination happening while creating the nodes using gpt-3.5. if I use GPT-4, it does not create any relation only nodes. I think the prompt may not be tuned

Even with GPT-4o and text-embedding-3-small, unable to extract relationships. See standalone 19 nodes in Neo4J browser. Deprecated message around config parameter still shows. Neo4J version: 5.19, Python: 3.11, lama-index.core: 0.11.1

SrijaAlla commented 2 months ago

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: CALL subquery without a variable scope clause is now deprecated. Use CALL (node, node) { ... }} {position: line: 3, column: 13, offset: 105} for query: "CALL db.index.fulltext.queryNodes('entity', $query, {limit:4})\n YIELD node, score\n
CALL {\n WITH node\n MATCH (node)-[r:!MENTIONS]->(neighbor)\n RETURN node.id + ' - ' + type(r) + ' -> ' + neighbor.id AS output\n UNION ALL\n WITH node\n MATCH (node)<-[r:!MENTIONS]-(neighbor)\n RETURN neighbor.id + ' - ' + type(r) + ' -> ' + node.id AS output\n }\n RETURN output LIMIT 50\n " - same error with GPT 4o mini and text-embedding-3-small. Has anyone found a solution?

akmal-123 commented 1 month ago

Any update on this? got same issue while testing blog https://medium.com/neo4j/enhancing-the-accuracy-of-rag-applications-with-knowledge-graphs-ad5e2ffab663

justinzyw commented 1 month ago

I got the same warning... however it did not seem to impact the construction of the graph index.

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"