Skip to content

Conversation

@sanjeed5
Copy link
Contributor

@sanjeed5 sanjeed5 commented Nov 6, 2025

Summary

This PR updates the documentation for metrics to showcase the new ragas.metrics.collections API as the primary recommended approach, while preserving legacy API documentation for backward compatibility.

Changes

Metrics

  • AnswerAccuracy
  • AnswerCorrectness
  • AnswerRelevancy
  • AnswerSimilarity
  • BleuScore
  • ContextEntityRecall
  • ContextPrecision
  • ContextUtilization
  • Faithfulness
  • ContextRelevance
  • NoiseSensitivity
  • RougeScore
  • SemanticSimilarity
  • String metrics (ExactMatch, StringPresence, NonLLMStringSimilarity, DistanceMeasure)
  • SummaryScore

Documentation Pattern

Each metric documentation follows this structure:

  1. Primary Example: Collections-based API (modern, recommended)
  2. Concepts/How It's Calculated: Conceptual explanation (implementation-agnostic)
  3. Legacy Section: Original API for backward compatibility

Test Plan

  • Build docs locally to verify formatting
  • Test code examples to ensure they work
  • Verify all metrics from collections are documented

- Add new primary example using ragas.metrics.collections
- Show modern API with llm_factory and direct parameter passing
- Move legacy SingleTurnSample examples to Legacy section
- Relocate HHEM section to Legacy (no collections version yet)
- Add note about sync .score() method availability
- Legacy API will be deprecated in v0.4
- Complete removal planned for v1.0
- Added warning box to guide users to migrate
- Add new primary example using ragas.metrics.collections
- Show modern API with llm_factory and direct parameter passing
- Move legacy SingleTurnSample examples to Legacy section
- Add deprecation timeline (v0.4 deprecated, v1.0 removed)
- New example tested and verified to work correctly
Updated BleuScore section in traditional.md to:
- Show new collections-based API as primary example
- Add synchronous usage note
- Include configuration example for kwargs parameter
- Move legacy SingleTurnSample example to dedicated Legacy API section
- Add deprecation warning for legacy API

The new example was tested and produces the expected output.
…s API

- Add new primary example using collections-based API with llm_factory
- Include synchronous usage note for .score() method
- Move legacy SingleTurnSample example to Legacy Metrics API section
- Add deprecation timeline warning (v0.4 deprecated, v1.0 removed)
- Preserve conceptual explanation and "How It's Calculated" section
- Tested new example and verified it produces expected output
- Migrate primary example to use AnswerSimilarity from ragas.metrics.collections
- Use modern OpenAIEmbeddings instead of deprecated embedding_factory
- Add synchronous usage note for .score() method
- Move legacy SingleTurnSample example to "Legacy Metrics API" section
- Add deprecation timeline warning (v0.4 deprecation, v1.0 removal)
- Update terminology from "answer" to "response" for consistency
- Add step 4 to calculation explanation showing final score output
- Tested example successfully with no deprecation warnings
Updated answer_relevance.md to follow the new pattern:
- Added collections-based API example as primary example
- Improved structure with clearer title and description
- Added synchronous usage note
- Moved legacy SingleTurnSample example to "Legacy Metrics API" section
- Tested new example successfully
- Add examples for ContextPrecision and ContextUtilization using collections API
- Simplify documentation to show only user-facing metrics (removed wrapper details)
- Move legacy examples to deprecated section
- All examples tested and verified
- Add new collections-based API example at the top
- Add synchronous usage note
- Move legacy API examples to deprecated section
- Tested example and verified it works correctly
- Add new collections-based API example at the top
- Add synchronous usage note
- Preserve configuration section (rouge_type and mode)
- Move legacy API examples to Legacy Metrics API section with deprecation warning
- Tested example code and verified it produces expected output
- Updated example to use SemanticSimilarity from collections API
- Changed title from 'Answer Similarity' to 'Semantic Similarity' for consistency
- Added synchronous usage note
- Preserved 'How It's Calculated' section
- Moved legacy API examples to bottom with deprecation warning
- Tested example and verified it produces expected output
- Add new collections-based API example using SummaryScore from ragas.metrics.collections
- Include synchronous usage note with .score() method
- Add custom configuration example for length_penalty and coeff parameters
- Move legacy example to Legacy Metrics API section with deprecation warning
- Preserve all conceptual explanations and formulas
- Tested example code and verified it produces expected output
- Add primary example using collections-based API from ragas.metrics.collections
- Include examples for both 'relevant' and 'irrelevant' modes with outputs
- Add synchronous usage note
- Move legacy examples to Legacy Metrics API section with deprecation warning
- Preserve 'How It's Calculated' section and credits
- Tested example code and verified it works correctly
- Add collections-based API example with LLM and embeddings setup
- Move legacy evaluate() example to Legacy Metrics API section
- Add deprecation warning for legacy API
- Include synchronous usage note
- Tested example code and verified it works correctly

Note: Embeddings are required because default weights [0.75, 0.25]
include semantic similarity. See issue #2408 for making embeddings
optional when weights[1] == 0.
…Similarity) to collections API

- Updated NonLLMStringSimilarity with collections API example and configuration section
- Updated ExactMatch with collections API example
- Updated StringPresence with collections API example
- Added synchronous usage notes for all three metrics
- Moved legacy examples to Legacy Metrics API section with deprecation warnings
- All examples tested and verified to work correctly
@sanjeed5 sanjeed5 marked this pull request as ready for review November 7, 2025 12:38
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Nov 7, 2025
Reorder imports to follow Python conventions (alphabetical order, grouped by standard library, third-party, and local imports) and fix minor typo in Opik integration documentation.
@sanjeed5 sanjeed5 requested a review from anistark November 7, 2025 12:57
@anistark anistark merged commit 5b64f89 into main Nov 7, 2025
5 checks passed
@anistark anistark deleted the docs/metrics-collections branch November 7, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants