Knowledge Graph

Knowledge graphs in the library are represented using the KnowledgeLLM class. This component in the llamarch library that provides a simple interface to work with knowledge graphs.
KnowledgeLLM
Source code in llamarch/patterns/knowledge_graph/__init__.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
__init__(knowledge_graph, llm)
Initialize the KnowledgeLLM with a knowledge graph and a language model.
| Parameters: |
|---|
Source code in llamarch/patterns/knowledge_graph/__init__.py
6 7 8 9 10 11 12 13 14 15 16 17 18 | |
query_knowledge_graph(query)
Query the knowledge graph for relevant data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in llamarch/patterns/knowledge_graph/__init__.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
update_knowledge_graph(query, parameters=None)
Update the knowledge graph with new data.
| Parameters: |
|
|---|
Source code in llamarch/patterns/knowledge_graph/__init__.py
36 37 38 39 40 41 42 43 44 45 46 47 | |
generate_ontology(text)
Generate an ontology from the provided text using the language model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
The generated ontology will be inserted into the knowledge graph.
Source code in llamarch/patterns/knowledge_graph/__init__.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
respond_to_query(query)
Generate a response to a query by combining information from the knowledge graph and the language model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
This method combines the results from a knowledge graph query with the language model's response.
Source code in llamarch/patterns/knowledge_graph/__init__.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |