Skip to content

Complete RAG Pattern Variants (Conversational, Multi-Query, Hybrid) #61

@charlesgreen

Description

@charlesgreen

Problem Statement

Three RAG variants are stubbed and just return basic RAG without implementing their advertised functionality:

  1. Conversational RAG - History parameter completely ignored
  2. Multi-Query RAG - Query expander parameter ignored
  3. Hybrid RAG - Keyword retriever ignored, only semantic used

Current Behavior

File: internal/orchestration/rag.go

Conversational RAG (line 150)

func NewConversationalRAG(..., historyAgent string) *RAG {
    // TODO: Implement conversation history tracking
    return NewRAG(name, runtime, retriever, generator)  // historyAgent ignored!
}

Multi-Query RAG (line 156)

func NewMultiQueryRAG(..., queryExpander, retriever, generator string) *RAG {
    // TODO: Implement multi-query expansion
    return NewRAG(name, runtime, retriever, generator)  // queryExpander ignored!
}

Hybrid RAG (line 162)

func NewHybridRAG(..., semanticRetriever, keywordRetriever, generator string) *RAG {
    // TODO: Implement hybrid retrieval
    return NewRAG(name, runtime, semanticRetriever, generator)  // keywordRetriever ignored!
}

Expected Behavior

Conversational RAG

  • Track conversation history with configurable window
  • Include conversation context in retrieval query
  • Support history compression for long conversations
  • Optional history persistence

Multi-Query RAG

  • Generate 3-5 query variations using query expander
  • Retrieve documents for all variations
  • Deduplicate and merge results
  • Configurable number of expansions

Hybrid RAG

  • Run semantic and keyword retrievers in parallel
  • Merge with rank fusion (RRF or weighted)
  • Configurable fusion weights
  • Support different retrievers per mode

Acceptance Criteria

Conversational RAG

  • History agent receives and stores conversation messages
  • Query reformulation considers previous N messages
  • Retrieved documents account for conversational context
  • Integration test demonstrates multi-turn coherence

Multi-Query RAG

  • Query expander generates N diverse variations
  • All variations used for retrieval
  • Results deduplicated by document ID
  • Parallel execution for performance

Hybrid RAG

  • Both retrievers execute in parallel
  • Results merged with reciprocal rank fusion
  • Combined results improve recall
  • Benchmarks show quality improvement

Implementation Hints

Conversational History

type ConversationHistory struct {
    Messages []agent.Message
    MaxDepth int
}

// Retrieve with query + context from last N messages

Multi-Query Expansion

prompt := fmt.Sprintf("Generate 5 diverse queries capturing different aspects of: %s", originalQuery)

Reciprocal Rank Fusion

// score = sum(1/(k + rank_i))
func reciprocalRankFusion(results [][]Document, k int) []Document {
    scores := make(map[string]float64)
    for _, resultSet := range results {
        for rank, doc := range resultSet {
            scores[doc.ID] += 1.0 / float64(k + rank)
        }
    }
    // Sort by score and return
}

Dependencies

Impact

High - These variants enable enterprise-grade RAG applications with better relevance and recall

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority - important featuresenhancementNew feature or requestorchestrationOrchestration patternsragRAG patternstubStubbed/incomplete implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions