hugegraph-llm
Summary
The hugegraph-llm is a tool for the implementation and research related to large language models. This project includes runnable demos, it can also be used as a third-party library.
As we know, graph systems can help large models address challenges like timeliness and hallucination, while large models can assist graph systems with cost-related issues.
With this project, we aim to reduce the cost of using graph systems, and decrease the complexity of building knowledge graphs. This project will offer more applications and integration solutions for graph systems and large language models.
- Construct knowledge graph by LLM + HugeGraph
- Use natural language to operate graph databases (gremlin)
- Knowledge graph supplements answer context (RAG)
Examples
Examples (knowledge graph construction by llm)
- Start the HugeGraph database, you can do it via Docker. Refer to this link for guidance
- Run example like
python hugegraph-llm/examples/build_kg_test.pyNote: If you need a proxy to access OpenAI's API, please set your HTTP proxy in
build_kg_test.py.
The KgBuilder class is used to construct a knowledge graph. Here is a brief usage guide:
- Initialization: The
KgBuilderclass is initialized with an instance of a language model. This can be obtained from theLLMsclass.
from hugegraph_llm.llms.init_llm import LLMs
from hugegraph_llm.operators.kg_construction_task import KgBuilder
TEXT = ""
builder = KgBuilder(LLMs().get_llm())
(
builder
.import_schema(from_hugegraph="talent_graph").print_result()
.extract_triples(TEXT).print_result()
.disambiguate_word_sense().print_result()
.commit_to_hugegraph()
.run()
)
- Import Schema: The
import_schemamethod is used to import a schema from a source. The source can be a HugeGraph instance, a user-defined schema or an extraction result. The methodprint_resultcan be chained to print the result.
# Import schema from a HugeGraph instance
import_schema(from_hugegraph="xxx").print_result()
# Import schema from an extraction result
import_schema(from_extraction="xxx").print_result()
# Import schema from user-defined schema
import_schema(from_user_defined="xxx").print_result()
- Extract Triples: The
extract_triplesmethod is used to extract triples from a text. The text should be passed as a string argument to the method.
TEXT = "Meet Sarah, a 30-year-old attorney, and her roommate, James, whom she's shared a home with since 2010."
extract_triples(TEXT).print_result()
- Disambiguate Word Sense: The
disambiguate_word_sensemethod is used to disambiguate the sense of words in the extracted triples.
disambiguate_word_sense().print_result()
- Commit to HugeGraph: The
commit_to_hugegraphmethod is used to commit the constructed knowledge graph to a HugeGraph instance.
commit_to_hugegraph().print_result()
- Run: The
runmethod is used to execute the chained operations.
run()
The methods of the KgBuilder class can be chained together to perform a sequence of operations.
Metadata
Release files for hugegraph-llm 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hugegraph-llm-1.3.0.tar.gz | 21.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hugegraph_llm-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.5 kB
Release files / hugegraph-llm-1.3.0.tar.gz
| Download URL | hugegraph-llm-1.3.0.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4a165c67215a6d22ddad6488bf6d86a5723bb9c6ffdfa266521af897a04755b
|
|
BLAKE2b-256 checksum How to use checksums |
52eff3c4ef9f6f0e95081e7911c616b55a31ff8395a8bb1b7c4919cf804ef5ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.6
|
Release files / hugegraph_llm-1.3.0-py3-none-any.whl
| Download URL | hugegraph_llm-1.3.0-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
513df839a89125776743b22ae3738bb2b59246bd48698ee5ebbdc6add560f74c
|
|
BLAKE2b-256 checksum How to use checksums |
31726703af26c9882d0d1f120bc3d12d8ae9e0ad56ef4f71d2a691a41260da30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.6
|
Security for hugegraph-llm 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.