Update README.md
Browse files- README-zh.md +8 -8
- README.md +5 -5
README-zh.md
CHANGED
@@ -532,20 +532,20 @@ response = rag.query(
|
|
532 |
)
|
533 |
```
|
534 |
|
535 |
-
###
|
536 |
|
537 |
-
|
538 |
|
539 |
```python
|
540 |
-
#
|
541 |
query_param = QueryParam(
|
542 |
-
mode = "hybrid", #
|
543 |
-
user_prompt = "
|
544 |
)
|
545 |
|
546 |
-
#
|
547 |
response_default = rag.query(
|
548 |
-
"
|
549 |
param=query_param
|
550 |
)
|
551 |
print(response_default)
|
@@ -755,7 +755,7 @@ rag = LightRAG(
|
|
755 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
756 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
757 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
758 |
-
|
759 |
-- 如有必要可以删除
|
760 |
drop INDEX entity_p_idx;
|
761 |
drop INDEX vertex_p_idx;
|
|
|
532 |
)
|
533 |
```
|
534 |
|
535 |
+
### 用户提示词 vs. 查询内容
|
536 |
|
537 |
+
当使用LightRAG查询内容的时候,不要把内容查询和与查询结果无关的输出加工写在一起。因为把两者混在一起会严重影响查询的效果。Query Param中的`user_prompt`就是为解决这一问题而设计的。`user_prompt`中的内容不参与RAG中的查询过程,它仅会在获得查询结果之后,与查询结果一起送给LLM,指导LLM如何处理查询结果。以下是使用方法:
|
538 |
|
539 |
```python
|
540 |
+
# Create query parameters
|
541 |
query_param = QueryParam(
|
542 |
+
mode = "hybrid", # Other modes:local, global, hybrid, mix, naive
|
543 |
+
user_prompt = "如需画图使用mermaid格式,节点名称用英文或拼音,显示名称用中文",
|
544 |
)
|
545 |
|
546 |
+
# Query and process
|
547 |
response_default = rag.query(
|
548 |
+
"请画出 Scrooge 的人物关系图谱",
|
549 |
param=query_param
|
550 |
)
|
551 |
print(response_default)
|
|
|
755 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
756 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
757 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
758 |
+
|
759 |
-- 如有必要可以删除
|
760 |
drop INDEX entity_p_idx;
|
761 |
drop INDEX vertex_p_idx;
|
README.md
CHANGED
@@ -570,15 +570,15 @@ response = rag.query(
|
|
570 |
|
571 |
</details>
|
572 |
|
573 |
-
###
|
574 |
|
575 |
-
|
576 |
|
577 |
```python
|
578 |
# Create query parameters
|
579 |
query_param = QueryParam(
|
580 |
-
mode = "hybrid", #
|
581 |
-
user_prompt = "
|
582 |
)
|
583 |
|
584 |
# Query and process
|
@@ -759,7 +759,7 @@ For production level scenarios you will most likely want to leverage an enterpri
|
|
759 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
760 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
761 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
762 |
-
|
763 |
-- drop if necessary
|
764 |
drop INDEX entity_p_idx;
|
765 |
drop INDEX vertex_p_idx;
|
|
|
570 |
|
571 |
</details>
|
572 |
|
573 |
+
### User Prompt vs. Query
|
574 |
|
575 |
+
When using LightRAG for content queries, avoid combining the search process with unrelated output processing, as this significantly impacts query effectiveness. The `user_prompt` parameter in Query Param is specifically designed to address this issue — it does not participate in the RAG retrieval phase, but rather guides the LLM on how to process the retrieved results after the query is completed. Here's how to use it:
|
576 |
|
577 |
```python
|
578 |
# Create query parameters
|
579 |
query_param = QueryParam(
|
580 |
+
mode = "hybrid", # Other modes:local, global, hybrid, mix, naive
|
581 |
+
user_prompt = "For diagrams, use mermaid format with English/Pinyin node names and Chinese display labels",
|
582 |
)
|
583 |
|
584 |
# Query and process
|
|
|
759 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
760 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
761 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
762 |
+
|
763 |
-- drop if necessary
|
764 |
drop INDEX entity_p_idx;
|
765 |
drop INDEX vertex_p_idx;
|