0
0
NLPml~20 mins

Batch vs real-time inference in NLP - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch vs Real-time Inference Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding batch inference

Which of the following best describes batch inference in machine learning?

ATraining the model using multiple data points in one go.
BGenerating predictions instantly for each data point as it arrives.
CProcessing many data points together at once, usually offline, to generate predictions.
DUpdating the model weights continuously during prediction.
Attempts:
2 left
💡 Hint

Think about when predictions are made: all at once or one by one?

🧠 Conceptual
intermediate
2:00remaining
Real-time inference use case

Which scenario is best suited for real-time inference?

ARecommending a product immediately after a user clicks on a website.
BArchiving old prediction results for future analysis.
CTraining a language model on millions of sentences.
DAnalyzing a large dataset overnight to update customer segments.
Attempts:
2 left
💡 Hint

Consider when the prediction is needed: instantly or later?

Metrics
advanced
2:00remaining
Latency comparison between batch and real-time inference

Given a model that takes 0.01 seconds to predict one input, what is the expected latency for batch inference processing 1000 inputs at once compared to real-time inference processing one input at a time?

ABatch latency ~10 seconds; Real-time latency ~0.01 seconds per input.
BBatch latency ~100 seconds; Real-time latency ~1 second per input.
CBatch latency ~0.1 seconds; Real-time latency ~0.1 seconds per input.
DBatch latency ~0.01 seconds; Real-time latency ~10 seconds per input.
Attempts:
2 left
💡 Hint

Multiply prediction time by number of inputs for batch; real-time is per input.

🔧 Debug
advanced
2:00remaining
Identifying error in real-time inference code snippet

What error will this Python code raise when performing real-time inference?

def predict_real_time(model, inputs):
    results = []
    for input in inputs:
        prediction = model.predict(input)
        results.append(prediction)
    return results

# inputs is a list of data points
ANameError because 'input' is a reserved keyword.
BSyntaxError due to incorrect indentation of results.append(prediction).
CTypeError because model.predict expects a batch, not single input.
DThe results list will contain only the last prediction, missing others.
Attempts:
2 left
💡 Hint

Check where the prediction is added to results inside the loop.

Model Choice
expert
2:00remaining
Choosing model architecture for batch vs real-time inference

You have two model architectures: Model A is large and accurate but slow; Model B is smaller and faster but less accurate. For a chatbot requiring instant replies, which model is best?

AModel A, because accuracy is most important regardless of speed.
BModel B, because real-time inference needs fast responses even if less accurate.
CUse Model A for batch inference and Model B for real-time inference simultaneously.
DNeither, because chatbots should only use rule-based systems.
Attempts:
2 left
💡 Hint

Consider the trade-off between speed and accuracy for instant replies.