          if isinstance(docs, Doc):
              docs = [docs]
  
          for i, doc in enumerate(docs):
              if len(doc) > 0:
                  context_encoding = context_encodings[i]
                  context_enc_t = context_encoding.T
 
</s> remove                 context_encoding = self.model([doc])
                context_enc_t = np.transpose(context_encoding)
 </s> add                 context_encoding = context_encodings[i]
                context_enc_t = context_encoding.T
                norm_1 = xp.linalg.norm(context_enc_t) </s> remove         docs = el_pipe.pipe(docs)
 </s> add         print("applying el_pipe", datetime.datetime.now())
        docs = list(el_pipe.pipe(docs, batch_size=10000000000))
        print("done applying el_pipe", datetime.datetime.now()) </s> remove             entity_encodings = np.asarray(entity_encodings, dtype=np.float32)
 </s> add             entity_encodings = self.model.ops.asarray(entity_encodings, dtype="float32") </s> remove                         scores = []
                        for c in candidates:
                            prior_prob = c.prior_prob * self.prior_weight
                            kb_id = c.entity_
                            entity_encoding = c.entity_vector
                            sim = float(cosine(np.asarray([entity_encoding]), context_enc_t)) * self.context_weight
                            score = prior_prob + sim - (prior_prob*sim)
                            scores.append(score)
 </s> add                         prior_probs = xp.asarray([c.prior_prob for c in candidates])
                        prior_probs *= self.prior_weight

                        entity_encodings = xp.asarray([c.entity_vector for c in candidates])
                        norm_2 = xp.linalg.norm(entity_encodings, axis=1)

                        # cosine similarity
                        sims = xp.dot(entity_encodings, context_enc_t) / (norm_1 * norm_2)
                        sims *= self.context_weight
                        scores = prior_probs + sims - (prior_probs*sims)
                        best_index = scores.argmax() </s> remove     to_read_nlp = True
 </s> add     to_read_nlp = False
        context_encodings = self.model(docs)
        xp = get_array_module(context_encodings)

          if isinstance(docs, Doc):
              docs = [docs]
  
        context_encodings = self.model(docs)
        xp = get_array_module(context_encodings)

          for i, doc in enumerate(docs):
              if len(doc) > 0:
                  context_encoding = context_encodings[i]
                  context_enc_t = context_encoding.T
keep keep add keep keep keep keep
 improve speed of prediction loop 
spacy/pipeline/pipes.pyx