@@ -220,7 +220,7 @@ def predict(
220220
221221 Args:
222222 X (bigframes.dataframe.DataFrame or bigframes.series.Series):
223- Input DataFrame or Series, which needs to contain a column with name "prompt". Only the column will be used as input .
223+ Input DataFrame or Series, which contains only one column of prompts .
224224 Prompts can include preamble, questions, suggestions, instructions, or examples.
225225
226226 temperature (float, default 0.0):
@@ -335,11 +335,11 @@ def score(
335335
336336 Args:
337337 X (bigframes.dataframe.DataFrame or bigframes.series.Series):
338- A BigQuery DataFrame as evaluation data. X must have a column named
339- ``input_text`` that contains the prompt text to use when evaluating the model.
338+ A BigQuery DataFrame as evaluation data, which contains only one column of input_text
339+ that contains the prompt text to use when evaluating the model.
340340 y (bigframes.dataframe.DataFrame or bigframes.series.Series):
341- A BigQuery DataFrame as evaluation labels. y must also have a column named `` output_text`` that contains the generated
342- text that you would expect to be returned by the model.
341+ A BigQuery DataFrame as evaluation labels, which contains only one column of output_text
342+ that you would expect to be returned by the model.
343343 task_type (Optional[str]):
344344 The type of the task for LLM model. Default to "text_generation".
345345 Possible values: "text_generation", "classification", "summarization", and "question_answering".
@@ -352,25 +352,20 @@ def score(
352352
353353 X , y = utils .convert_to_dataframe (X , y )
354354
355- X_columns = X .columns .to_list ()
356- y_columns = y .columns .to_list ()
357- if "input_text" not in X_columns :
358- raise ValueError (
359- """Must contain a column named input_text that contains the prompt
360- text to use when evaluating the model."""
361- )
362- if "output_text" not in y_columns :
355+ if len (X .columns ) != 1 or len (y .columns ) != 1 :
363356 raise ValueError (
364- """Must contain a column named output_text that contains the generated
365- text that you would expect to be returned by the model."""
357+ f"Only support one column as input for X and y. { constants .FEEDBACK_LINK } "
366358 )
367359
368- input_data = (
369- X .join (y , how = "outer" ) if (X is not None ) and (y is not None ) else None
370- )
371- refined_data = input_data [["input_text" , "output_text" ]].copy ()
360+ # BQML identified the column by name
361+ X_col_label = cast (blocks .Label , X .columns [0 ])
362+ y_col_label = cast (blocks .Label , y .columns [0 ])
363+ X = X .rename (columns = {X_col_label : "input_text" })
364+ y = y .rename (columns = {y_col_label : "output_text" })
365+
366+ input_data = X .join (y , how = "outer" )
372367
373- return self ._bqml_model .llm_evaluate (refined_data , task_type )
368+ return self ._bqml_model .llm_evaluate (input_data , task_type )
374369
375370 def to_gbq (self , model_name : str , replace : bool = False ) -> PaLM2TextGenerator :
376371 """Save the model to BigQuery.
0 commit comments