0
0
NLPml~10 mins

Batch vs real-time inference in NLP - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to perform batch inference on a list of texts using a model.

NLP
predictions = model.predict([1])
Drag options to blanks, or click blank then click option'
Asentence
Btext
Ctexts
Dinput_text
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single string instead of a list causes errors or wrong predictions.
2fill in blank
medium

Complete the code to perform real-time inference on a single input text.

NLP
result = model.predict([1])
Drag options to blanks, or click blank then click option'
Atexts
Btext
Cbatch
Dinputs
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a list instead of a single string causes shape errors.
3fill in blank
hard

Fix the error in the batch inference code by choosing the correct input format.

NLP
outputs = model.predict([1])
Drag options to blanks, or click blank then click option'
Atexts
B[text]
Ctext
Dtext.split()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single string or a list with one string inside causes unexpected results.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each text to its prediction in batch mode.

NLP
results = {text: model.predict([1]) for text in [2]
Drag options to blanks, or click blank then click option'
A[text]
Btext
Ctexts
Dtext.split()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing text directly without wrapping causes errors.
Iterating over a single string instead of the list of texts.
5fill in blank
hard

Fill all three blanks to create a batch inference dictionary that filters texts longer than 5 words and maps them to predictions.

NLP
filtered_results = { [1]: model.predict([[2]]) for [3] in texts if len([1].split()) > 5 }
Drag options to blanks, or click blank then click option'
Atext
Dsentence
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not wrapping the input in a list for prediction.