Update documentation with LLM selection guidelines and API improvements

This commit is contained in:
yangdx 2025-08-21 13:59:14 +08:00
parent 4b2ef71c25
commit 62cdc7d7eb
4 changed files with 15 additions and 2 deletions

View file

@ -142,6 +142,8 @@ LightRAG对大型语言模型LLM的能力要求远高于传统RAG因为
- **LLM选型** - **LLM选型**
- 推荐选用参数量至少为32B的LLM。 - 推荐选用参数量至少为32B的LLM。
- 上下文长度至少为32KB推荐达到64KB。 - 上下文长度至少为32KB推荐达到64KB。
- 在文档索引阶段不建议选择推理模型。
- 在查询阶段建议选择比索引阶段能力更强的模型,以达到更高的查询效果。
- **Embedding模型** - **Embedding模型**
- 高性能的Embedding模型对RAG至关重要。 - 高性能的Embedding模型对RAG至关重要。
- 推荐使用主流的多语言Embedding模型例如BAAI/bge-m3 和 text-embedding-3-large。 - 推荐使用主流的多语言Embedding模型例如BAAI/bge-m3 和 text-embedding-3-large。

View file

@ -141,6 +141,8 @@ LightRAG's demands on the capabilities of Large Language Models (LLMs) are signi
- **LLM Selection**: - **LLM Selection**:
- It is recommended to use an LLM with at least 32 billion parameters. - It is recommended to use an LLM with at least 32 billion parameters.
- The context length should be at least 32KB, with 64KB being recommended. - The context length should be at least 32KB, with 64KB being recommended.
- It is not recommended to choose reasoning models during the document indexing stage.
- During the query stage, it is recommended to choose models with stronger capabilities than those used in the indexing stage to achieve better query results.
- **Embedding Model**: - **Embedding Model**:
- A high-performance Embedding model is essential for RAG. - A high-performance Embedding model is essential for RAG.
- We recommend using mainstream multilingual Embedding models, such as: `BAAI/bge-m3` and `text-embedding-3-large`. - We recommend using mainstream multilingual Embedding models, such as: `BAAI/bge-m3` and `text-embedding-3-large`.
@ -1287,8 +1289,10 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
), ),
) )
) )
# Initialize storage (this will load existing data if available) # Initialize storage (this will load existing data if available)
await lightrag_instance.initialize_storages() await lightrag_instance.initialize_storages()
# Now initialize RAGAnything with the existing LightRAG instance # Now initialize RAGAnything with the existing LightRAG instance
rag = RAGAnything( rag = RAGAnything(
lightrag=lightrag_instance, # Pass the existing LightRAG instance lightrag=lightrag_instance, # Pass the existing LightRAG instance
@ -1317,12 +1321,14 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
) )
# Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance # Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
) )
# Query the existing knowledge base # Query the existing knowledge base
result = await rag.query_with_multimodal( result = await rag.query_with_multimodal(
"What data has been processed in this LightRAG instance?", "What data has been processed in this LightRAG instance?",
mode="hybrid" mode="hybrid"
) )
print("Query result:", result) print("Query result:", result)
# Add new multimodal documents to the existing LightRAG instance # Add new multimodal documents to the existing LightRAG instance
await rag.process_document_complete( await rag.process_document_complete(
file_path="path/to/new/multimodal_document.pdf", file_path="path/to/new/multimodal_document.pdf",

View file

@ -357,7 +357,7 @@ API 服务器可以通过三种方式配置(优先级从高到低):
LightRAG 支持绑定到各种 LLM/嵌入后端: LightRAG 支持绑定到各种 LLM/嵌入后端:
* ollama * ollama
* openai 和 openai 兼容 * openai (含openai 兼容)
* azure_openai * azure_openai
* lollms * lollms
* aws_bedrock * aws_bedrock
@ -372,7 +372,10 @@ lightrag-server --llm-binding ollama --help
lightrag-server --embedding-binding ollama --help lightrag-server --embedding-binding ollama --help
``` ```
> 请使用openai兼容方式访问OpenRouter或vLLM部署的LLM。可以通过 `OPENAI_LLM_EXTRA_BODY` 环境变量给OpenRouter或vLLM传递额外的参数实现推理模式的关闭或者其它个性化控制。
### 实体提取配置 ### 实体提取配置
* ENABLE_LLM_CACHE_FOR_EXTRACT为实体提取启用 LLM 缓存默认true * ENABLE_LLM_CACHE_FOR_EXTRACT为实体提取启用 LLM 缓存默认true
在测试环境中将 `ENABLE_LLM_CACHE_FOR_EXTRACT` 设置为 true 以减少 LLM 调用成本是很常见的做法。 在测试环境中将 `ENABLE_LLM_CACHE_FOR_EXTRACT` 设置为 true 以减少 LLM 调用成本是很常见的做法。

View file

@ -360,7 +360,7 @@ Most of the configurations come with default settings; check out the details in
LightRAG supports binding to various LLM/Embedding backends: LightRAG supports binding to various LLM/Embedding backends:
* ollama * ollama
* openai & openai compatible * openai (including openai compatible)
* azure_openai * azure_openai
* lollms * lollms
* aws_bedrock * aws_bedrock
@ -374,6 +374,8 @@ lightrag-server --llm-binding ollama --help
lightrag-server --embedding-binding ollama --help lightrag-server --embedding-binding ollama --help
``` ```
> Please use OpenAI-compatible method to access LLMs deployed by OpenRouter or vLLM. You can pass additional parameters to OpenRouter or vLLM through the `OPENAI_LLM_EXTRA_BODY` environment variable to disable reasoning mode or achieve other personalized controls.
### Entity Extraction Configuration ### Entity Extraction Configuration
* ENABLE_LLM_CACHE_FOR_EXTRACT: Enable LLM cache for entity extraction (default: true) * ENABLE_LLM_CACHE_FOR_EXTRACT: Enable LLM cache for entity extraction (default: true)