Skip to content

Files

docs_to_knowledge_graph

Build Real-Time Knowledge Graph For Documents with LLM

We will process a list of documents and use LLM to extract relationships between the concepts in each document. We will generate two kinds of relationships:

  1. Relationships between subjects and objects. E.g., "CocoIndex supports Incremental Processing"
  2. Mentions of entities in a document. E.g., "core/basics.mdx" mentions CocoIndex and Incremental Processing.

You can find a step by step blog for this project here

Please drop Cocoindex on Github a star to support us if you like our work. Thank you so much with a warm coconut hug 🥥🤗. GitHub

example-explanation

Prerequisite

Documentation

You can read the official CocoIndex Documentation for Property Graph Targets here.

Run

Build the index

Install dependencies:

pip install -e .

Setup:

python main.py cocoindex setup

Update index:

python main.py cocoindex update

Browse the knowledge graph

After the knowledge graph is build, you can explore the knowledge graph you built in Neo4j Browser.

For the dev enviroment, you can connect neo4j browser using credentials:

  • username: neo4j
  • password: cocoindex which is pre-configured in the our docker compose config.yaml.

You can open it at http://localhost:7474, and run the following Cypher query to get all relationships:

MATCH p=()-->() RETURN p
neo4j-for-coco-docs

CocoInsight

I used CocoInsight (Free beta now) to troubleshoot the index generation and understand the data lineage of the pipeline. It just connects to your local CocoIndex server, with Zero pipeline data retention. Run following command to start CocoInsight:

python main.py cocoindex server -ci

And then open the url https://cocoindex.io/cocoinsight.

cocoinsight