Update README.md

This commit is contained in:
yangdx
2025-05-09 10:43:19 +08:00
parent 0e3ecbfd6c
commit 11fa70f7d1
2 changed files with 13 additions and 13 deletions

View File

@@ -532,20 +532,20 @@ response = rag.query(
) )
``` ```
### 自定义用户提示词 ### 用户提示词 vs. 查询内容
自定义用户提示词不影响查询内容仅仅用于向LLM指示如何处理查询结果。以下是使用方法: 当使用LightRAG查询内容的时候不要把内容查询和与查询结果无关的输出加工写在一起。因为把两者混在一起会严重影响查询的效果。Query Param中的`user_prompt`就是为解决这一问题而设计的。`user_prompt`中的内容不参与RAG中的查询过程它仅会在获得查询结果之后与查询结果一起送给LLM指导LLM如何处理查询结果。以下是使用方法:
```python ```python
# 创建查询参数 # Create query parameters
query_param = QueryParam( query_param = QueryParam(
mode = "hybrid", # 或其他模式:"local"、"global"、"hybrid"、"mix"和"naive" mode = "hybrid", # Other modeslocal, global, hybrid, mix, naive
user_prompt = "Please create the diagram using the Mermaid syntax" user_prompt = "如需画图使用mermaid格式节点名称用英文或拼音显示名称用中文",
) )
# 查询和处理 # Query and process
response_default = rag.query( response_default = rag.query(
"Please draw a character relationship diagram for Scrooge", "请画出 Scrooge 的人物关系图谱",
param=query_param param=query_param
) )
print(response_default) print(response_default)
@@ -755,7 +755,7 @@ rag = LightRAG(
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype)); create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties); CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx; ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
-- 如有必要可以删除 -- 如有必要可以删除
drop INDEX entity_p_idx; drop INDEX entity_p_idx;
drop INDEX vertex_p_idx; drop INDEX vertex_p_idx;

View File

@@ -570,15 +570,15 @@ response = rag.query(
</details> </details>
### Custom User Prompt Support ### User Prompt vs. Query
Custom user prompts do not affect the query content; they are only used to instruct the LLM on how to handle the query results. Here's how to use it: 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:
```python ```python
# Create query parameters # Create query parameters
query_param = QueryParam( query_param = QueryParam(
mode = "hybrid", # 或其他模式:"local"、"global"、"hybrid"、"mix"和"naive" mode = "hybrid", # Other modeslocal, global, hybrid, mix, naive
user_prompt = "Please create the diagram using the Mermaid syntax" user_prompt = "For diagrams, use mermaid format with English/Pinyin node names and Chinese display labels",
) )
# Query and process # Query and process
@@ -759,7 +759,7 @@ For production level scenarios you will most likely want to leverage an enterpri
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype)); create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties); CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx; ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
-- drop if necessary -- drop if necessary
drop INDEX entity_p_idx; drop INDEX entity_p_idx;
drop INDEX vertex_p_idx; drop INDEX vertex_p_idx;