mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-06-26 22:00:19 +00:00
Update README.md
This commit is contained in:
parent
7cf6381359
commit
d0eb602b12
159
README.md
159
README.md
@ -441,11 +441,15 @@ if __name__ == "__main__":
|
||||
- [Direct OpenAI Example](examples/lightrag_llamaindex_direct_demo.py)
|
||||
- [LiteLLM Proxy Example](examples/lightrag_llamaindex_litellm_demo.py)
|
||||
|
||||
</details>
|
||||
|
||||
### Conversation History Support
|
||||
|
||||
|
||||
LightRAG now supports multi-turn dialogue through the conversation history feature. Here's how to use it:
|
||||
|
||||
<details>
|
||||
|
||||
```python
|
||||
# Create conversation history
|
||||
conversation_history = [
|
||||
@ -506,6 +510,8 @@ response_custom = rag.query(
|
||||
print(response_custom)
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Separate Keyword Extraction
|
||||
|
||||
We've introduced a new function `query_with_separate_keyword_extraction` to enhance the keyword extraction capabilities. This function separates the keyword extraction process from the user's prompt, focusing solely on the query to improve the relevance of extracted keywords.
|
||||
@ -519,7 +525,8 @@ The function operates by dividing the input into two parts:
|
||||
|
||||
It then performs keyword extraction exclusively on the `user query`. This separation ensures that the extraction process is focused and relevant, unaffected by any additional language in the `prompt`. It also allows the `prompt` to serve purely for response formatting, maintaining the intent and clarity of the user's original question.
|
||||
|
||||
**Usage Example**
|
||||
<details>
|
||||
<summary> <b> Usage Example </b></summary>
|
||||
|
||||
This `example` shows how to tailor the function for educational content, focusing on detailed explanations for older students.
|
||||
|
||||
@ -531,67 +538,6 @@ rag.query_with_separate_keyword_extraction(
|
||||
)
|
||||
```
|
||||
|
||||
### Insert Custom KG
|
||||
|
||||
```python
|
||||
custom_kg = {
|
||||
"chunks": [
|
||||
{
|
||||
"content": "Alice and Bob are collaborating on quantum computing research.",
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"entity_name": "Alice",
|
||||
"entity_type": "person",
|
||||
"description": "Alice is a researcher specializing in quantum physics.",
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"entity_name": "Bob",
|
||||
"entity_type": "person",
|
||||
"description": "Bob is a mathematician.",
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"entity_name": "Quantum Computing",
|
||||
"entity_type": "technology",
|
||||
"description": "Quantum computing utilizes quantum mechanical phenomena for computation.",
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
],
|
||||
"relationships": [
|
||||
{
|
||||
"src_id": "Alice",
|
||||
"tgt_id": "Bob",
|
||||
"description": "Alice and Bob are research partners.",
|
||||
"keywords": "collaboration research",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"src_id": "Alice",
|
||||
"tgt_id": "Quantum Computing",
|
||||
"description": "Alice conducts research on quantum computing.",
|
||||
"keywords": "research expertise",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"src_id": "Bob",
|
||||
"tgt_id": "Quantum Computing",
|
||||
"description": "Bob researches quantum computing.",
|
||||
"keywords": "research application",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
rag.insert_custom_kg(custom_kg)
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Insert
|
||||
@ -683,6 +629,70 @@ rag.insert(text_content.decode('utf-8'))
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> <b> Insert Custom KG </b></summary>
|
||||
|
||||
```python
|
||||
custom_kg = {
|
||||
"chunks": [
|
||||
{
|
||||
"content": "Alice and Bob are collaborating on quantum computing research.",
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"entity_name": "Alice",
|
||||
"entity_type": "person",
|
||||
"description": "Alice is a researcher specializing in quantum physics.",
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"entity_name": "Bob",
|
||||
"entity_type": "person",
|
||||
"description": "Bob is a mathematician.",
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"entity_name": "Quantum Computing",
|
||||
"entity_type": "technology",
|
||||
"description": "Quantum computing utilizes quantum mechanical phenomena for computation.",
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
],
|
||||
"relationships": [
|
||||
{
|
||||
"src_id": "Alice",
|
||||
"tgt_id": "Bob",
|
||||
"description": "Alice and Bob are research partners.",
|
||||
"keywords": "collaboration research",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"src_id": "Alice",
|
||||
"tgt_id": "Quantum Computing",
|
||||
"description": "Alice conducts research on quantum computing.",
|
||||
"keywords": "research expertise",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
},
|
||||
{
|
||||
"src_id": "Bob",
|
||||
"tgt_id": "Quantum Computing",
|
||||
"description": "Bob researches quantum computing.",
|
||||
"keywords": "research application",
|
||||
"weight": 1.0,
|
||||
"source_id": "doc-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
rag.insert_custom_kg(custom_kg)
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Citation Functionality</b></summary>
|
||||
|
||||
@ -842,7 +852,8 @@ rag.delete_by_doc_id("doc_id")
|
||||
|
||||
LightRAG now supports comprehensive knowledge graph management capabilities, allowing you to create, edit, and delete entities and relationships within your knowledge graph.
|
||||
|
||||
### Create Entities and Relations
|
||||
<details>
|
||||
<summary> <b> Create Entities and Relations </b></summary>
|
||||
|
||||
```python
|
||||
# Create new entity
|
||||
@ -865,7 +876,10 @@ relation = rag.create_relation("Google", "Gmail", {
|
||||
})
|
||||
```
|
||||
|
||||
### Edit Entities and Relations
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> <b> Edit Entities and Relations </b></summary>
|
||||
|
||||
```python
|
||||
# Edit an existing entity
|
||||
@ -902,6 +916,8 @@ All operations are available in both synchronous and asynchronous versions. The
|
||||
|
||||
These operations maintain data consistency across both the graph database and vector database components, ensuring your knowledge graph remains coherent.
|
||||
|
||||
</details>
|
||||
|
||||
## Data Export Functions
|
||||
|
||||
### Overview
|
||||
@ -910,7 +926,8 @@ LightRAG allows you to export your knowledge graph data in various formats for a
|
||||
|
||||
### Export Functions
|
||||
|
||||
#### Basic Usage
|
||||
<details>
|
||||
<summary> <b> Basic Usage </b></summary>
|
||||
|
||||
```python
|
||||
# Basic CSV export (default format)
|
||||
@ -920,7 +937,10 @@ rag.export_data("knowledge_graph.csv")
|
||||
rag.export_data("output.xlsx", file_format="excel")
|
||||
```
|
||||
|
||||
#### Different File Formats supported
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> <b> Different File Formats supported </b></summary>
|
||||
|
||||
```python
|
||||
#Export data in CSV format
|
||||
@ -935,13 +955,18 @@ rag.export_data("graph_data.md", file_format="md")
|
||||
# Export data in Text
|
||||
rag.export_data("graph_data.txt", file_format="txt")
|
||||
```
|
||||
#### Additional Options
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> <b> Additional Options </b></summary>
|
||||
|
||||
Include vector embeddings in the export (optional):
|
||||
|
||||
```python
|
||||
rag.export_data("complete_data.csv", include_vector_data=True)
|
||||
```
|
||||
</details>
|
||||
|
||||
### Data Included in Export
|
||||
|
||||
All exports include:
|
||||
|
Loading…
x
Reference in New Issue
Block a user