Skip to content

Conversation

@suraj-phanindra
Copy link
Owner

Replace pure semantic similarity threshold with intelligent two-stage approach:

Stage 1: Semantic search using embeddings to get top candidates (fast filter)
Stage 2: LLM-based evaluation to select truly relevant facts (smart filter)

Key Changes:

  • Add ContextInjectionAgent using LlamaIndex workflow
  • Agent analyzes query context and candidate facts
  • Makes nuanced decisions about relevance vs. noise
  • Understands contextual connections beyond vector similarity
  • More selective: only injects facts that genuinely improve conversation

Updated retrieval_agent.py:

  • Integrate ContextInjectionAgent into ContextRetrievalAgent
  • Lower semantic threshold (0.3) to give agent more candidates
  • Pass top 10-15 candidates to injection agent for evaluation
  • Maintain backward compatibility with use_agent=False flag

Benefits:

  • Reduces irrelevant context injection
  • Better understands nuanced relevance
  • Improves conversation quality across platforms
  • More intelligent than fixed similarity thresholds

Replace pure semantic similarity threshold with intelligent two-stage approach:

Stage 1: Semantic search using embeddings to get top candidates (fast filter)
Stage 2: LLM-based evaluation to select truly relevant facts (smart filter)

Key Changes:
- Add ContextInjectionAgent using LlamaIndex workflow
- Agent analyzes query context and candidate facts
- Makes nuanced decisions about relevance vs. noise
- Understands contextual connections beyond vector similarity
- More selective: only injects facts that genuinely improve conversation

Updated retrieval_agent.py:
- Integrate ContextInjectionAgent into ContextRetrievalAgent
- Lower semantic threshold (0.3) to give agent more candidates
- Pass top 10-15 candidates to injection agent for evaluation
- Maintain backward compatibility with use_agent=False flag

Benefits:
- Reduces irrelevant context injection
- Better understands nuanced relevance
- Improves conversation quality across platforms
- More intelligent than fixed similarity thresholds
@suraj-phanindra suraj-phanindra self-assigned this Nov 18, 2025
@suraj-phanindra suraj-phanindra added the enhancement New feature or request label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants