llmgraph  by dylanhogg

CLI tool to create knowledge graphs from LLM-extracted world knowledge

created 1 year ago
452 stars

Top 67.7% on sourcepulse

GitHubView on GitHub
Project Summary

This project enables the creation of knowledge graphs from Wikipedia entities using Large Language Models (LLMs). It targets researchers and developers interested in visualizing and analyzing complex relationships, offering an automated way to extract and structure world knowledge into interactive graph formats.

How It Works

The tool leverages LLMs, configurable via LiteLLM, to extract entities and their relationships from a specified Wikipedia page. It uses customized prompts tailored to different entity types (e.g., movies, people, concepts) to guide the LLM in identifying relevant information. The extracted data is then structured into knowledge graphs, supporting formats like GraphML, GEXF, and interactive HTML visualizations via pyvis.

Quick Start & Requirements

  • Install via pip: pip install llmgraph
  • Requires an OpenAI API key set as an environment variable OPENAI_API_KEY.
  • Supports custom LLM providers via LiteLLM, including local Ollama models.
  • Example usage: llmgraph machine-learning "https://en.wikipedia.org/wiki/Artificial_intelligence" --levels 3
  • Official documentation and examples are available.

Highlighted Details

  • Generates knowledge graphs in GraphML, GEXF, and interactive HTML (pyvis) formats.
  • Supports iterative graph growth with caching for LLM API calls and Wikipedia data.
  • Outputs total tokens used for cost estimation; default runs are approximately 1 cent.
  • Customizable LLM models, including OpenAI's gpt-4o-mini and local models via Ollama.

Maintenance & Community

The project welcomes contributions via pull requests. LiteLLM updates were recently implemented.

Licensing & Compatibility

The project does not explicitly state a license in the README.

Limitations & Caveats

Prompt effectiveness is noted as best with OpenAI models; results with Llama2 are described as "ok, but not as good." Future improvements include parallelizing API calls and removing the dependency on Wikipedia as a sole source.

Health Check
Last commit

5 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
36 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.