An MLOps engineer is building a Pandas UDF that applies a language model that translates English strings into Spanish. The initial code is loading the model on every call to the UDF, which is hurting the performance of the data pipeline. The initial code is: def in_spanish_inner(df: pd.Series) -> pd.Series: model = get_translation_model(target_lang='es') return df.apply(model) in_spanish = sf.pandas_udf(in_spanish_inner, StringType()) How can the MLOps engineer change this code to reduce how many times the language model is loaded?
Select one answer.
Purchase Full Access to view answer options & explanation
The first 118 questions in this bank are completely free. Unlock Full Access on the exam page to view all answer choices, verified answers, explanations, and community discussions for all 392 questions.