Is it possible to run the "predict" command using a different DatasetReader?

I’ve written a Predictor, and I’d like to be able to use it to make predictions on a dataset that is loaded by a different DatasetReader than both my training and validation dataset readers. I’ve been reading the docs for the “predict” command here:
and while I can see that it’s possible to specify a choice of either {train, validation}. But I can’t figure out how to use a datareader that I didn’t use for either train or validation.

Apologies if this is a simple or obvious question! I’m new to AllenNLP. But I have spent a bunch of time trying to troubleshoot this question before asking for help, and would super appreciate any help or advice!

It looks to me like these three things should make it work:

  1. Pass the --use-dataset-reader flag to allennlp predict
  2. When you write your Predictor subclass, pass the dataset reader that you want to use to the super class constructor. (This might mean ignoring a constructor argument that gets passed to your subclass by Predictor.from_archive.)
  3. Pass the --predictor argument with the name that you’ve registered for the predictor that you wrote.

If you do those things, you should get the right dataset reader being used during predict. If you don’t, we’ll probably need a lot more detail to try to figure out what’s going on.


Yes, that did it! Thanks so much for the prompt and helpful response.