QuestionQ186

VerifiedUsing Pandas API on Spark

An MLOps engineer is developing a Pandas UDF that uses a language model to translate English strings to Spanish. The initial code loads the model on every UDF call, which is degrading data-pipeline performance.

The initial code is:

Question Image

How can the MLOps engineer modify this code to reduce the number of times the language model is loaded?

Explanation

An Iterator[pandas.Series] -> Iterator[pandas.Series] Pandas UDF can initialize expensive state, such as a language model, once before processing the input iterator and reuse that state for every Series batch it yields. This avoids loading the model once per Series-to-Series UDF batch.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!