How to Ensure Consistent Preprocessing Between Training and Serving?
You have trained a model by using data that was preprocessed in a batch Dataflow pipeline. Your use case requires real-time inference. You want to ensure that the data preprocessing logic is applied consistently between training and serving. What should you do?
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question tests the mitigation of training-serving skew by reusing transformation code, trapping candidates who choose data validation or batching strategies that fail to maintain logical consistency.
To prevent training-serving skew, the preprocessing logic used during training must be identically applied during inference. The community consensus is that refactoring batch pipeline code into a reusable module for the endpoint is the correct approach.
Choosing Option A is a common mistake because while data validation is good practice, it only checks data format and does not ensure the preprocessing logic itself is consistent across environments.
Community Discussion (5 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Refactoring the transformation code into a standalone module allows it to be imported and executed directly within the inference endpoint. By embedding this logic into the serving environment (e.g., within aserving_fn), you guarantee that the exact same mathematical operations applied to training data are applied to real-time requests. This approach satisfies the real-time requirement without the latency introduced by batch processing methods.Why the Other Options Are Wrong
Option A focuses on data validation, which confirms schema compatibility but fails to enforce that the actual preprocessing logic is identical. Option C is incorrect because it offloads preprocessing to end users, creating a poor user experience and high potential for error. Option D introduces latency through batching, which violates the real-time inference constraint and adds unnecessary architectural complexity.Community Comment Notes
Commenters highlighted that implementing identical transformations in theserving_fn function is the standard method to define the serving interface for a SavedModel. There was unanimous agreement (100% of votes) that code reuse is the only effective way to ensure consistency, with specific references made to TensorFlow's documentation on serving functions. Official Reference
Exam Strategy
When facing questions about training-serving skew, always look for the option that promotes code reuse between the training pipeline and the serving application. Avoid options that suggest batching for real-time needs or delegate data processing tasks to the client.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →