Skip to content

[P2-Enhancement] Add time-decay and source weighting to hybrid search #68

@VirtualAgentics

Description

@VirtualAgentics

Description

Enhance the hybrid search implementation with time-decay scoring and source weighting to improve search relevance and user experience.

Background

This enhancement extends Issue #58 (hybrid search) by adding sophisticated scoring factors that consider content freshness and source credibility, leading to more relevant search results.

Requirements

  • Implement time-decay scoring: score = α·sim + β·bm25 + γ·freshness + δ·source_weight
  • Add configurable weights for each scoring factor
  • Implement namespace-specific boost factors
  • Add source credibility scoring
  • Add freshness calculation based on document timestamps
  • Make scoring factors configurable via environment variables
  • Add unit tests for scoring calculations

Implementation Details

Files to modify:

  • src/contextforge_memory/search/ - Extend hybrid search service
  • src/contextforge_memory/config.py - Add scoring configuration
  • src/contextforge_memory/main.py - Add scoring parameters to search endpoint
  • tests/ - Add scoring tests
  • README.md - Document scoring parameters

Technical approach:

  • Extend existing hybrid search with additional scoring factors
  • Add configuration for α, β, γ, δ weights
  • Implement time-decay calculation based on document age
  • Add source weighting based on namespace or metadata
  • Create scoring explanation for debugging

Acceptance Criteria

  • Time-decay scoring works correctly with configurable weights
  • Source weighting improves result relevance
  • All scoring factors are configurable
  • Unit tests pass for scoring calculations
  • Documentation explains scoring parameters

Testing Requirements

  • Unit tests for each scoring factor
  • Integration tests for combined scoring
  • Performance tests for scoring overhead
  • Relevance tests with sample data

Documentation Updates

  • README.md - Document scoring parameters
  • API documentation - Search scoring options
  • Configuration guide - Scoring weights
  • Examples - Scoring configuration

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions