title: NLP: How to train a spaCy NER Model using GoldParse objects
body: <p>I am trying to train a spaCy NER model using GoldParse objects. This is what I have done:</p>
  <p><em>Adding extra labels to NER model</em></p>
  <pre><code>add_ents = ['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1'] # sample labels
  
  # Create a pipe if it does not exist
  if &quot;ner&quot; not in nlp.pipe_names:
      ner = nlp.create_pipe(&quot;ner&quot;) 
      nlp.add_pipe(ner)
  else:
      ner = nlp.get_pipe(&quot;ner&quot;)
  
  for e in add_ents:
      ner.add_label(e)
  </code></pre>
  <p><em>Training the NER Model</em></p>
  <pre><code>other_pipes = [pipe for pipe in nlp.pipe_names if pipe != &quot;ner&quot;]
  model = None # Since we training a fresh model not a saved model
  with nlp.disable_pipes(*other_pipes):  # only train ner
      if model is None:
          optimizer = nlp.begin_training()
      else:
          optimizer = nlp.resume_training()
      for i in range(20):
          loss = {}
          nlp.update(X, y,  sgd=optimizer, drop=0.0, losses=loss)
          print(&quot;Loss: &quot;, loss)
  </code></pre>
  <p>Here X is a list of Doc objects and y is a list of corresponding GoldParse objects. While executing I am running into the following error:</p>
  <pre><code>nn_parser.pyx in spacy.syntax.nn_parser.Parser.update()
  
  nn_parser.pyx in spacy.syntax.nn_parser.Parser._init_gold_batch()
  
  ner.pyx in spacy.syntax.ner.BiluoPushDown.preprocess_gold()
  
  ner.pyx in spacy.syntax.ner.BiluoPushDown.lookup_transition()
  
  ValueError: 'A1' is not in list
  </code></pre>
  <p>I tried searching for the solution but couldn't find anything relevant. Is there a way to fix this issue?</p>