Incorrect class name in deprecation warning for LLMContextPrecisionWithoutReference
Bug Description
The deprecation warning for LLMContextPrecisionWithoutReference tells users to run:
from ragas.metrics.collections import LLMContextPrecisionWithoutReference
But that class does not exist, which causes an ImportError when users follow the warning.
Expected Behavior
The warning should point to the correct class name:
from ragas.metrics.collections import ContextPrecisionWithoutReference
Environment
- ragas: 0.4.3
- langchain-community: 0.4.2
- langchain-google-vertexai: 3.2.3
- langchain-core: 1.4.0
- langchain: 1.3.1
Fix
Already fixed in PR #2746
This kind of import mismatch is a classic gotcha, especially when deprecating classes in evolving libraries like ragas. We've run into similar issues when renaming metrics in production pipelines for RAG systems—import errors can cascade and cause bigger failures downstream. Since the fix is already merged in #2746, a good quick workaround is to directly import ContextPrecisionWithoutReference instead, as you pointed out. Also, double-check the version of ragas in your environment; I've seen version mismatches where the warning was still old even after upgrading. For anyone hitting this, pinning ragas to 0.4.4 or later should resolve the problem until this fix lands on PyPI.
Confirmed this — when using LLMContextPrecisionWithoutReference in an eval pipeline the deprecation warning references the wrong class name, which makes it hard to know what to migrate to.
For anyone hitting this now, the correct replacement is LLMContextPrecision from ragas.metrics. Adding filterwarnings as a temporary workaround:
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning, module='ragas')
Not ideal — would be good to get the class name corrected in the warning message so the migration path is clear.
Hi 👋 — I can reproduce this on current main: the warning suggests from ragas.metrics.collections import LLMContextPrecisionWithoutReference, but the v2 class is ContextPrecisionWithoutReference, so following the example raises ImportError. (Side note: the "already fixed in #2746" mention above looks mistaken — #2746 was the langchain-vertexai import fix.)
While checking, I found it's systemic: the deprecation shim in src/ragas/metrics/__init__.py reuses the legacy name in the "Example:" line for all 54 deprecated names, and 22 of them don't exist under that name in ragas.metrics.collections (e.g. ChrfScore → CHRFScore, ResponseRelevancy → AnswerRelevancy, TopicAdherenceScore → TopicAdherence — plus names like FaithfulnesswithHHEM and the NonLLM*/IDBased* variants that have no collections equivalent at all).
I'd like to pick this up: map each renamed legacy name to its verified collections equivalent (checked against the class definitions on both sides), and for the ones with no equivalent, say so in the warning instead of suggesting a broken import. I'd also add a parametrized regression test asserting every suggested import actually resolves.