Member-only story
Using Graph Database combined with full-text search #
In the previous article, I presented a simple way for feeding local data into LLM queries. In this article, it is extended in two ways.
- The embedding will be stored in a graph database
- Similarity search will be combined with full-text search
I will use Neo4j graph database. For this article, a community version is deployed on Kubernetes. The detailed deployment steps are available in Deploying Neo4j Graph Database in Kubernetes article.
The overall procedure is shown in the diagram below.
Code Walk-through #
In this section, we will go through a running example code. We use a local LLM and a Neo4j graph database as a knowledge database.
We install the following Python packages for the example code.
- langchain_community
- tiktoken
- neo4j
- openai
- sentence-transformers
- ipywidgets
- pdfplumber
We set all the environment specific variables in the .env file and load it using the load_dotenv function.