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
feat: Add fine tuning fit() for Palm2TextGenerator (#616)
* feat: support list of numerics in pandas.cut (#580)
An internal user encountered this missing overload
* move the tests to load-testing
* add predict tests
* address comments
* address comments
---------
Co-authored-by: Henry Solberg <[email protected]>
"""Create a session-temporary BQML model with the CREATE OR REPLACE MODEL statement
332
+
333
+
Args:
334
+
X_train: features columns for training
335
+
y_train: labels columns for training
336
+
options: a dict of options to configure the model. Generates a BQML OPTIONS
337
+
clause
338
+
connection_name:
339
+
a BQ connection to talk with Vertex AI, of the format <PROJECT_NUMBER>.<REGION>.<CONNECTION_NAME>. https://cloud.google.com/bigquery/docs/create-cloud-resource-connection
340
+
341
+
Returns: a BqmlModel, wrapping a trained model in BigQuery
342
+
"""
343
+
options=dict(options)
344
+
# Cache dataframes to make sure base table is not a snapshot
345
+
# cached dataframe creates a full copy, never uses snapshot
"""The model options as they will be set for BQML"""
167
+
options= {
168
+
"max_iterations": self.max_iterations,
169
+
"data_split_method": "NO_SPLIT",
170
+
}
171
+
returnoptions
172
+
173
+
deffit(
174
+
self,
175
+
X: Union[bpd.DataFrame, bpd.Series],
176
+
y: Union[bpd.DataFrame, bpd.Series],
177
+
) ->PaLM2TextGenerator:
178
+
"""Fine tune PaLM2TextGenerator model.
179
+
180
+
.. note::
181
+
182
+
This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
183
+
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
184
+
and might have limited support. For more information, see the launch stage descriptions
# 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
+
15
+
importpandasaspd
16
+
importpytest
17
+
18
+
importbigframes.ml.llm
19
+
20
+
21
+
@pytest.fixture(scope="session")
22
+
defllm_fine_tune_df_default_index(
23
+
session: bigframes.Session,
24
+
) ->bigframes.dataframe.DataFrame:
25
+
sql="""
26
+
SELECT
27
+
CONCAT("Please do sentiment analysis on the following text and only output a number from 0 to 5 where 0 means sadness, 1 means joy, 2 means love, 3 means anger, 4 means fear, and 5 means surprise. Text: ", text) as prompt,
28
+
CAST(label AS STRING) as label
29
+
FROM `llm_tuning.emotion_classification_train`
30
+
"""
31
+
returnsession.read_gbq(sql)
32
+
33
+
34
+
@pytest.fixture(scope="session")
35
+
defllm_remote_text_pandas_df():
36
+
"""Additional data matching the penguins dataset, with a new index"""
37
+
returnpd.DataFrame(
38
+
{
39
+
"prompt": [
40
+
"Please do sentiment analysis on the following text and only output a number from 0 to 5where 0 means sadness, 1 means joy, 2 means love, 3 means anger, 4 means fear, and 5 means surprise. Text: i feel beautifully emotional knowing that these women of whom i knew just a handful were holding me and my baba on our journey",
41
+
"Please do sentiment analysis on the following text and only output a number from 0 to 5 where 0 means sadness, 1 means joy, 2 means love, 3 means anger, 4 means fear, and 5 means surprise. Text: i was feeling a little vain when i did this one",
42
+
"Please do sentiment analysis on the following text and only output a number from 0 to 5 where 0 means sadness, 1 means joy, 2 means love, 3 means anger, 4 means fear, and 5 means surprise. Text: a father of children killed in an accident",
0 commit comments