Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dianaow/products-knowledge-graph
Implementing Retrieval-Augmented Generation (RAG) with constructed Knowledge Graph
https://github.com/dianaow/products-knowledge-graph
knowledge-graph langchain langchain-python neo4j rag vector-search
Last synced: about 1 month ago
JSON representation
Implementing Retrieval-Augmented Generation (RAG) with constructed Knowledge Graph
- Host: GitHub
- URL: https://github.com/dianaow/products-knowledge-graph
- Owner: dianaow
- Created: 2024-02-05T13:49:27.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-05T16:15:44.000Z (11 months ago)
- Last Synced: 2024-02-05T17:34:57.675Z (11 months ago)
- Topics: knowledge-graph, langchain, langchain-python, neo4j, rag, vector-search
- Language: HTML
- Homepage: https://dianaow.com/blog/knowledge-graph-rag/
- Size: 2.11 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Implementing Retrieval-Augmented Generation (RAG) with a Knowledge Graph (KG)
### Constructing a KG with skincare products found on an e-commerce website
### Product similarity search with vector embeddings
Tools: Python, OpenAI (free tier), LangChain, Neo4j### Set up
1. Create a Python virtual environment where the dependencies for this project will be installed.
```
cd server
python3 -m venv venv
```2. Activate the environment and install all the packages available in the requirement.txt file.
```
source venv/bin/activate
pip install -r ./requirements.txt
```3. If a `.env` file is not present in the server folder, create one to store the private OpenAI API key, which is required to use the LLMs.
```
OPENAI_API_KEY=XXXXXX
NEO4J_PW=XXX
```4. Run the Python script to web scrape product information found online.
```
python3 web_scrape.py
```5. The `llm_kg.ipynb` file explains:
- How to use LLM to extract new relations from product descriptions and construct Knowledge Graph
- Methods to query the graph database (based on embeddings, LLM-generated entities in prompt, Cypher)![Image of Knowledge Graph](https://github.com/dianaow/products-knowledge-graph/blob/main/graph_overview.png)