0
0
NLPml~10 mins

Model selection for tasks in NLP - Interactive Code Practice

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

Complete the code to import the model used for text classification.

NLP
from sklearn.[1] import LogisticRegression
Drag options to blanks, or click blank then click option'
Acluster
Blinear_model
Censemble
Ddecomposition
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'ensemble' which contains tree-based models.
Choosing 'cluster' which is for clustering algorithms.
2fill in blank
medium

Complete the code to create a model for sentiment analysis using a pretrained transformer.

NLP
from transformers import [1]
model = [1].from_pretrained('distilbert-base-uncased-finetuned-sst-2-english')
Drag options to blanks, or click blank then click option'
ADistilBertForSequenceClassification
BBertModel
CGPT2Model
DRobertaModel
Attempts:
3 left
💡 Hint
Common Mistakes
Using BertModel which is a base model without classification head.
Using GPT2Model which is for text generation.
3fill in blank
hard

Fix the error in the code to select the right model for named entity recognition (NER).

NLP
from transformers import AutoModelFor[1]
model = AutoModelFor[1].from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
Drag options to blanks, or click blank then click option'
ASequenceClassification
BQuestionAnswering
CTokenClassification
DMaskedLM
Attempts:
3 left
💡 Hint
Common Mistakes
Using SequenceClassification which is for whole sentence labels.
Using MaskedLM which is for language modeling.
4fill in blank
hard

Fill both blanks to create a pipeline for text summarization using Hugging Face.

NLP
from transformers import pipeline
summarizer = pipeline(task=[1], model=[2])
Drag options to blanks, or click blank then click option'
A'summarization'
B'translation_en_to_fr'
C'facebook/bart-large-cnn'
D'text-generation'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'translation_en_to_fr' which is for translation.
Using 'text-generation' which is for generating text, not summarizing.
5fill in blank
hard

Fill all three blanks to build and evaluate a simple text classification model using scikit-learn.

NLP
from sklearn.feature_extraction.text import [1]
from sklearn.linear_model import [2]
from sklearn.metrics import [3]

vectorizer = [1]()
X_train_vec = vectorizer.fit_transform(X_train)
model = [2]()
model.fit(X_train_vec, y_train)
y_pred = model.predict(vectorizer.transform(X_test))
score = [3](y_test, y_pred)
Drag options to blanks, or click blank then click option'
ACountVectorizer
BLogisticRegression
Caccuracy_score
DTfidfVectorizer
Attempts:
3 left
💡 Hint
Common Mistakes
Using TfidfVectorizer instead of CountVectorizer (both work but only one is correct here).
Using other metrics like precision instead of accuracy_score.