Merge branch 'optimize-reranker'

This commit is contained in:
yangdx 2025-08-23 02:05:54 +08:00
commit 3b8a540e81
9 changed files with 14 additions and 22 deletions

View file

@ -87,11 +87,10 @@ ENABLE_LLM_CACHE=true
#########################################################
### Reranking configuration
### RERANK_BINDING type: cohere, jina, aliyun
### RERANK_BINDING type: null, cohere, jina, aliyun
### For rerank model deployed by vLLM use cohere binding
#########################################################
ENABLE_RERANK=False
RERANK_BINDING=cohere
RERANK_BINDING=null
### rerank score chunk filter(set to 0.0 to keep all chunks, 0.6 or above if LLM is not strong enought)
# MIN_RERANK_SCORE=0.0

View file

@ -1 +1 @@
__api_version__ = "0206"
__api_version__ = "0207"

View file

@ -228,15 +228,9 @@ def parse_args() -> argparse.Namespace:
"--rerank-binding",
type=str,
default=get_env_value("RERANK_BINDING", DEFAULT_RERANK_BINDING),
choices=["cohere", "jina", "aliyun"],
choices=["null", "cohere", "jina", "aliyun"],
help=f"Rerank binding type (default: from env or {DEFAULT_RERANK_BINDING})",
)
parser.add_argument(
"--enable-rerank",
action="store_true",
default=get_env_value("ENABLE_RERANK", False, bool),
help="Enable rerank functionality (default: from env or disalbed)",
)
# Conditionally add binding options defined in binding_options module
# This will add command line arguments for all binding options (e.g., --ollama-embedding-num_ctx)

View file

@ -393,7 +393,7 @@ def create_app(args):
# Configure rerank function based on enable_rerank parameter
rerank_model_func = None
if args.enable_rerank and args.rerank_binding:
if args.rerank_binding != "null":
from lightrag.rerank import cohere_rerank, jina_rerank, ali_rerank
# Map rerank binding to corresponding function
@ -651,13 +651,11 @@ def create_app(args):
"workspace": args.workspace,
"max_graph_nodes": args.max_graph_nodes,
# Rerank configuration
"enable_rerank": args.enable_rerank,
"rerank_binding": args.rerank_binding
if args.enable_rerank
else None,
"rerank_model": args.rerank_model if args.enable_rerank else None,
"enable_rerank": rerank_model_func is not None,
"rerank_binding": args.rerank_binding,
"rerank_model": args.rerank_model if rerank_model_func else None,
"rerank_binding_host": args.rerank_binding_host
if args.enable_rerank
if rerank_model_func
else None,
# Environment variable status (requested configuration)
"summary_language": args.summary_language,

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@
<link rel="icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lightrag</title>
<script type="module" crossorigin src="/webui/assets/index-B90LgL3h.js"></script>
<script type="module" crossorigin src="/webui/assets/index-B8PWUG__.js"></script>
<link rel="modulepreload" crossorigin href="/webui/assets/react-vendor-DEwriMA6.js">
<link rel="modulepreload" crossorigin href="/webui/assets/ui-vendor-CeCm8EER.js">
<link rel="modulepreload" crossorigin href="/webui/assets/graph-vendor-B-X5JegA.js">

View file

@ -33,7 +33,7 @@ DEFAULT_HISTORY_TURNS = 0
# Rerank configuration defaults
DEFAULT_MIN_RERANK_SCORE = 0.0
DEFAULT_RERANK_BINDING = "cohere"
DEFAULT_RERANK_BINDING = "null"
# File path configuration for vector and graph database(Should not be changed, used in Milvus Schema)
DEFAULT_MAX_FILE_PATH_LENGTH = 32768

View file

@ -43,6 +43,7 @@ export type LightragStatus = {
workspace?: string
max_graph_nodes?: string
enable_rerank?: boolean
rerank_binding?: string | null
rerank_model?: string | null
rerank_binding_host?: string | null
summary_language: string

View file

@ -52,7 +52,7 @@ const StatusCard = ({ status }: { status: LightragStatus | null }) => {
<span>{t('graphPanel.statusCard.rerankerBindingHost')}:</span>
<span>{status.configuration.rerank_binding_host || '-'}</span>
<span>{t('graphPanel.statusCard.rerankerModel')}:</span>
<span>{status.configuration.rerank_model || '-'}</span>
<span>{(status.configuration.rerank_binding || '-')} : {(status.configuration.rerank_model || '-')}</span>
</div>
</div>
)}