Skip to main content

Create knowledge graphs with LLMs

Project description

llmgraph

llmgraph enables you to create knowledge graphs in GraphML, GEXF, and HTML formats from a given source entity Wikipedia page. The knowledge graphs are generated by extracting world knowledge from ChatGPT or other large language models (LLMs).

Features

  • Create knowledge graphs from a source entity Wikipedia page.
  • Support for generating knowledge graphs in HTML, GraphML, and GEXF formats.
  • Utilizes the power of ChatGPT and other large language models to extract world knowledge.

Installation

You can install llmgraph using pip:

pip install llmgraph

Example Output

In addition to GraphML and GEXF formats, an HTML pyvis physics enabled graph can be viewed:

example machine learning output

Example Usage

The example above was generated with the following command:

llmgraph machine-learning "https://en.wikipedia.org/wiki/Artificial_intelligence" --levels 3

It used a total of 7,650 gpt-3.5-turbo tokens to render 3 layers from the root 'Artificial Intelligence' node.

Required Arguments

  • entity_type (TEXT): Entity type (e.g. movie)
  • entity_wikipedia (TEXT): Full Wikipedia link to the root entity

Optional Arguments

  • --entity-root (TEXT): Optional root entity name override if different from the Wikipedia page title [default: None]
  • --levels (INTEGER): Number of levels deep to construct from the central root entity [default: 2]
  • --max-sum-total-tokens (INTEGER): Maximum sum of tokens for graph generation [default: 200000]
  • --output-folder (TEXT): Folder location to write outputs [default: ./_output/]
  • --llm-model (TEXT): The model name [default: gpt-3.5-turbo]
  • --llm-temp (FLOAT): LLM temperature value [default: 0.0]
  • --llm-use-localhost (INTEGER): LLM use localhost:8081 instead of OpenAI [default: 0]
  • --help: Show this message and exit.

Contributing

We welcome contributions to llmgraph. To contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Create a pull request with a clear description of your changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmgraph-0.9.0.tar.gz (13.6 kB view hashes)

Uploaded Source

Built Distribution

llmgraph-0.9.0-py3-none-any.whl (16.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page