Error while predicting on single sentence for token classification task
Hi

I have fine-tuned BERT for NER task. I am predicting on the fine-tuned model as:

`output = self.tokenizer(text)
trainer = Trainer(model=self.model, tokenizer=self.tokenizer)
trainer.predict(output)`

This code snippet is throwing the following error:

  File "run_ner_test_3.py", line 486, in <module>
    obj.predict(text="i require to send 9330793.33 by account")
  File "run_ner_test_3.py", line 430, in predict
    trainer.predict(output)
  File "/home/dev01/python_3/lib/python3.6/site-packages/transformers/trainer.py", line 1596, in predict
    test_dataloader, description="Prediction", ignore_keys=ignore_keys, metric_key_prefix=metric_key_prefix
  File "/home/dev01/python_3/lib/python3.6/site-packages/transformers/trainer.py", line 1658, in prediction_loop
    for step, inputs in enumerate(dataloader):
  File "/home/dev01/python_3/lib64/python3.6/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/home/dev01/python_3/lib64/python3.6/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/dev01/python_3/lib64/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/dev01/python_3/lib64/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/dev01/python_3/lib/python3.6/site-packages/transformers/tokenization_utils_base.py", line 305, in __getitem__
    return self._encodings[item]
IndexError: list index out of range


Can you please suggest how to predict on a single sentence?
@saurabhhssaurabh `trainer.predict()` expects an instance of `torch.utils.data.Dataset` to be passed and not a single sentence. I think it will be easier to use the trained model at self.model to predict rather than trying to use trainer object, as it does not have any single prediction method yet.<|||||>@frankhart2018 
Thank you for replying. I will implement code using prediction from self.model.