You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update ResponseGroundedness metric documentation to Collections API
- Added new primary example using collections-based API with ResponseGroundedness
- Added synchronous usage note with .score() method
- Moved legacy SingleTurnSample example to Legacy Metrics API section
- Tested new example and verified it produces expected output (score: 1.0)
If you prefer synchronous code, you can use the `.score()` method instead of `.ascore()`:
284
+
285
+
```python
286
+
result = scorer.score(
287
+
response="Albert Einstein was born in 1879.",
288
+
retrieved_contexts=[...]
289
+
)
290
+
```
291
+
273
292
### How It’s Calculated
274
293
275
294
**Step 1:** The LLM is prompted with two distinct templates to evaluate the grounding of the response with respect to the retrieved contexts. Each prompt returns a grounding rating of **0**, **1**, or **2**.
@@ -299,3 +318,35 @@ In this example, the retrieved contexts provide both the birthdate and location
299
318
-**Token Usage:** Faithfulness consumes more tokens, whereas Response Groundedness is more token-efficient.
300
319
-**Explainability:** Faithfulness provides transparent, reasoning for each claim, while Response Groundedness provides a raw score.
301
320
-**Robust Evaluation:** Faithfulness incorporates user input for a comprehensive assessment, whereas Response Groundedness ensures consistency through dual LLM evaluations.
321
+
322
+
### Legacy Metrics API
323
+
324
+
The following examples use the legacy metrics API pattern. For new projects, we recommend using the collections-based API shown above.
325
+
326
+
!!! warning "Deprecation Timeline"
327
+
This API will be deprecated in version 0.4 and removed in version 1.0. Please migrate to the collections-based API shown above.
328
+
329
+
#### Example with SingleTurnSample
330
+
331
+
```python
332
+
from ragas.dataset_schema import SingleTurnSample
333
+
from ragas.metrics import ResponseGroundedness
334
+
335
+
sample = SingleTurnSample(
336
+
response="Albert Einstein was born in 1879.",
337
+
retrieved_contexts=[
338
+
"Albert Einstein was born March 14, 1879.",
339
+
"Albert Einstein was born at Ulm, in Württemberg, Germany.",
0 commit comments