Skip to content

Commit

Permalink
feat: Add deprecation messages for all model-based metric classes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658523450
  • Loading branch information
vertex-sdk-bot authored and copybara-github committed Aug 1, 2024
1 parent 7f238fb commit 71c0fd3
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vertexai/preview/evaluation/metrics/_fluency.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@
# limitations under the License.
#
from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class `Fluency` will"
" result in an error. Please use string metric name `fluency` or define"
" a PointwiseMetric instead."
)


class Fluency(_base._ModelBasedMetric):
"""The model-based pointwise metric for Fluency."""

_metric_name = constants.Metric.FLUENCY

def __init__(self, *, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=Fluency._metric_name,
version=version,
Expand Down
9 changes: 9 additions & 0 deletions vertexai/preview/evaluation/metrics/_fulfillment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@
# limitations under the License.
#
from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class `Fulfillment` will"
" result in an error. Please use string metric name `fulfillment` or define"
" a PointwiseMetric instead."
)


class Fulfillment(_base._ModelBasedMetric):
"""The model-based pointwise metric for Fulfillment."""

_metric_name = constants.Metric.FULFILLMENT

def __init__(self, *, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=Fulfillment._metric_name,
version=version,
Expand Down
9 changes: 9 additions & 0 deletions vertexai/preview/evaluation/metrics/_groundedness.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@
# limitations under the License.
#
from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class `Groundedness` will"
" result in an error. Please use string metric name `groundedness` or define"
" a PointwiseMetric instead."
)


class Groundedness(_base._ModelBasedMetric):
"""The model-based pointwise metric for Groundedness."""

_metric_name = constants.Metric.GROUNDEDNESS

def __init__(self, *, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=Groundedness._metric_name,
version=version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@
#

from typing import Callable, Optional, Union
import warnings

from vertexai.generative_models import _generative_models
from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `PairwiseQuestionAnsweringQuality` will result in an error. Please use"
" string metric name `pairwise_question_answering_quality` or define a"
" PairwiseMetric instead."
)


class PairwiseQuestionAnsweringQuality(_base.PairwiseMetric):
"""The Side-by-side(SxS) Pairwise Metric for Question Answering Quality."""
Expand All @@ -35,6 +44,7 @@ def __init__(
use_reference: bool = False,
version: Optional[int] = None
):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=PairwiseQuestionAnsweringQuality._metric_name,
baseline_model=baseline_model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@
#

from typing import Callable, Optional, Union
import warnings

from vertexai.generative_models import _generative_models
from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `PairwiseSummarizationQuality` will result in an error. Please use"
" string metric name `pairwise_summarization_quality` or define a"
" PairwiseMetric instead."
)


class PairwiseSummarizationQuality(_base.PairwiseMetric):
"""The Side-by-side(SxS) Pairwise Metric for summarization quality."""
Expand All @@ -35,6 +44,7 @@ def __init__(
use_reference: bool = False,
version: Optional[int] = None
):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=PairwiseSummarizationQuality._metric_name,
baseline_model=baseline_model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `QuestionAnsweringCorrectness` will result in an error. Please use"
" string metric name `question_answering_correctness` or define a"
" PointwiseMetric instead."
)


class QuestionAnsweringCorrectness(_base._ModelBasedMetric):
"""The model-based pointwise metric for Question Answering Correctness."""

_metric_name = constants.Metric.QUESTION_ANSWERING_CORRECTNESS

def __init__(self, *, use_reference: bool = True, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=QuestionAnsweringCorrectness._metric_name,
use_reference=use_reference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `QuestionAnsweringHelpfulness` will result in an error. Please use"
" string metric name `question_answering_helpfulness` or define a"
" PointwiseMetric instead."
)


class QuestionAnsweringHelpfulness(_base._ModelBasedMetric):
"""The model-based pointwise metric for Question Answering Helpfulness."""

_metric_name = constants.Metric.QUESTION_ANSWERING_HELPFULNESS

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=QuestionAnsweringHelpfulness._metric_name,
use_reference=use_reference,
Expand Down
10 changes: 10 additions & 0 deletions vertexai/preview/evaluation/metrics/_question_answering_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `QuestionAnsweringQuality` will result in an error. Please use"
" string metric name `question_answering_quality` or define a"
" PointwiseMetric instead."
)


class QuestionAnsweringQuality(_base._ModelBasedMetric):
"""The model-based pointwise metric for Question Answering Quality."""

_metric_name = constants.Metric.QUESTION_ANSWERING_QUALITY

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=QuestionAnsweringQuality._metric_name,
use_reference=use_reference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `QuestionAnsweringRelevance` will result in an error. Please use"
" string metric name `question_answering_relevance` or define a"
" PointwiseMetric instead."
)


class QuestionAnsweringRelevance(_base._ModelBasedMetric):
"""The model-based pointwise metric for Question Answering Relevance."""

_metric_name = constants.Metric.QUESTION_ANSWERING_RELEVANCE

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=QuestionAnsweringRelevance._metric_name,
use_reference=use_reference,
Expand Down
10 changes: 10 additions & 0 deletions vertexai/preview/evaluation/metrics/_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,26 @@
# limitations under the License.
#
from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `Safety` will result in an error. Please use"
" string metric name `safety` or define a"
" PointwiseMetric instead."
)


class Safety(_base._ModelBasedMetric):
"""The model-based pointwise metric for Safety."""

_metric_name = constants.Metric.SAFETY

def __init__(self, *, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=Safety._metric_name,
version=version,
Expand Down
10 changes: 10 additions & 0 deletions vertexai/preview/evaluation/metrics/_summarization_helpfulness.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `SummarizationHelpfulness` will result in an error. Please use"
" string metric name `summarization_helpfulness` or define a"
" PointwiseMetric instead."
)


class SummarizationHelpfulness(_base._ModelBasedMetric):
"""The model-based pointwise metric for Summarization Helpfulness."""

_metric_name = constants.Metric.SUMMARIZATION_HELPFULNESS

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=SummarizationHelpfulness._metric_name,
use_reference=use_reference,
Expand Down
10 changes: 10 additions & 0 deletions vertexai/preview/evaluation/metrics/_summarization_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `SummarizationQuality` will result in an error. Please use"
" string metric name `summarization_quality` or define a"
" PointwiseMetric instead."
)


class SummarizationQuality(_base._ModelBasedMetric):
"""The model-based pointwise metric for Summarization Quality."""

_metric_name = constants.Metric.SUMMARIZATION_QUALITY

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=SummarizationQuality._metric_name,
use_reference=use_reference,
Expand Down
10 changes: 10 additions & 0 deletions vertexai/preview/evaluation/metrics/_summarization_verbosity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#

from typing import Optional
import warnings

from vertexai.preview.evaluation import constants
from vertexai.preview.evaluation.metrics import _base

_DEPRECATION_WARNING_MESSAGE = (
"After google-cloud-aiplatform>1.63.0, using metric class"
" `SummarizationVerbosity` will result in an error. Please use"
" string metric name `summarization_verbosity` or define a"
" PointwiseMetric instead."
)


class SummarizationVerbosity(_base._ModelBasedMetric):
"""The model-based pointwise metric for Summarization Verbosity."""

_metric_name = constants.Metric.SUMMARIZATION_VERBOSITY

def __init__(self, *, use_reference: bool = False, version: Optional[int] = None):
warnings.warn(message=_DEPRECATION_WARNING_MESSAGE)
super().__init__(
metric=SummarizationVerbosity._metric_name,
use_reference=use_reference,
Expand Down

0 comments on commit 71c0fd3

Please sign in to comment.