feat(llm): update keyword extraction method (BREAKING CHANGE)  (#282)

BREAKING CHANGE
**MUST** :UPDATE YOUR "KEYWORD EXTRACT PROMPT" To LATEST VERSION

fix #224 problem, update the new UI to support change keyword extraction
method.

**Main changes**

Added options to the RAG interface for selecting the keyword extraction
method(including LLM, TextRank, Hybrid) and the max number of keywords.
<img width="619" height="145" alt="QQ20250818-193453"
src="https://github.com/user-attachments/assets/3c0d21f0-82bb-4176-bfe2-1b0744c06b6d"
/>

A 'TextRank mask words' setting has also been added. It allows users to
manually input specific phrases composed of letters and symbols to
prevent them from being split during word segmentation. And the input
will also be saved.
<img width="1207" height="263" alt="QQ20250818-193518"
src="https://github.com/user-attachments/assets/6366789a-f87d-46a4-a85a-9f3b4d9ce9a5"
/>


**Test results**

TextRank Method:
-Input
<img width="363" height="144" alt="image"
src="https://github.com/user-attachments/assets/4a6267f7-3982-4fca-82df-60cd55bed6af"
/>

-Result:
<img width="232" height="118" alt="image"
src="https://github.com/user-attachments/assets/54a34d00-e588-44ad-9eff-d7281d7d93e5"
/>


Hybrid Method:
<img width="710" height="129" alt="QQ20250818-193508"
src="https://github.com/user-attachments/assets/541534fd-cec0-4002-9967-e49954a6c19e"
/>

---------

Co-authored-by: imbajin <jin@apache.org>
15 files changed
tree: c2a1aa6ee3c82ddb7a2f4f1874fca291a1ab56a9
  1. .github/
  2. docker/
  3. hugegraph-llm/
  4. hugegraph-ml/
  5. hugegraph-python-client/
  6. rules/
  7. scripts/
  8. style/
  9. vermeer-python-client/
  10. .asf.yaml
  11. .gitattributes
  12. .gitignore
  13. .licenserc.yaml
  14. DISCLAIMER
  15. LICENSE
  16. NOTICE
  17. pyproject.toml
  18. README.md
README.md

hugegraph-ai

License Ask DeepWiki

hugegraph-ai integrates HugeGraph with artificial intelligence capabilities, providing comprehensive support for developers to build AI-powered graph applications.

✨ Key Features

🚀 Quick Start

[!NOTE] For a complete deployment guide and detailed examples, please refer to hugegraph-llm/README.md

Prerequisites

  • Python 3.10+ (required for hugegraph-llm)
  • uv 0.7+ (required for workspace management)
  • HugeGraph Server 1.3+ (1.5+ recommended)
  • Docker (optional, for containerized deployment)

Option 1: Docker Deployment (Recommended)

# Clone the repository
git clone https://github.com/apache/incubator-hugegraph-ai.git
cd incubator-hugegraph-ai

# Set up environment and start services
cp docker/env.template docker/.env
# Edit docker/.env to set your PROJECT_PATH
cd docker
# same as `docker-compose` (Legacy)
docker compose -f docker-compose-network.yml up -d

# Access services:
# - HugeGraph Server: http://localhost:8080
# - RAG Service: http://localhost:8001

Option 2: Source Installation

# 1. Start HugeGraph Server
docker run -itd --name=server -p 8080:8080 hugegraph/hugegraph

# 2. Clone and set up the project
git clone https://github.com/apache/incubator-hugegraph-ai.git
cd incubator-hugegraph-ai

# 3. Install dependencies with workspace management
# uv sync automatically creates venv (.venv) and installs base dependencies
# NOTE: If download is slow, uncomment mirror lines in pyproject.toml or use: uv config --global index.url https://pypi.tuna.tsinghua.edu.cn/simple
# Or create local uv.toml with mirror settings to avoid git diff (see uv.toml example in root)
uv sync --extra llm  # Install LLM-specific dependencies
# Or install all optional dependencies: uv sync --all-extras

# 4. Activate virtual environment (recommended for easier commands)
source .venv/bin/activate

# 5. Start the demo (no uv run prefix needed when venv activated)
cd hugegraph-llm
python -m hugegraph_llm.demo.rag_demo.app
# Visit http://127.0.0.1:8001

Basic Usage Examples

[!NOTE] Examples assume you've activated the virtual environment with source .venv/bin/activate

GraphRAG - Question Answering

from hugegraph_llm.operators.graph_rag_task import RAGPipeline

# Initialize RAG pipeline
graph_rag = RAGPipeline()

# Ask questions about your graph
result = (graph_rag
    .extract_keywords(text="Tell me about Al Pacino.")
    .keywords_to_vid()
    .query_graphdb(max_deep=2, max_graph_items=30)
    .merge_dedup_rerank()
    .synthesize_answer()
    .run())

Knowledge Graph Construction

from hugegraph_llm.models.llms.init_llm import LLMs
from hugegraph_llm.operators.kg_construction_task import KgBuilder

# Build KG from text
TEXT = "Your text content here..."
builder = KgBuilder(LLMs().get_chat_llm())

(builder
    .import_schema(from_hugegraph="hugegraph")
    .chunk_split(TEXT)
    .extract_info(extract_type="property_graph")
    .commit_to_hugegraph()
    .run())

Graph Machine Learning

# Install ML dependencies (ml module is not in workspace)
uv sync --extra ml
source .venv/bin/activate

# Run ML algorithms
cd hugegraph-ml
python examples/your_ml_example.py

📦 Modules

hugegraph-llm Ask DeepWiki

Large language model integration for graph applications:

  • GraphRAG: Retrieval-augmented generation with graph data
  • Knowledge Graph Construction: Build KGs from text automatically
  • Natural Language Interface: Query graphs using natural language
  • AI Agents: Intelligent graph analysis and reasoning

hugegraph-ml

Graph machine learning with 20+ implemented algorithms:

  • Node Classification: GCN, GAT, GraphSAGE, APPNP, etc.
  • Graph Classification: DiffPool, P-GNN, etc.
  • Graph Embedding: DeepWalk, Node2Vec, GRACE, etc.
  • Link Prediction: SEAL, GATNE, etc.

[!NOTE] hugegraph-ml is not part of the workspace but linked via path dependency

hugegraph-python-client

Python client for HugeGraph operations:

  • Schema Management: Define vertex/edge labels and properties
  • CRUD Operations: Create, read, update, delete graph data
  • Gremlin Queries: Execute graph traversal queries
  • REST API: Complete HugeGraph REST API coverage

📚 Learn More

🔗 Related HugeGraph Projects

And here are links of other repositories:

  1. hugegraph (graph's core component - Graph server + PD + Store)
  2. hugegraph-toolchain (graph tools loader/dashboard/tool/client)
  3. hugegraph-computer (integrated graph computing system)
  4. hugegraph-website (doc & website code)

🤝 Contributing

We welcome contributions! Please see our contribution guidelines for details.

🤖 AI Coding Guidelines for Developers

[!IMPORTANT] > For project contributors using AI coding tools, please follow these guidelines:

  • Start Here: First read rules/README.md for the complete AI-assisted development workflow
  • Module Context: When AGENTS.md exists in any module, rename it as context for your LLM (e.g., CLAUDE.md, copilot-instructions.md)
  • Documentation Standards: Follow the structured documentation approach in rules/prompts/project-general.md
  • Deep Analysis: For complex features, refer to rules/prompts/project-deep.md for comprehensive code analysis methodology
  • Code Quality: Maintain consistency with existing patterns and ensure proper type annotations
  • Testing: Follow TDD principles and ensure comprehensive test coverage for new features

These guidelines ensure consistent code quality and maintainable development workflow with AI assistance.

Development Setup:

# 1. Clone and navigate to project
git clone https://github.com/apache/incubator-hugegraph-ai.git
cd incubator-hugegraph-ai

# 2. Install all development dependencies
# uv sync creates venv automatically and installs base dependencies
uv sync --all-extras  # Install all optional dependency groups
source .venv/bin/activate  # Activate for easier command usage

# 3. Run tests for workspace members
cd hugegraph-llm && pytest
cd ../hugegraph-python-client && pytest

# 4. Run tests for path dependencies
cd ../hugegraph-ml && pytest  # If tests exist

# 5. Format and lint code
./style/code_format_and_analysis.sh

# 6. Add new dependencies to workspace
uv add numpy  # Add to base dependencies
uv add --group dev pytest-mock  # Add to dev group

Key Points:

  • Use GitHub Desktop for easier PR management
  • Check existing issues before reporting bugs

contributors graph

📄 License

hugegraph-ai is licensed under Apache 2.0 License.

📞 Contact Us