Skip to content

Fix: Reranker fails with missing template - needs fallback or template seeding #459

@manavgup

Description

@manavgup

Problem

When reranking is enabled (ENABLE_RERANKING=True, which is the default), the system fails with:

ValueError: Template is required for batch generation
  File: rag_solution/generation/providers/watsonx.py:218

Root Cause

  1. Reranking is enabled by default in core/config.py:143
  2. LLMReranker requires a PromptTemplateType.RERANKING template from database
  3. No reranking template exists in database for users (not seeded during initialization)
  4. Fallback to SimpleReranker exists in code but fails before it can trigger

Impact

  • Severity: HIGH - Blocks all search operations when reranking enabled
  • Workaround: Disable reranking (ENABLE_RERANKING=False)

Proposed Solutions

Option 1: Seed Default Reranking Template (Recommended)

Add reranking template to database initialization

Option 2: Hardcode Fallback Template

Add default template in LLMReranker.__init__()

Option 3: Better Fallback Logic

Fix SearchService.get_reranker() to catch template errors earlier

Files Involved

  • backend/rag_solution/services/search_service.py:172-237
  • backend/rag_solution/retrieval/reranker.py:60-84
  • backend/rag_solution/generation/providers/watsonx.py:194-227
  • backend/core/config.py:143

Temporary Fix Applied

Changed default to ENABLE_RERANKING=False in core/config.py:143

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions