Skip to content

Add optional retrieval confidence metadata to RAG response thoughts#293

Open
Nithin00614 wants to merge 1 commit intoAzure-Samples:mainfrom
Nithin00614:feature/add-retrieval-confidence
Open

Add optional retrieval confidence metadata to RAG response thoughts#293
Nithin00614 wants to merge 1 commit intoAzure-Samples:mainfrom
Nithin00614:feature/add-retrieval-confidence

Conversation

@Nithin00614
Copy link
Copy Markdown

Add Retrieval Confidence Metadata

Problem

Currently, there's no visibility into the confidence/quality of retrieved items in RAG responses. This makes debugging and monitoring difficult.

Solution

Add optional, non-breaking metadata to track retrieval confidence:

  • Top retrieval score
  • Average retrieval score
  • Confidence threshold (configurable)
  • Confidence level classification (high/low)

Benefits

  • Non-breaking (backward compatible)
  • Helps debug low-quality retrievals
  • Provides metrics for monitoring
  • Configurable threshold via self.confidence_threshold

Changes

  • Added confidence calculation in answer() method
  • Added ThoughtStep with retrieval metrics
  • Safe handling for items without scores

Testing

  • Tested with items that have scores
  • Tested with items without scores
  • Verified backward compatibility
  • Checked ThoughtStep rendering

Example Output

{
  "title": "Retrieval Confidence",
  "props": {
    "top_score": 0.85,
    "avg_score": 0.72,
    "threshold": 0.7,
    "confidence_level": "high",
    "scored_items_count": 5
  }
}

@Nithin00614
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant