title: BERT get sentence level embedding after fine tuning
body: <p>I came across this <a href="https://colab.research.google.com/github/google-research/bert/blob/master/predicting_movie_reviews_with_bert_on_tf_hub.ipynb#scrollTo=KVB3eOcjxxm1" rel="nofollow noreferrer">page</a></p>
  
  <p>1) I would like to get sentence level embedding (embedding given by <code>[CLS]</code> token) after the fine tuning is done. How could I do it?</p>
  
  <p>2) I also noticed that the code on that page takes a lot of time to return results on the test data. Why is that? When i trained the model it took less time as compared to when i tried to get test predictions. 
  From the code on that page, I didnt use below blocks of the code</p>
  
  <pre><code>test_InputExamples = test.apply(lambda x: bert.run_classifier.InputExample(guid=None, 
                                                                         text_a = x[DATA_COLUMN], 
                                                                         text_b = None, 
                                                                         label = x[LABEL_COLUMN]), axis = 1
  
  test_features = bert.run_classifier.convert_examples_to_features(test_InputExamples, label_list, MAX_SEQ_LENGTH, tokenizer)
  
  test_input_fn = run_classifier.input_fn_builder(
          features=test_features,
          seq_length=MAX_SEQ_LENGTH,
          is_training=False,
          drop_remainder=False)
  
  estimator.evaluate(input_fn=test_input_fn, steps=None)
  </code></pre>
  
  <p>Rather I just used below function on my entire test data</p>
  
  <pre><code>def getPrediction(in_sentences):
    labels = ["Negative", "Positive"]
    input_examples = [run_classifier.InputExample(guid="", text_a = x, text_b = None, label = 0) for x in in_sentences] # here, "" is just a dummy label
    input_features = run_classifier.convert_examples_to_features(input_examples, label_list, MAX_SEQ_LENGTH, tokenizer)
    predict_input_fn = run_classifier.input_fn_builder(features=input_features, seq_length=MAX_SEQ_LENGTH, is_training=False, drop_remainder=False)
    predictions = estimator.predict(predict_input_fn)
    return [(sentence, prediction['probabilities'], labels[prediction['labels']]) for sentence, prediction in zip(in_sentences, predictions)]
  </code></pre>
  
  <p>3) how could i get probability of prediction. is there a way to use <code>keras predict</code> method?</p>
  
  <h1>update1</h1>
  
  <p>question 2 update -
  could you test on 20000 training examples using <code>getPrediction</code> function?....it takes much longer time for me..even more than the time took to train model on 20000 examples.</p>