Skip to content

Version 1.5 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.

HugeGraph-LLM

Please refer to the AI repository README for the most up-to-date documentation, and the official website regularly is updated and synchronized.

Bridge the gap between Graph Databases and Large Language Models

AI summarizes the project documentation: Ask DeepWiki

🎯 Overview

HugeGraph-LLM is a comprehensive toolkit that combines the power of graph databases with large language models. It enables seamless integration between HugeGraph and LLMs for building intelligent applications.

Key Features

  • 🏗️ Knowledge Graph Construction - Build KGs automatically using LLMs + HugeGraph
  • 🗣️ Natural Language Querying - Operate graph databases using natural language (Gremlin/Cypher)
  • 🔍 Graph-Enhanced RAG - Leverage knowledge graphs to improve answer accuracy (GraphRAG & Graph Agent)

For detailed source code doc, visit our DeepWiki page. (Recommended)

📋 Prerequisites

Important
  • Python: 3.10+ (not tested on 3.12)
  • HugeGraph Server: 1.3+ (recommended: 1.5+)
  • UV Package Manager: 0.7+

🚀 Quick Start

Choose your preferred deployment method:

The fastest way to get started with both HugeGraph Server and RAG Service:

 1# 1. Set up environment
 2cp docker/env.template docker/.env
 3# Edit docker/.env and set PROJECT_PATH to your actual project path
 4
 5# 2. Deploy services
 6cd docker
 7docker-compose -f docker-compose-network.yml up -d
 8
 9# 3. Verify deployment
10docker-compose -f docker-compose-network.yml ps
11
12# 4. Access services
13# HugeGraph Server: http://localhost:8080
14# RAG Service: http://localhost:8001

Option 2: Individual Docker Containers

For more control over individual components:

Available Images

  • hugegraph/rag - Development image with source code access
  • hugegraph/rag-bin - Production-optimized binary (compiled with Nuitka)
 1# 1. Create network
 2docker network create -d bridge hugegraph-net
 3
 4# 2. Start HugeGraph Server
 5docker run -itd --name=server -p 8080:8080 --network hugegraph-net hugegraph/hugegraph
 6
 7# 3. Start RAG Service
 8docker pull hugegraph/rag:latest
 9docker run -itd --name rag \
10  -v /path/to/your/hugegraph-llm/.env:/home/work/hugegraph-llm/.env \
11  -p 8001:8001 --network hugegraph-net hugegraph/rag
12
13# 4. Monitor logs
14docker logs -f rag

Option 3: Build from Source

For development and customization:

 1# 1. Start HugeGraph Server
 2docker run -itd --name=server -p 8080:8080 hugegraph/hugegraph
 3
 4# 2. Install UV package manager
 5curl -LsSf https://astral.sh/uv/install.sh | sh
 6
 7# 3. Clone and setup project
 8git clone https://github.com/apache/incubator-hugegraph-ai.git
 9cd incubator-hugegraph-ai/hugegraph-llm
10
11# 4. Create virtual environment and install dependencies
12uv venv && source .venv/bin/activate
13uv pip install -e .
14
15# 5. Launch RAG demo
16python -m hugegraph_llm.demo.rag_demo.app
17# Access at: http://127.0.0.1:8001
18
19# 6. (Optional) Custom host/port
20python -m hugegraph_llm.demo.rag_demo.app --host 127.0.0.1 --port 18001

Additional Setup (Optional)

1# Download NLTK stopwords for better text processing
2python ./hugegraph_llm/operators/common_op/nltk_helper.py
3
4# Update configuration files
5python -m hugegraph_llm.config.generate --update
Tip

Check our Quick Start Guide for detailed usage examples and query logic explanations.

💡 Usage Examples

Knowledge Graph Construction

Interactive Web Interface

Use the Gradio interface for visual knowledge graph building:

Input Options:

  • Text: Direct text input for RAG index creation
  • Files: Upload TXT or DOCX files (multiple selection supported)

Schema Configuration:

  • Custom Schema: JSON format following our template
  • HugeGraph Schema: Use existing graph instance schema (e.g., “hugegraph”)
Knowledge Graph Builder

Programmatic Construction

Build knowledge graphs with code using the KgBuilder class:

 1from hugegraph_llm.models.llms.init_llm import LLMs
 2from hugegraph_llm.operators.kg_construction_task import KgBuilder
 3
 4# Initialize and chain operations
 5TEXT = "Your input text here..."
 6builder = KgBuilder(LLMs().get_chat_llm())
 7
 8(
 9    builder
10    .import_schema(from_hugegraph="talent_graph").print_result()
11    .chunk_split(TEXT).print_result()
12    .extract_info(extract_type="property_graph").print_result()
13    .commit_to_hugegraph()
14    .run()
15)

Pipeline Workflow:

Graph-Enhanced RAG

Leverage HugeGraph for retrieval-augmented generation:

 1from hugegraph_llm.operators.graph_rag_task import RAGPipeline
 2
 3# Initialize RAG pipeline
 4graph_rag = RAGPipeline()
 5
 6# Execute RAG workflow
 7(
 8    graph_rag
 9    .extract_keywords(text="Tell me about Al Pacino.")
10    .keywords_to_vid()
11    .query_graphdb(max_deep=2, max_graph_items=30)
12    .merge_dedup_rerank()
13    .synthesize_answer(vector_only_answer=False, graph_only_answer=True)
14    .run(verbose=True)
15)

RAG Pipeline Flow:

🔧 Configuration

After running the demo, configuration files are automatically generated:

  • Environment: hugegraph-llm/.env
  • Prompts: hugegraph-llm/src/hugegraph_llm/resources/demo/config_prompt.yaml
Note

Configuration changes are automatically saved when using the web interface. For manual changes, simply refresh the page to load updates.

LLM Provider Support: This project uses LiteLLM for multi-provider LLM support.

📚 Additional Resources

  • Graph Visualization: Use HugeGraph Hubble for data analysis and schema management
  • API Documentation: Explore our REST API endpoints for integration
  • Community: Join our discussions and contribute to the project

License: Apache License 2.0 | Community: Apache HugeGraph