Closed entslscheia closed 5 years ago
We still use the Trainer
. It sounds like you're writing your own script to train your model; I'd recommend using the allennlp train
command instead. You can follow this tutorial to learn more about how that whole setup works. In this repo, you'll find DatasetReaders
and Models
, plus a bunch of code that gets used inside those for semantic-parsing-specific stuff, and that's it. The Trainer
code lives in the main repo, and we train using allennlp train
and a configuration file.
As a newbie to allennlp, my understanding of the paradigm of training a model using allennlp is that we should have a
DatasetReader
object to read the data from disk, anIterator
object to batch the training data (i.e., objects ofInstance
), and aModel
object to set up the computational graphs. Then basically, we pass those objects and an optimizer (or some other options) to aTrainer
objecttrainer = Trainer(...)
, and train the model usingtrainer.train()
.However, for the semantic parsing framework, I didn't see any code related to
allennlp.training.Trainer
, and the behavior ofDecoderTrainer
seems totally different fromTrainer
in allennlp. Instead of taking aModel
object as a parameter to train, aDecoderTrainer
object is served as a parameter of aModel
object (e.g.,MaximumMarginalLikelihood
is insideWikiTablesMmlSemanticParser
) to compute the loss.So how do we exactly train a semantic parser programmatically? Are we still using a
allennlp.training.Trainer
object to incorporate everything (i.e., the model, dataset and an iterator) and train the model by callingtrain()
?I have read part of the source codes and have a basic understanding of how the semantic parsing framework looks like but didn't see any concrete example that includes a complete pipeline to train a semantic parser. I don't know maybe my question is kind of naive or trivial, but still confused for now.