-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 12 model-based pointwise metric classes to `vertexai.previe…
…w.evaluation.metrics` PiperOrigin-RevId: 644484669
- Loading branch information
1 parent
04e07db
commit 4742a87
Showing
14 changed files
with
525 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
class Coherence(_base._ModelBasedMetric): | ||
"""The model-based pointwise metric for Coherence.""" | ||
|
||
_metric_name = constants.Metric.COHERENCE | ||
|
||
def __init__(self, *, version: Optional[int] = None): | ||
super().__init__( | ||
metric=Coherence._metric_name, | ||
version=version, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
class Fluency(_base._ModelBasedMetric): | ||
"""The model-based pointwise metric for Fluency.""" | ||
|
||
_metric_name = constants.Metric.FLUENCY | ||
|
||
def __init__(self, *, version: Optional[int] = None): | ||
super().__init__( | ||
metric=Fluency._metric_name, | ||
version=version, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
class Fulfillment(_base._ModelBasedMetric): | ||
"""The model-based pointwise metric for Fulfillment.""" | ||
|
||
_metric_name = constants.Metric.FULFILLMENT | ||
|
||
def __init__(self, *, version: Optional[int] = None): | ||
super().__init__( | ||
metric=Fulfillment._metric_name, | ||
version=version, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
class Groundedness(_base._ModelBasedMetric): | ||
"""The model-based pointwise metric for Groundedness.""" | ||
|
||
_metric_name = constants.Metric.GROUNDEDNESS | ||
|
||
def __init__(self, *, version: Optional[int] = None): | ||
super().__init__( | ||
metric=Groundedness._metric_name, | ||
version=version, | ||
) |
33 changes: 33 additions & 0 deletions
33
vertexai/preview/evaluation/metrics/_question_answering_correctness.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
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): | ||
super().__init__( | ||
metric=QuestionAnsweringCorrectness._metric_name, | ||
use_reference=use_reference, | ||
version=version, | ||
) |
33 changes: 33 additions & 0 deletions
33
vertexai/preview/evaluation/metrics/_question_answering_helpfulness.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
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): | ||
super().__init__( | ||
metric=QuestionAnsweringHelpfulness._metric_name, | ||
use_reference=use_reference, | ||
version=version, | ||
) |
33 changes: 33 additions & 0 deletions
33
vertexai/preview/evaluation/metrics/_question_answering_quality.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from typing import Optional | ||
from vertexai.preview.evaluation import constants | ||
from vertexai.preview.evaluation.metrics import _base | ||
|
||
|
||
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): | ||
super().__init__( | ||
metric=QuestionAnsweringQuality._metric_name, | ||
use_reference=use_reference, | ||
version=version, | ||
) |
Oops, something went wrong.