0
0
NLPml~20 mins

NER with spaCy in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
NER spaCy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Named Entity Recognition with spaCy
What is the output of the following code snippet that uses spaCy to detect named entities in a sentence?
NLP
import spacy
nlp = spacy.load('en_core_web_sm')
doc = nlp('Apple is looking at buying U.K. startup for $1 billion')
entities = [(ent.text, ent.label_) for ent in doc.ents]
print(entities)
A[('Apple', 'ORG'), ('U.K.', 'GPE'), ('$1 billion', 'MONEY')]
B[('Apple', 'PERSON'), ('U.K.', 'LOC'), ('$1 billion', 'MONEY')]
C[('Apple', 'ORG'), ('startup', 'ORG'), ('$1 billion', 'MONEY')]
D[('Apple', 'ORG'), ('U.K.', 'ORG'), ('$1 billion', 'MONEY')]
Attempts:
2 left
💡 Hint
Look at common entity labels spaCy uses for organizations, geopolitical entities, and money.
Model Choice
intermediate
1:30remaining
Choosing the Correct spaCy Model for NER
Which spaCy model is best suited for performing Named Entity Recognition on English text with a balance of speed and accuracy?
Aen_core_web_md
Ben_vectors_web_lg
Cen_core_web_lg
Den_core_web_sm
Attempts:
2 left
💡 Hint
Consider models that include trained pipelines for NER and balance size and speed.
Hyperparameter
advanced
2:00remaining
Effect of Batch Size in spaCy NER Training
During training a spaCy NER model, what is the effect of increasing the batch size parameter?
AIt slows down training and always improves model accuracy.
BIt causes the model to overfit immediately.
CIt has no effect on training speed or accuracy.
DIt speeds up training but may reduce model accuracy due to less frequent weight updates.
Attempts:
2 left
💡 Hint
Think about how batch size affects gradient updates and training speed.
Metrics
advanced
1:30remaining
Evaluating spaCy NER Model Performance
Which metric is most appropriate to evaluate the quality of a spaCy Named Entity Recognition model on a test dataset?
AAccuracy of token classification
BMean Squared Error
CF1-score
DPerplexity
Attempts:
2 left
💡 Hint
NER is a sequence labeling task with imbalanced classes; consider precision and recall.
🔧 Debug
expert
2:30remaining
Debugging spaCy NER Model Training Error
You run spaCy NER training code but get this error: 'ValueError: [E088] The component 'ner' is not initialized. Call 'nlp.begin_training()' first.' Which code snippet fixes this error?
A
nlp = spacy.load('en_core_web_sm')
ner = nlp.get_pipe('ner')
optimizer = nlp.begin_training()
B
nlp = spacy.blank('en')
ner = nlp.add_pipe('ner')
optimizer = nlp.begin_training()
C
nlp = spacy.load('en_core_web_sm')
optimizer = nlp.create_optimizer()
D
nlp = spacy.blank('en')
optimizer = nlp.begin_training()
Attempts:
2 left
💡 Hint
The error means the 'ner' component is missing or not initialized properly.