CommencerCommencer gratuitement

Training preparation steps

Before and during training of a spaCy model, you'll need to (1) disable other pipeline components in order to only train the intended component and (2) convert a Doc container of a training data point and its corresponding annotations into an Example class.

In this exercise, you will practice these two steps by using a pre-loaded en_core_web_sm model, which is accessible as nlp. Example class is already imported and a text string and related annotations are also available for your use.

Cet exercice fait partie du cours

Natural Language Processing with spaCy

Afficher le cours

Instructions

  • Disable all pipeline components of the nlp model except ner.
  • Convert a text string and its annotations to the correct format usable for training.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

nlp = spacy.load("en_core_web_sm")

# Disable all pipeline components of  except `ner`
other_pipes = [____ for ____ in nlp.____ if ____ != 'ner']
nlp.____(*other_pipes)

# Convert a text and its annotations to the correct format usable for training
doc = nlp.____(text)
example = Example.____(____, ____)
print("Example object for training: \n", example.to_dict())
Modifier et exécuter le code