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:
yangdx 2025-08-18 19:32:11 +08:00
parent 8d7a7e4ad6
commit d5e8f1e860
6 changed files with 24 additions and 24 deletions

View File

@ -308,15 +308,15 @@ class QueryParam:
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."""
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.
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."""
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."""
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))

View File

@ -315,15 +315,15 @@ class QueryParam:
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."""
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.
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."""
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."""
max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000"))

View File

@ -64,11 +64,11 @@ ENABLE_LLM_CACHE=true
### Number of entities or relations retrieved from KG
# TOP_K=40
### Maxmium number or chunks for naive vactor search
# CHUNK_TOP_K=10
# CHUNK_TOP_K=20
### control the actual enties send to LLM
# MAX_ENTITY_TOKENS=10000
# MAX_ENTITY_TOKENS=6000
### 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)
# MAX_TOTAL_TOKENS=30000

View File

@ -21,9 +21,9 @@ GRAPH_FIELD_SEP = "<SEP>"
# Query and retrieval configuration defaults
DEFAULT_TOP_K = 40
DEFAULT_CHUNK_TOP_K = 10
DEFAULT_MAX_ENTITY_TOKENS = 10000
DEFAULT_MAX_RELATION_TOKENS = 10000
DEFAULT_CHUNK_TOP_K = 20
DEFAULT_MAX_ENTITY_TOKENS = 6000
DEFAULT_MAX_RELATION_TOKENS = 8000
DEFAULT_MAX_TOTAL_TOKENS = 30000
DEFAULT_COSINE_THRESHOLD = 0.2
DEFAULT_RELATED_CHUNK_NUMBER = 5

View File

@ -30,9 +30,9 @@ export default function QuerySettings() {
mode: 'mix' as QueryMode,
response_type: 'Multiple Paragraphs',
top_k: 40,
chunk_top_k: 10,
max_entity_tokens: 10000,
max_relation_tokens: 10000,
chunk_top_k: 20,
max_entity_tokens: 6000,
max_relation_tokens: 8000,
max_total_tokens: 30000
}), [])
@ -179,7 +179,7 @@ export default function QuerySettings() {
onBlur={(e) => {
const value = e.target.value
if (value === '' || isNaN(parseInt(value))) {
handleChange('top_k', 1)
handleChange('top_k', 40)
}
}}
min={1}
@ -219,7 +219,7 @@ export default function QuerySettings() {
onBlur={(e) => {
const value = e.target.value
if (value === '' || isNaN(parseInt(value))) {
handleChange('chunk_top_k', 1)
handleChange('chunk_top_k', 20)
}
}}
min={1}
@ -259,7 +259,7 @@ export default function QuerySettings() {
onBlur={(e) => {
const value = e.target.value
if (value === '' || isNaN(parseInt(value))) {
handleChange('max_entity_tokens', 1000)
handleChange('max_entity_tokens', 6000)
}
}}
min={1}
@ -299,7 +299,7 @@ export default function QuerySettings() {
onBlur={(e) => {
const value = e.target.value
if (value === '' || isNaN(parseInt(value))) {
handleChange('max_relation_tokens', 1000)
handleChange('max_relation_tokens', 8000)
}
}}
min={1}
@ -339,7 +339,7 @@ export default function QuerySettings() {
onBlur={(e) => {
const value = e.target.value
if (value === '' || isNaN(parseInt(value))) {
handleChange('max_total_tokens', 32000)
handleChange('max_total_tokens', 30000)
}
}}
min={1}

View File

@ -115,10 +115,10 @@ const useSettingsStoreBase = create<SettingsState>()(
mode: 'global',
response_type: 'Multiple Paragraphs',
top_k: 40,
chunk_top_k: 10,
max_entity_tokens: 10000,
max_relation_tokens: 10000,
max_total_tokens: 32000,
chunk_top_k: 20,
max_entity_tokens: 6000,
max_relation_tokens: 8000,
max_total_tokens: 30000,
only_need_context: false,
only_need_prompt: false,
stream: true,