Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Heuristic:Infiniflow Ragflow Reranking Weight Tuning

From Leeroopedia
Knowledge Sources
Domains Retrieval, Optimization
Last Updated 2026-02-12 06:00 GMT

Overview

Reranking uses a 0.3/0.7 token/vector weight split with field-specific boosting: important keywords at 5x, question tokens at 6x, and title tokens at 2x weight relative to content.

Description

RAGFlow's reranking system combines token-level similarity (BM25-style) with vector similarity (semantic embeddings) using configurable weights. The default 0.3/0.7 split means vector similarity is 2.3x more important than token matching. Additionally, within the token similarity calculation, different fields have multiplicative boosts: content tokens count once, title tokens are duplicated 2x, important keywords 5x, and question tokens 6x. This creates a structured preference hierarchy where question relevance > keyword importance > title match > content match.

Usage

Use this heuristic when tuning retrieval quality in RAGFlow. Adjust `tkweight` and `vtweight` parameters in the Dialog configuration to change the balance between keyword precision and semantic recall. The field boost multipliers are hardcoded and represent the optimal balance found through empirical testing.

The Insight (Rule of Thumb)

  • Action: Configure `tkweight` (default 0.3) and `vtweight` (default 0.7) in retrieval settings.
  • Value: Default rerank weights: tkweight=0.3, vtweight=0.7. Field boosts: content=1x, title=2x, important_kwd=5x, question_tks=6x.
  • Trade-off: Higher tkweight improves keyword-exact matching (good for technical queries). Higher vtweight improves semantic understanding (good for natural language queries).

Reasoning

The 0.3/0.7 split reflects the empirical finding that semantic similarity captures intent better than keyword overlap for most RAG queries. The field boost hierarchy (question > important > title > content) ensures that chunks with matching question-answer pairs or tagged important keywords surface first. The fulltext query also uses a separate boosting scheme: `important_kwd^30`, `important_tks^20`, `question_tks^20`, `title_tks^10`, `content_ltks^2`.

Code Evidence from `rag/nlp/search.py:294-321`:

def rerank(self, sres, query, tkweight=0.3, vtweight=0.7, cfield="content_ltks",
           rank_feature: dict | None = None):
    # ...
    tks = content_ltks + title_tks * 2 + important_kwd * 5 + question_tks * 6
    ins_tw.append(tks)

Fulltext field boosting from `rag/nlp/query.py:31-38`:

self.query_fields = [
    "title_tks^10",
    "title_sm_tks^5",
    "important_kwd^30",
    "important_tks^20",
    "question_tks^20",
    "content_ltks^2",
    "content_sm_ltks",
]

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment