google-cloud-pipeline-components 2.14.0__py3-none-any.whl → 2.14.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of google-cloud-pipeline-components might be problematic. Click here for more details.
- google_cloud_pipeline_components/_implementation/llm/deployment_graph.py +10 -26
- google_cloud_pipeline_components/_implementation/llm/generated/refined_image_versions.py +1 -1
- google_cloud_pipeline_components/_implementation/llm/infer_preprocessor.py +109 -0
- google_cloud_pipeline_components/_implementation/llm/online_evaluation_pairwise.py +8 -0
- google_cloud_pipeline_components/_implementation/llm/reward_model_graph.py +5 -6
- google_cloud_pipeline_components/_implementation/llm/rlhf_preprocessor.py +24 -0
- google_cloud_pipeline_components/_implementation/model_evaluation/__init__.py +0 -12
- google_cloud_pipeline_components/_implementation/model_evaluation/llm_embedding/evaluation_llm_embedding_pipeline.py +2 -1
- google_cloud_pipeline_components/preview/llm/infer/component.py +22 -25
- google_cloud_pipeline_components/preview/llm/rlhf/component.py +12 -2
- google_cloud_pipeline_components/preview/model_evaluation/__init__.py +4 -1
- google_cloud_pipeline_components/preview/model_evaluation/model_evaluation_import_component.py +209 -0
- google_cloud_pipeline_components/proto/task_error_pb2.py +33 -0
- google_cloud_pipeline_components/v1/automl/forecasting/prophet_predict_pipeline.yaml +13 -13
- google_cloud_pipeline_components/v1/automl/forecasting/prophet_trainer.py +10 -0
- google_cloud_pipeline_components/v1/automl/forecasting/prophet_trainer_pipeline.yaml +4 -1
- google_cloud_pipeline_components/v1/model_evaluation/error_analysis_pipeline.py +8 -10
- google_cloud_pipeline_components/v1/model_evaluation/evaluated_annotation_pipeline.py +2 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_tabular_feature_attribution_pipeline.py +2 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_tabular_pipeline.py +2 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_unstructure_data_pipeline.py +2 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_feature_attribution_pipeline.py +2 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_llm_classification_pipeline.py +4 -2
- google_cloud_pipeline_components/v1/model_evaluation/evaluation_llm_text_generation_pipeline.py +4 -2
- google_cloud_pipeline_components/v1/model_evaluation/model_based_llm_evaluation/autosxs/autosxs_pipeline.py +1 -0
- google_cloud_pipeline_components/version.py +1 -1
- {google_cloud_pipeline_components-2.14.0.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/METADATA +1 -1
- {google_cloud_pipeline_components-2.14.0.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/RECORD +31 -28
- {google_cloud_pipeline_components-2.14.0.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/LICENSE +0 -0
- {google_cloud_pipeline_components-2.14.0.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/WHEEL +0 -0
- {google_cloud_pipeline_components-2.14.0.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/top_level.txt +0 -0
|
@@ -37,8 +37,10 @@ def pipeline(
|
|
|
37
37
|
policy_model_reference: str,
|
|
38
38
|
model_display_name: Optional[str] = None,
|
|
39
39
|
deploy_model: bool = True,
|
|
40
|
+
upload_model: bool = True,
|
|
40
41
|
encryption_spec_key_name: str = '',
|
|
41
42
|
upload_location: str = _placeholders.LOCATION_PLACEHOLDER,
|
|
43
|
+
regional_endpoint: str = '',
|
|
42
44
|
) -> PipelineOutput:
|
|
43
45
|
# fmt: off
|
|
44
46
|
"""Uploads a tuned language model and (optionally) deploys it to an endpoint.
|
|
@@ -51,50 +53,32 @@ def pipeline(
|
|
|
51
53
|
deploy_model: Whether to deploy the model to an endpoint in `us-central1`. Default is True.
|
|
52
54
|
encryption_spec_key_name: Customer-managed encryption key. If this is set, then all resources created by the CustomJob will be encrypted with the provided encryption key. Note that this is not supported for TPU at the moment.
|
|
53
55
|
upload_location: Region to upload and deploy the model to. Default is the location used to run the pipeline components.
|
|
56
|
+
regional_endpoint: Regional endpoint to upload the model.
|
|
54
57
|
|
|
55
58
|
Returns:
|
|
56
59
|
model_resource_name: Path to the model uploaded to the Model Registry. This will be an empty string if the model was not deployed.
|
|
57
60
|
endpoint_resource_name: Path the Online Prediction Endpoint. This will be an empty string if the model was not deployed.
|
|
58
61
|
"""
|
|
59
62
|
# fmt: on
|
|
60
|
-
regional_endpoint = function_based.resolve_regional_endpoint(
|
|
61
|
-
upload_location=upload_location
|
|
62
|
-
).set_display_name('Resolve Regional Endpoint')
|
|
63
|
-
|
|
64
|
-
display_name = (
|
|
65
|
-
function_based.resolve_model_display_name(
|
|
66
|
-
large_model_reference=large_model_reference,
|
|
67
|
-
model_display_name=model_display_name,
|
|
68
|
-
)
|
|
69
|
-
.set_caching_options(False)
|
|
70
|
-
.set_display_name('Resolve Model Display Name')
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
upload_model = function_based.resolve_upload_model(
|
|
74
|
-
large_model_reference=policy_model_reference,
|
|
75
|
-
).set_display_name('Resolve Upload Model')
|
|
76
63
|
upload_task = upload_llm_model.refined_upload_llm_model(
|
|
77
64
|
project=_placeholders.PROJECT_ID_PLACEHOLDER,
|
|
78
65
|
location=upload_location,
|
|
79
|
-
regional_endpoint=regional_endpoint
|
|
66
|
+
regional_endpoint=regional_endpoint,
|
|
80
67
|
artifact_uri=output_adapter_path,
|
|
81
|
-
model_display_name=
|
|
68
|
+
model_display_name=model_display_name,
|
|
82
69
|
model_reference_name=large_model_reference,
|
|
83
|
-
upload_model=upload_model
|
|
70
|
+
upload_model=upload_model,
|
|
84
71
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
85
72
|
tune_type='rlhf',
|
|
86
73
|
).set_display_name('Upload Model')
|
|
87
|
-
|
|
88
|
-
deploy_model=deploy_model,
|
|
89
|
-
large_model_reference=policy_model_reference,
|
|
90
|
-
).set_display_name('Resolve Deploy Model')
|
|
74
|
+
|
|
91
75
|
deploy_task = deploy_llm_model.deploy_llm_model(
|
|
92
76
|
project=_placeholders.PROJECT_ID_PLACEHOLDER,
|
|
93
77
|
location=upload_location,
|
|
94
78
|
model_resource_name=upload_task.outputs['model_resource_name'],
|
|
95
|
-
display_name=
|
|
96
|
-
regional_endpoint=regional_endpoint
|
|
97
|
-
deploy_model=deploy_model
|
|
79
|
+
display_name=model_display_name,
|
|
80
|
+
regional_endpoint=regional_endpoint,
|
|
81
|
+
deploy_model=deploy_model,
|
|
98
82
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
99
83
|
).set_display_name('Deploy Model')
|
|
100
84
|
return PipelineOutput(
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Copyright 2024 The Kubeflow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Component that preprocesses inputs for infer pipeline."""
|
|
15
|
+
|
|
16
|
+
from google_cloud_pipeline_components import _placeholders
|
|
17
|
+
from google_cloud_pipeline_components import utils as gcpc_utils
|
|
18
|
+
from google_cloud_pipeline_components._implementation.llm import utils
|
|
19
|
+
from kfp import dsl
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dsl.container_component
|
|
23
|
+
def infer_preprocessor(
|
|
24
|
+
large_model_reference: str,
|
|
25
|
+
accelerator_type: str,
|
|
26
|
+
use_test_spec: bool,
|
|
27
|
+
project: str,
|
|
28
|
+
location: str,
|
|
29
|
+
artifact_registry: str,
|
|
30
|
+
tag: str,
|
|
31
|
+
gcp_resources: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
32
|
+
metadata_large_model_reference: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
33
|
+
metadata_reference_model_path: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
34
|
+
metadata_reward_model_reference: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
35
|
+
metadata_reward_model_path: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
36
|
+
metadata_machine_type: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
37
|
+
metadata_tuning_location: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
38
|
+
metadata_accelerator_type: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
39
|
+
metadata_accelerator_count: dsl.OutputPath(int), # pytype: disable=invalid-annotation
|
|
40
|
+
metadata_instruction: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
41
|
+
metadata_refined_image_uri: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
42
|
+
use_experimental_image: bool = False,
|
|
43
|
+
input_reference_model_path: str = '',
|
|
44
|
+
instruction: str = '',
|
|
45
|
+
image_uri: str = utils.get_default_image_uri('refined_cpu', ''),
|
|
46
|
+
) -> dsl.ContainerSpec: # pylint: disable=g-doc-args
|
|
47
|
+
# fmt: off
|
|
48
|
+
"""Preprocess infer pipeline inputs.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
large_model_reference: The model for fine tuning.
|
|
52
|
+
accelerator_type: Specific accelerator type for the job.
|
|
53
|
+
use_test_spec: Whether to use a lower resource machine for testing.
|
|
54
|
+
project: Project that contains the artifact registry.
|
|
55
|
+
location: Region that contains the artifact registry.
|
|
56
|
+
artifact_registry: Registry that contains Docker images.
|
|
57
|
+
tag: Image tag.
|
|
58
|
+
use_experimental_image: Whether to use refined experimental image.
|
|
59
|
+
input_reference_model_path: The model checkpoint path for the reference model
|
|
60
|
+
instruction: The instruction to let the model know what task it needs to perform.
|
|
61
|
+
image_uri: Docker image URI to use for the custom job.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
gcp_resources: GCP resources that can be used to track the custom job.
|
|
65
|
+
metadata_large_model_reference: The base model for fine tuning. The name should be in capitalized snake case format.
|
|
66
|
+
metadata_reference_model_path: The model checkpoint path for the reinforcer model
|
|
67
|
+
metadata_reward_model_reference: The base model for training reward model. The name should be in capitalized snake case format.
|
|
68
|
+
metadata_reward_model_path: The model checkpoint path for the reward model.
|
|
69
|
+
metadata_machine_type: The type of the machine to provision for the custom job.
|
|
70
|
+
metadata_tuning_location: The GCP region to run the custom job.
|
|
71
|
+
metadata_accelerator_type: Specific accelerator type for the custom job.
|
|
72
|
+
metadata_accelerator_count: The number of accelerator.
|
|
73
|
+
metadata_instruction: The instruction to let the model know what task it needs to perform.
|
|
74
|
+
metadata_refined_image_uri: Docker image URI to use for the custom job.
|
|
75
|
+
"""
|
|
76
|
+
# fmt: on
|
|
77
|
+
return gcpc_utils.build_serverless_customjob_container_spec(
|
|
78
|
+
project=_placeholders.PROJECT_ID_PLACEHOLDER,
|
|
79
|
+
location=_placeholders.LOCATION_PLACEHOLDER,
|
|
80
|
+
custom_job_payload=utils.build_payload(
|
|
81
|
+
display_name='infer_preprocessor',
|
|
82
|
+
machine_type='n1-standard-4',
|
|
83
|
+
image_uri=image_uri,
|
|
84
|
+
args=[
|
|
85
|
+
'--app_name=infer_preprocessor',
|
|
86
|
+
f'--large_model_reference={large_model_reference}',
|
|
87
|
+
f'--input_reference_model_path={input_reference_model_path}',
|
|
88
|
+
f'--accelerator_type={accelerator_type}',
|
|
89
|
+
f'--use_test_spec={use_test_spec}',
|
|
90
|
+
f'--project={project}',
|
|
91
|
+
f'--location={location}',
|
|
92
|
+
f'--artifact_registry={artifact_registry}',
|
|
93
|
+
f'--tag={tag}',
|
|
94
|
+
f'--use_experimental_image={use_experimental_image}',
|
|
95
|
+
f'--instruction={instruction}',
|
|
96
|
+
f'--metadata_large_model_reference_path={metadata_large_model_reference}',
|
|
97
|
+
f'--metadata_reference_model_path_path={metadata_reference_model_path}',
|
|
98
|
+
f'--metadata_reward_model_reference_path={metadata_reward_model_reference}',
|
|
99
|
+
f'--metadata_reward_model_path_path={metadata_reward_model_path}',
|
|
100
|
+
f'--metadata_machine_type_path={metadata_machine_type}',
|
|
101
|
+
f'--metadata_tuning_location_path={metadata_tuning_location}',
|
|
102
|
+
f'--metadata_accelerator_type_path={metadata_accelerator_type}',
|
|
103
|
+
f'--metadata_accelerator_count_path={metadata_accelerator_count}',
|
|
104
|
+
f'--metadata_instruction_path={metadata_instruction}',
|
|
105
|
+
f'--metadata_refined_image_uri_path={metadata_refined_image_uri}',
|
|
106
|
+
],
|
|
107
|
+
),
|
|
108
|
+
gcp_resources=gcp_resources,
|
|
109
|
+
)
|
|
@@ -52,6 +52,7 @@ def online_evaluation_pairwise(
|
|
|
52
52
|
project: str = _placeholders.PROJECT_ID_PLACEHOLDER,
|
|
53
53
|
location: str = _placeholders.LOCATION_PLACEHOLDER,
|
|
54
54
|
encryption_spec_key_name: str = '',
|
|
55
|
+
autorater_prompt_parameters: Dict[str, Dict[str, str]] = {},
|
|
55
56
|
) -> dsl.ContainerSpec: # pylint: disable=g-doc-args
|
|
56
57
|
"""Evaluate two models using an autorater.
|
|
57
58
|
|
|
@@ -73,6 +74,8 @@ def online_evaluation_pairwise(
|
|
|
73
74
|
encryption_spec_key_name: Customer-managed encryption key options. If this
|
|
74
75
|
is set, then all resources created by the component will be encrypted with
|
|
75
76
|
the provided encryption key.
|
|
77
|
+
autorater_prompt_parameters: Map of autorater prompt template parameters to
|
|
78
|
+
columns or templates.
|
|
76
79
|
|
|
77
80
|
Returns:
|
|
78
81
|
judgments: Individual judgments used to calculate the win rates.
|
|
@@ -112,6 +115,11 @@ def online_evaluation_pairwise(
|
|
|
112
115
|
'--executor_input={{$.json_escape[1]}}',
|
|
113
116
|
f'--kms_key_name={encryption_spec_key_name}',
|
|
114
117
|
f'--metadata_path={metadata}',
|
|
118
|
+
(
|
|
119
|
+
'--autorater_prompt_parameters='
|
|
120
|
+
"{{$.inputs.parameters['autorater_prompt_parameters']"
|
|
121
|
+
'.json_escape[0]}}'
|
|
122
|
+
),
|
|
115
123
|
],
|
|
116
124
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
117
125
|
),
|
|
@@ -21,6 +21,7 @@ from google_cloud_pipeline_components._implementation.llm import function_based
|
|
|
21
21
|
from google_cloud_pipeline_components._implementation.llm import preprocess_chat_dataset
|
|
22
22
|
from google_cloud_pipeline_components._implementation.llm import private_text_comparison_importer
|
|
23
23
|
from google_cloud_pipeline_components._implementation.llm import reward_model_trainer
|
|
24
|
+
from google_cloud_pipeline_components._implementation.llm import rlhf_preprocessor
|
|
24
25
|
from google_cloud_pipeline_components._implementation.llm import upload_tensorboard_metrics
|
|
25
26
|
import kfp
|
|
26
27
|
|
|
@@ -45,6 +46,7 @@ def pipeline(
|
|
|
45
46
|
accelerator_type: str,
|
|
46
47
|
accelerator_count: int,
|
|
47
48
|
reward_model_image_uri: str,
|
|
49
|
+
comma_separated_candidates_field_names: str,
|
|
48
50
|
prompt_sequence_length: int = 512,
|
|
49
51
|
target_sequence_length: int = 64,
|
|
50
52
|
batch_size: int = 64,
|
|
@@ -72,6 +74,7 @@ def pipeline(
|
|
|
72
74
|
accelerator_type: Specific accelerator type for the custom job.
|
|
73
75
|
accelerator_count: The number of accelerator.
|
|
74
76
|
reward_model_image_uri: Docker image URI to use for the reward model training job.
|
|
77
|
+
comma_separated_candidates_field_names: Comma separated list of fields that contain candidate text, e.g. ``'field_1,field_2,field_3'``.
|
|
75
78
|
prompt_sequence_length: Maximum tokenized sequence length for input text. Higher values increase memory overhead. This value should be at most 8192. Default value is 512.
|
|
76
79
|
target_sequence_length: Maximum tokenized sequence length for target text. Higher values increase memory overhead. This value should be at most 1024. Default value is 64.
|
|
77
80
|
batch_size: Number of examples in each finetuning step. Default is 64.
|
|
@@ -91,7 +94,6 @@ def pipeline(
|
|
|
91
94
|
"""
|
|
92
95
|
# fmt: on
|
|
93
96
|
prompt_column = 'input_text'
|
|
94
|
-
candidate_columns = ['candidate_0', 'candidate_1']
|
|
95
97
|
choice_column = 'choice'
|
|
96
98
|
|
|
97
99
|
processed_preference_dataset = (
|
|
@@ -103,9 +105,6 @@ def pipeline(
|
|
|
103
105
|
).set_display_name('Preprocess Prompt Dataset')
|
|
104
106
|
)
|
|
105
107
|
|
|
106
|
-
comma_separated_candidates_field_names = (
|
|
107
|
-
function_based.convert_to_delimited_string(items=candidate_columns)
|
|
108
|
-
)
|
|
109
108
|
preference_dataset_importer = (
|
|
110
109
|
private_text_comparison_importer.private_text_comparison_importer(
|
|
111
110
|
project=project,
|
|
@@ -114,7 +113,7 @@ def pipeline(
|
|
|
114
113
|
'processed_dataset_uri'
|
|
115
114
|
],
|
|
116
115
|
inputs_field_name=prompt_column,
|
|
117
|
-
comma_separated_candidates_field_names=comma_separated_candidates_field_names
|
|
116
|
+
comma_separated_candidates_field_names=comma_separated_candidates_field_names,
|
|
118
117
|
choice_field_name=choice_column,
|
|
119
118
|
split=env.TRAIN_SPLIT,
|
|
120
119
|
large_model_reference=reward_model_reference,
|
|
@@ -131,7 +130,7 @@ def pipeline(
|
|
|
131
130
|
location=location,
|
|
132
131
|
input_text=eval_dataset,
|
|
133
132
|
inputs_field_name=prompt_column,
|
|
134
|
-
comma_separated_candidates_field_names=comma_separated_candidates_field_names
|
|
133
|
+
comma_separated_candidates_field_names=comma_separated_candidates_field_names,
|
|
135
134
|
choice_field_name=choice_column,
|
|
136
135
|
split=env.TRAIN_SPLIT,
|
|
137
136
|
large_model_reference=reward_model_reference,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"""Component that preprocesses inputs for Reinforcement Learning from Human Feedback (RLHF)."""
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
|
+
from typing import List
|
|
17
18
|
|
|
18
19
|
from google_cloud_pipeline_components import _placeholders
|
|
19
20
|
from google_cloud_pipeline_components import utils as gcpc_utils
|
|
@@ -33,6 +34,7 @@ def rlhf_preprocessor(
|
|
|
33
34
|
gcp_resources: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
34
35
|
has_tensorboard_id: dsl.OutputPath(bool), # pytype: disable=invalid-annotation
|
|
35
36
|
has_inference_dataset: dsl.OutputPath(bool), # pytype: disable=invalid-annotation
|
|
37
|
+
metadata_candidate_columns_string: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
36
38
|
metadata_large_model_reference: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
37
39
|
metadata_reference_model_path: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
38
40
|
metadata_reward_model_reference: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
@@ -43,11 +45,18 @@ def rlhf_preprocessor(
|
|
|
43
45
|
metadata_accelerator_count: dsl.OutputPath(int), # pytype: disable=invalid-annotation
|
|
44
46
|
metadata_refined_image_uri: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
45
47
|
metadata_num_microbatches: dsl.OutputPath(int), # pytype: disable=invalid-annotation
|
|
48
|
+
metadata_upload_location: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
49
|
+
metadata_deploy_model: dsl.OutputPath(bool), # pytype: disable=invalid-annotation
|
|
50
|
+
metadata_model_display_name: dsl.OutputPath(str), # pytype: disable=invalid-annotation
|
|
51
|
+
metadata_upload_model: dsl.OutputPath(bool), # pytype: disable=invalid-annotation
|
|
46
52
|
use_experimental_image: bool = False,
|
|
47
53
|
evaluation_dataset: str = '',
|
|
48
54
|
tensorboard_resource_id: str = '',
|
|
49
55
|
input_reference_model_path: str = '',
|
|
50
56
|
image_uri: str = utils.get_default_image_uri('refined_cpu', ''),
|
|
57
|
+
upload_location: str = '',
|
|
58
|
+
model_display_name: str = '',
|
|
59
|
+
deploy_model: bool = True,
|
|
51
60
|
) -> dsl.ContainerSpec: # pylint: disable=g-doc-args
|
|
52
61
|
# fmt: off
|
|
53
62
|
"""Preprocess RLHF pipeline inputs.
|
|
@@ -68,6 +77,9 @@ def rlhf_preprocessor(
|
|
|
68
77
|
metadata_reward_model_reference: The base model for training reward model. The name should be in capitalized snake case format.
|
|
69
78
|
metadata_reward_model_path: The model checkpoint path for the reward model.
|
|
70
79
|
image_uri: Docker image URI to use for the custom job.
|
|
80
|
+
upload_location: Region where the model will be uploaded.
|
|
81
|
+
model_display_name: Display name of the model.
|
|
82
|
+
deploy_model: Whether to deploy the model.
|
|
71
83
|
|
|
72
84
|
Returns:
|
|
73
85
|
gcp_resources: GCP resources that can be used to track the custom job.
|
|
@@ -80,6 +92,10 @@ def rlhf_preprocessor(
|
|
|
80
92
|
metadata_refined_image_uri: Docker image URI to use for the custom job.
|
|
81
93
|
metadata_num_microbatches: Number of microbatches to break the total batch
|
|
82
94
|
size into during training.
|
|
95
|
+
metadata_upload_location: Regional endpoint.
|
|
96
|
+
metadata_deploy_model: Whether to deploy the model.
|
|
97
|
+
metadata_model_display_name: Display name of the model.
|
|
98
|
+
metadata_upload_model: Whether to upload the model.
|
|
83
99
|
"""
|
|
84
100
|
# fmt: on
|
|
85
101
|
return gcpc_utils.build_serverless_customjob_container_spec(
|
|
@@ -102,8 +118,12 @@ def rlhf_preprocessor(
|
|
|
102
118
|
f'--artifact_registry={artifact_registry}',
|
|
103
119
|
f'--tag={tag}',
|
|
104
120
|
f'--use_experimental_image={use_experimental_image}',
|
|
121
|
+
f'--upload_location={upload_location}',
|
|
122
|
+
f'--deploy_model={deploy_model}',
|
|
123
|
+
f'--model_display_name={model_display_name}',
|
|
105
124
|
f'--has_tensorboard_id_path={has_tensorboard_id}',
|
|
106
125
|
f'--has_inference_dataset_path={has_inference_dataset}',
|
|
126
|
+
f'--metadata_candidate_columns_string_path={metadata_candidate_columns_string}',
|
|
107
127
|
f'--metadata_large_model_reference_path={metadata_large_model_reference}',
|
|
108
128
|
f'--metadata_reference_model_path_path={metadata_reference_model_path}',
|
|
109
129
|
f'--metadata_reward_model_reference_path={metadata_reward_model_reference}',
|
|
@@ -114,6 +134,10 @@ def rlhf_preprocessor(
|
|
|
114
134
|
f'--metadata_accelerator_count_path={metadata_accelerator_count}',
|
|
115
135
|
f'--metadata_refined_image_uri_path={metadata_refined_image_uri}',
|
|
116
136
|
f'--metadata_num_microbatches_path={metadata_num_microbatches}',
|
|
137
|
+
f'--metadata_upload_location_path={metadata_upload_location}',
|
|
138
|
+
f'--metadata_deploy_model_path={metadata_deploy_model}',
|
|
139
|
+
f'--metadata_model_display_name_path={metadata_model_display_name}',
|
|
140
|
+
f'--metadata_upload_model_path={metadata_upload_model}',
|
|
117
141
|
],
|
|
118
142
|
),
|
|
119
143
|
gcp_resources=gcp_resources,
|
|
@@ -25,27 +25,18 @@ from google_cloud_pipeline_components._implementation.model_evaluation.feature_a
|
|
|
25
25
|
from google_cloud_pipeline_components._implementation.model_evaluation.feature_attribution.feature_attribution_graph_component import feature_attribution_graph_component as FeatureAttributionGraphComponentOp
|
|
26
26
|
from google_cloud_pipeline_components._implementation.model_evaluation.feature_extractor.component import feature_extractor_error_analysis as FeatureExtractorOp
|
|
27
27
|
from google_cloud_pipeline_components._implementation.model_evaluation.import_evaluated_annotation.component import evaluated_annotation_import as ModelImportEvaluatedAnnotationOp
|
|
28
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.import_evaluation.component import model_evaluation_import as ModelImportEvaluationOp
|
|
29
28
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_classification_postprocessor.component import llm_classification_predictions_postprocessor_graph_component as LLMEvaluationClassificationPredictionsPostprocessorOp
|
|
30
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.llm_embedding.evaluation_llm_embedding_pipeline import evaluation_llm_embedding_pipeline
|
|
31
29
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_embedding_retrieval.component import llm_embedding_retrieval as LLMEmbeddingRetrievalOp
|
|
32
30
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_evaluation.component import model_evaluation_text_generation as LLMEvaluationTextGenerationOp
|
|
33
31
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_evaluation_preprocessor.component import llm_evaluation_dataset_preprocessor_graph_component as LLMEvaluationPreprocessorOp
|
|
34
32
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_information_retrieval_preprocessor.component import llm_information_retrieval_preprocessor as LLMInformationRetrievalPreprocessorOp
|
|
35
33
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_retrieval_metrics.component import llm_retrieval_metrics as LLMRetrievalMetricsOp
|
|
36
34
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_safety_bias.component import llm_safety_bias_metrics as LLMSafetyBiasMetricsOp
|
|
37
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.llm_safety_bias.evaluation_llm_safety_bias_pipeline import evaluation_llm_safety_bias_pipeline
|
|
38
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.model_inference.component import model_inference_and_evaluation_component
|
|
39
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.model_inference.component import model_inference_component
|
|
40
35
|
from google_cloud_pipeline_components._implementation.model_evaluation.model_name_preprocessor.component import model_name_preprocessor as ModelNamePreprocessorOp
|
|
41
36
|
from google_cloud_pipeline_components._implementation.model_evaluation.target_field_data_remover.component import target_field_data_remover as TargetFieldDataRemoverOp
|
|
42
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.text2sql.evaluation_llm_text2sql_pipeline import evaluation_llm_text2sql_pipeline
|
|
43
37
|
|
|
44
38
|
|
|
45
39
|
__all__ = [
|
|
46
|
-
'evaluation_llm_safety_bias_pipeline',
|
|
47
|
-
'evaluation_llm_embedding_pipeline',
|
|
48
|
-
'evaluation_llm_text2sql_pipeline',
|
|
49
40
|
'evaluation_llm_endpoint_batch_predict_pipeline_graph_component',
|
|
50
41
|
'ChunkingOp',
|
|
51
42
|
'EvaluationDataSamplerOp',
|
|
@@ -63,9 +54,6 @@ __all__ = [
|
|
|
63
54
|
'LLMSafetyBiasMetricsOp',
|
|
64
55
|
'ModelEvaluationFeatureAttributionOp',
|
|
65
56
|
'ModelImportEvaluatedAnnotationOp',
|
|
66
|
-
'ModelImportEvaluationOp',
|
|
67
57
|
'ModelNamePreprocessorOp',
|
|
68
58
|
'TargetFieldDataRemoverOp',
|
|
69
|
-
'model_inference_component',
|
|
70
|
-
'model_inference_and_evaluation_component',
|
|
71
59
|
]
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"""LLM embedding evaluation pipeline based on information retrieval (IR) task."""
|
|
15
15
|
|
|
16
16
|
from typing import Dict, Optional, Union
|
|
17
|
+
|
|
17
18
|
from google_cloud_pipeline_components._implementation.model_evaluation.endpoint_batch_predict.component import evaluation_llm_endpoint_batch_predict_pipeline_graph_component as LLMEndpointBatchPredictOp
|
|
18
|
-
from google_cloud_pipeline_components._implementation.model_evaluation.import_evaluation.component import model_evaluation_import as ModelImportEvaluationOp
|
|
19
19
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_embedding_retrieval.component import llm_embedding_retrieval as LLMEmbeddingRetrievalOp
|
|
20
20
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_information_retrieval_preprocessor.component import llm_information_retrieval_preprocessor as LLMInformationRetrievalPreprocessorOp
|
|
21
21
|
from google_cloud_pipeline_components._implementation.model_evaluation.llm_retrieval_metrics.component import llm_retrieval_metrics as LLMRetrievalMetricsOp
|
|
22
|
+
from google_cloud_pipeline_components.preview.model_evaluation.model_evaluation_import_component import model_evaluation_import as ModelImportEvaluationOp
|
|
22
23
|
from google_cloud_pipeline_components.types.artifact_types import VertexModel
|
|
23
24
|
from google_cloud_pipeline_components.v1.batch_predict_job import ModelBatchPredictOp
|
|
24
25
|
import kfp
|
|
@@ -18,7 +18,7 @@ from typing import NamedTuple, Optional
|
|
|
18
18
|
from google_cloud_pipeline_components import _placeholders
|
|
19
19
|
from google_cloud_pipeline_components._implementation.llm import bulk_inferrer
|
|
20
20
|
from google_cloud_pipeline_components._implementation.llm import env
|
|
21
|
-
from google_cloud_pipeline_components._implementation.llm import
|
|
21
|
+
from google_cloud_pipeline_components._implementation.llm import infer_preprocessor
|
|
22
22
|
from google_cloud_pipeline_components._implementation.llm import preprocess_chat_dataset
|
|
23
23
|
from google_cloud_pipeline_components._implementation.llm import private_text_importer
|
|
24
24
|
import kfp
|
|
@@ -66,14 +66,16 @@ def infer_pipeline(
|
|
|
66
66
|
"""
|
|
67
67
|
# fmt: on
|
|
68
68
|
prompt_column = 'input_text'
|
|
69
|
-
|
|
69
|
+
preprocess_metadata = infer_preprocessor.infer_preprocessor(
|
|
70
|
+
large_model_reference=large_model_reference,
|
|
70
71
|
accelerator_type=accelerator_type,
|
|
71
72
|
use_test_spec=env.get_use_test_machine_spec(),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
project=env.PRIVATE_ARTIFACT_REGISTRY_PROJECT,
|
|
74
|
+
location=env.PRIVATE_ARTIFACT_REGISTRY_LOCATION,
|
|
75
|
+
artifact_registry=env.PRIVATE_ARTIFACT_REGISTRY,
|
|
76
|
+
tag=env.get_private_image_tag(),
|
|
77
|
+
instruction=instruction,
|
|
78
|
+
).set_display_name('Preprocess Inputs')
|
|
77
79
|
|
|
78
80
|
processed_dataset = preprocess_chat_dataset.preprocess_chat_dataset(
|
|
79
81
|
large_model_reference=large_model_reference,
|
|
@@ -82,10 +84,6 @@ def infer_pipeline(
|
|
|
82
84
|
dataset_type='prompt',
|
|
83
85
|
).set_display_name('Preprocess Dataset')
|
|
84
86
|
|
|
85
|
-
resolved_text_instruction = function_based.resolve_instruction(
|
|
86
|
-
large_model_reference=large_model_reference,
|
|
87
|
-
instruction=instruction,
|
|
88
|
-
).set_display_name('Resolve Instruction')
|
|
89
87
|
prompt_dataset_importer = (
|
|
90
88
|
private_text_importer.private_text_importer(
|
|
91
89
|
project=project,
|
|
@@ -94,35 +92,34 @@ def infer_pipeline(
|
|
|
94
92
|
inputs_field_name=prompt_column,
|
|
95
93
|
targets_field_name='', # ignore targets_field_name
|
|
96
94
|
output_split_name=env.TRAIN_SPLIT,
|
|
97
|
-
large_model_reference=
|
|
98
|
-
'
|
|
95
|
+
large_model_reference=preprocess_metadata.outputs[
|
|
96
|
+
'metadata_large_model_reference'
|
|
99
97
|
],
|
|
100
|
-
instruction=
|
|
98
|
+
instruction=preprocess_metadata.outputs['metadata_instruction'],
|
|
101
99
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
102
100
|
)
|
|
103
101
|
.set_display_name('Import Prompt Dataset')
|
|
104
102
|
.set_caching_options(False)
|
|
105
103
|
)
|
|
106
104
|
|
|
107
|
-
bulk_inferrer_image_uri = function_based.resolve_private_refined_image_uri(
|
|
108
|
-
accelerator_type=machine_spec.outputs['accelerator_type'],
|
|
109
|
-
).set_display_name('Resolve Bulk Inferrer Image URI')
|
|
110
105
|
bulk_inference = bulk_inferrer.bulk_inferrer(
|
|
111
106
|
project=project,
|
|
112
|
-
location=
|
|
113
|
-
input_model=
|
|
107
|
+
location=preprocess_metadata.outputs['metadata_tuning_location'],
|
|
108
|
+
input_model=preprocess_metadata.outputs['metadata_reference_model_path'],
|
|
114
109
|
input_dataset_path=prompt_dataset_importer.outputs['imported_data_path'],
|
|
115
110
|
dataset_split=env.TRAIN_SPLIT,
|
|
116
111
|
inputs_sequence_length=prompt_sequence_length,
|
|
117
112
|
targets_sequence_length=target_sequence_length,
|
|
118
|
-
large_model_reference=
|
|
119
|
-
'
|
|
113
|
+
large_model_reference=preprocess_metadata.outputs[
|
|
114
|
+
'metadata_large_model_reference'
|
|
120
115
|
],
|
|
121
116
|
sampling_strategy=sampling_strategy,
|
|
122
|
-
accelerator_type=
|
|
123
|
-
accelerator_count=
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
accelerator_type=preprocess_metadata.outputs['metadata_accelerator_type'],
|
|
118
|
+
accelerator_count=preprocess_metadata.outputs[
|
|
119
|
+
'metadata_accelerator_count'
|
|
120
|
+
],
|
|
121
|
+
machine_type=preprocess_metadata.outputs['metadata_machine_type'],
|
|
122
|
+
image_uri=preprocess_metadata.outputs['metadata_refined_image_uri'],
|
|
126
123
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
127
124
|
).set_display_name('Bulk Inferrer')
|
|
128
125
|
|
|
@@ -106,6 +106,9 @@ def rlhf_pipeline(
|
|
|
106
106
|
tag=env.get_private_image_tag(),
|
|
107
107
|
evaluation_dataset=eval_dataset,
|
|
108
108
|
tensorboard_resource_id=tensorboard_resource_id,
|
|
109
|
+
upload_location=location,
|
|
110
|
+
model_display_name=model_display_name,
|
|
111
|
+
deploy_model=deploy_model,
|
|
109
112
|
).set_display_name('Preprocess Inputs')
|
|
110
113
|
num_microbatches = preprocess_metadata.outputs['metadata_num_microbatches']
|
|
111
114
|
|
|
@@ -133,6 +136,9 @@ def rlhf_pipeline(
|
|
|
133
136
|
reward_model_image_uri=preprocess_metadata.outputs[
|
|
134
137
|
'metadata_refined_image_uri'
|
|
135
138
|
],
|
|
139
|
+
comma_separated_candidates_field_names=preprocess_metadata.outputs[
|
|
140
|
+
'metadata_candidate_columns_string'
|
|
141
|
+
],
|
|
136
142
|
prompt_sequence_length=prompt_sequence_length,
|
|
137
143
|
target_sequence_length=target_sequence_length,
|
|
138
144
|
eval_dataset=validate_pipeline_task.outputs[
|
|
@@ -226,10 +232,14 @@ def rlhf_pipeline(
|
|
|
226
232
|
policy_model_reference=preprocess_metadata.outputs[
|
|
227
233
|
'metadata_large_model_reference'
|
|
228
234
|
],
|
|
229
|
-
model_display_name=
|
|
230
|
-
|
|
235
|
+
model_display_name=preprocess_metadata.outputs[
|
|
236
|
+
'metadata_model_display_name'
|
|
237
|
+
],
|
|
238
|
+
deploy_model=preprocess_metadata.outputs['metadata_deploy_model'],
|
|
239
|
+
upload_model=preprocess_metadata.outputs['metadata_upload_model'],
|
|
231
240
|
encryption_spec_key_name=encryption_spec_key_name,
|
|
232
241
|
upload_location=location,
|
|
242
|
+
regional_endpoint=preprocess_metadata.outputs['metadata_upload_location'],
|
|
233
243
|
).set_display_name('Upload and Deploy Tuned Model')
|
|
234
244
|
|
|
235
245
|
return PipelineOutput(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2024 The Kubeflow Authors. All Rights Reserved.
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -17,10 +17,12 @@ from google_cloud_pipeline_components.preview.model_evaluation.data_bias_compone
|
|
|
17
17
|
from google_cloud_pipeline_components.preview.model_evaluation.feature_attribution_component import feature_attribution as ModelEvaluationFeatureAttributionOp
|
|
18
18
|
from google_cloud_pipeline_components.preview.model_evaluation.feature_attribution_graph_component import feature_attribution_graph_component as FeatureAttributionGraphComponentOp
|
|
19
19
|
from google_cloud_pipeline_components.preview.model_evaluation.model_bias_component import detect_model_bias as DetectModelBiasOp
|
|
20
|
+
from google_cloud_pipeline_components.preview.model_evaluation.model_evaluation_import_component import model_evaluation_import as ModelImportEvaluationOp
|
|
20
21
|
from google_cloud_pipeline_components.v1.model_evaluation.evaluation_llm_classification_pipeline import evaluation_llm_classification_pipeline
|
|
21
22
|
from google_cloud_pipeline_components.v1.model_evaluation.evaluation_llm_text_generation_pipeline import evaluation_llm_text_generation_pipeline
|
|
22
23
|
from google_cloud_pipeline_components.v1.model_evaluation.model_based_llm_evaluation.autosxs.autosxs_pipeline import autosxs_pipeline
|
|
23
24
|
|
|
25
|
+
|
|
24
26
|
__all__ = [
|
|
25
27
|
'autosxs_pipeline',
|
|
26
28
|
'evaluation_llm_classification_pipeline',
|
|
@@ -29,4 +31,5 @@ __all__ = [
|
|
|
29
31
|
'FeatureAttributionGraphComponentOp',
|
|
30
32
|
'DetectModelBiasOp',
|
|
31
33
|
'DetectDataBiasOp',
|
|
34
|
+
'ModelImportEvaluationOp',
|
|
32
35
|
]
|