Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neo4J integration. #197

Merged
merged 17 commits into from
Nov 4, 2024
Merged

Neo4J integration. #197

merged 17 commits into from
Nov 4, 2024

Conversation

wiltshirek
Copy link
Contributor

@wiltshirek wiltshirek commented Nov 2, 2024

Integration pull for Neo4j. I kept changes to a single folder (KG). With minor edits in lightrag.py. Its using configurable start params. Steps are in the readme but here's all you'll need to do:

  • See Neo4J Docker or alternatively just use the existing Neo4J Dockerfile via command line:
docker run \
    --restart always \
    --publish=7474:7474 --publish=7687:7687 \
    neo4j:5.25.1 \
    

Then set up login credentials via Neo4J Browser @ http://localhost:7474/

  • Set env Vars:
    export NEO4J_URI="neo4j://localhost:7687"
    export NEO4J_USERNAME="[your Neo4J Username]"
    export NEO4J_PASSWORD="[your Neo4J Password]"

run: python3 test_neo4j.py

  • Set start params:
    rag = LightRAG(
    working_dir=WORKING_DIR,
    llm_model_func=gpt_4o_mini_complete, # Use gpt_4o_mini_complete LLM model
    kg="Neo4JStorage", #<-----------override KG default
    log_level="DEBUG" #<-----------override log_level default
    )

The changes are non-dissruptive and non-breaking. Existing deployments that do not specify these start params and env vars will work the same and simply use the default values. One change to note is in lightrag.py, always_get_an_event_loop(), needed to use current loop opposed to a new one. I think this is how you would want it to work regardless.

Please review this PR and let me know if you need me to make any other changes to have it merged in. I believe you'll see significant adoption by adding production level features to the project.

@wiltshirek wiltshirek marked this pull request as ready for review November 2, 2024 22:52
@Dormiveglia-elf
Copy link
Contributor

Excellent work! By the way, I wanted to ask if you have any plans to integrate Neo4j to create a visualization of the partial KG used during queries. What I mean is, currently the KG shows all the entities and relations, but when we perform a query, we only actually use a subset of entities and relations relevant to our query. If we could display the partial KG that highlights the specific entities and relations that Lightrag used to generate the answer, I think it would make the response more convincing and intuitive.

@wiltshirek
Copy link
Contributor Author

wiltshirek commented Nov 4, 2024

Excellent work! By the way, I wanted to ask if you have any plans to integrate Neo4j to create a visualization of the partial KG used during queries. What I mean is, currently the KG shows all the entities and relations, but when we perform a query, we only actually use a subset of entities and relations relevant to our query. If we could display the partial KG that highlights the specific entities and relations that Lightrag used to generate the answer, I think it would make the response more convincing and intuitive.

Seems to me like this would be a dev time concern since there would be no use case to show a sub-graph in production. I'm focusing on production concerns atm, with an integration for a commercial Vector store next (Pinecone most likely). But You can probably capture the cypher queries using debug mode. I'll see if I can add a specific debug output in debug mode to show the subgraph(s) nodes/queries that were used to augment the response. Maybe I can return one executable query to select the subgraph(s). Then you'd just need to copy and paste in to Neo4J browswer. I do agree that this would be pretty useful for debugging.

@LarFii LarFii merged commit 6d9bd10 into HKUDS:main Nov 4, 2024
1 check failed
@LarFii
Copy link
Collaborator

LarFii commented Nov 4, 2024

Thanks for your excellent work!

@wiltshirek
Copy link
Contributor Author

wiltshirek commented Nov 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants