mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-12-04 19:06:51 +00:00
Update default query parameters for better performance
- Increase chunk_top_k from 10 to 20 - Reduce max_entity_tokens to 6000 - Reduce max_relation_tokens to 8000 - Update web UI default values - Fix max_total_tokens to 30000
This commit is contained in:
parent
8d7a7e4ad6
commit
d5e8f1e860
@ -308,15 +308,15 @@ class QueryParam:
|
|||||||
top_k: int = int(os.getenv("TOP_K", "60"))
|
top_k: int = int(os.getenv("TOP_K", "60"))
|
||||||
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
||||||
|
|
||||||
chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "10"))
|
chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "20"))
|
||||||
"""Number of text chunks to retrieve initially from vector search and keep after reranking.
|
"""Number of text chunks to retrieve initially from vector search and keep after reranking.
|
||||||
If None, defaults to top_k value.
|
If None, defaults to top_k value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "10000"))
|
max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "6000"))
|
||||||
"""Maximum number of tokens allocated for entity context in unified token control system."""
|
"""Maximum number of tokens allocated for entity context in unified token control system."""
|
||||||
|
|
||||||
max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "10000"))
|
max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "8000"))
|
||||||
"""Maximum number of tokens allocated for relationship context in unified token control system."""
|
"""Maximum number of tokens allocated for relationship context in unified token control system."""
|
||||||
|
|
||||||
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))
|
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))
|
||||||
|
|||||||
@ -315,15 +315,15 @@ class QueryParam:
|
|||||||
top_k: int = int(os.getenv("TOP_K", "60"))
|
top_k: int = int(os.getenv("TOP_K", "60"))
|
||||||
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
||||||
|
|
||||||
chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "10"))
|
chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "20"))
|
||||||
"""Number of text chunks to retrieve initially from vector search and keep after reranking.
|
"""Number of text chunks to retrieve initially from vector search and keep after reranking.
|
||||||
If None, defaults to top_k value.
|
If None, defaults to top_k value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "10000"))
|
max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "6000"))
|
||||||
"""Maximum number of tokens allocated for entity context in unified token control system."""
|
"""Maximum number of tokens allocated for entity context in unified token control system."""
|
||||||
|
|
||||||
max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "10000"))
|
max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "8000"))
|
||||||
"""Maximum number of tokens allocated for relationship context in unified token control system."""
|
"""Maximum number of tokens allocated for relationship context in unified token control system."""
|
||||||
|
|
||||||
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))
|
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))
|
||||||
|
|||||||
@ -64,11 +64,11 @@ ENABLE_LLM_CACHE=true
|
|||||||
### Number of entities or relations retrieved from KG
|
### Number of entities or relations retrieved from KG
|
||||||
# TOP_K=40
|
# TOP_K=40
|
||||||
### Maxmium number or chunks for naive vactor search
|
### Maxmium number or chunks for naive vactor search
|
||||||
# CHUNK_TOP_K=10
|
# CHUNK_TOP_K=20
|
||||||
### control the actual enties send to LLM
|
### control the actual enties send to LLM
|
||||||
# MAX_ENTITY_TOKENS=10000
|
# MAX_ENTITY_TOKENS=6000
|
||||||
### control the actual relations send to LLM
|
### control the actual relations send to LLM
|
||||||
# MAX_RELATION_TOKENS=10000
|
# MAX_RELATION_TOKENS=8000
|
||||||
### control the maximum tokens send to LLM (include entities, raltions and chunks)
|
### control the maximum tokens send to LLM (include entities, raltions and chunks)
|
||||||
# MAX_TOTAL_TOKENS=30000
|
# MAX_TOTAL_TOKENS=30000
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,9 @@ GRAPH_FIELD_SEP = "<SEP>"
|
|||||||
|
|
||||||
# Query and retrieval configuration defaults
|
# Query and retrieval configuration defaults
|
||||||
DEFAULT_TOP_K = 40
|
DEFAULT_TOP_K = 40
|
||||||
DEFAULT_CHUNK_TOP_K = 10
|
DEFAULT_CHUNK_TOP_K = 20
|
||||||
DEFAULT_MAX_ENTITY_TOKENS = 10000
|
DEFAULT_MAX_ENTITY_TOKENS = 6000
|
||||||
DEFAULT_MAX_RELATION_TOKENS = 10000
|
DEFAULT_MAX_RELATION_TOKENS = 8000
|
||||||
DEFAULT_MAX_TOTAL_TOKENS = 30000
|
DEFAULT_MAX_TOTAL_TOKENS = 30000
|
||||||
DEFAULT_COSINE_THRESHOLD = 0.2
|
DEFAULT_COSINE_THRESHOLD = 0.2
|
||||||
DEFAULT_RELATED_CHUNK_NUMBER = 5
|
DEFAULT_RELATED_CHUNK_NUMBER = 5
|
||||||
|
|||||||
@ -30,9 +30,9 @@ export default function QuerySettings() {
|
|||||||
mode: 'mix' as QueryMode,
|
mode: 'mix' as QueryMode,
|
||||||
response_type: 'Multiple Paragraphs',
|
response_type: 'Multiple Paragraphs',
|
||||||
top_k: 40,
|
top_k: 40,
|
||||||
chunk_top_k: 10,
|
chunk_top_k: 20,
|
||||||
max_entity_tokens: 10000,
|
max_entity_tokens: 6000,
|
||||||
max_relation_tokens: 10000,
|
max_relation_tokens: 8000,
|
||||||
max_total_tokens: 30000
|
max_total_tokens: 30000
|
||||||
}), [])
|
}), [])
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ export default function QuerySettings() {
|
|||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
if (value === '' || isNaN(parseInt(value))) {
|
if (value === '' || isNaN(parseInt(value))) {
|
||||||
handleChange('top_k', 1)
|
handleChange('top_k', 40)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
@ -219,7 +219,7 @@ export default function QuerySettings() {
|
|||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
if (value === '' || isNaN(parseInt(value))) {
|
if (value === '' || isNaN(parseInt(value))) {
|
||||||
handleChange('chunk_top_k', 1)
|
handleChange('chunk_top_k', 20)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
@ -259,7 +259,7 @@ export default function QuerySettings() {
|
|||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
if (value === '' || isNaN(parseInt(value))) {
|
if (value === '' || isNaN(parseInt(value))) {
|
||||||
handleChange('max_entity_tokens', 1000)
|
handleChange('max_entity_tokens', 6000)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
@ -299,7 +299,7 @@ export default function QuerySettings() {
|
|||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
if (value === '' || isNaN(parseInt(value))) {
|
if (value === '' || isNaN(parseInt(value))) {
|
||||||
handleChange('max_relation_tokens', 1000)
|
handleChange('max_relation_tokens', 8000)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
@ -339,7 +339,7 @@ export default function QuerySettings() {
|
|||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
if (value === '' || isNaN(parseInt(value))) {
|
if (value === '' || isNaN(parseInt(value))) {
|
||||||
handleChange('max_total_tokens', 32000)
|
handleChange('max_total_tokens', 30000)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
|
|||||||
@ -115,10 +115,10 @@ const useSettingsStoreBase = create<SettingsState>()(
|
|||||||
mode: 'global',
|
mode: 'global',
|
||||||
response_type: 'Multiple Paragraphs',
|
response_type: 'Multiple Paragraphs',
|
||||||
top_k: 40,
|
top_k: 40,
|
||||||
chunk_top_k: 10,
|
chunk_top_k: 20,
|
||||||
max_entity_tokens: 10000,
|
max_entity_tokens: 6000,
|
||||||
max_relation_tokens: 10000,
|
max_relation_tokens: 8000,
|
||||||
max_total_tokens: 32000,
|
max_total_tokens: 30000,
|
||||||
only_need_context: false,
|
only_need_context: false,
|
||||||
only_need_prompt: false,
|
only_need_prompt: false,
|
||||||
stream: true,
|
stream: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user