def from_archive(cls, archive: Archive, predictor_name: str = None) -> 'Predictor':
        """
        Instantiate a :class:`Predictor` from an :class:`~allennlp.models.archival.Archive`;
        that is, from the result of training a model. Optionally specify which `Predictor`
        subclass; otherwise, the default one for the model will be used.
        """
        # Duplicate the config so that the config inside the archive doesn't get consumed
        config = archive.config.duplicate()

        if not predictor_name:
            model_type = config.get("model").get("type")
            if not model_type in DEFAULT_PREDICTORS:
                raise ConfigurationError(f"No default predictor for model type {model_type}.\n"\
                                         f"Please specify a predictor explicitly.")
            predictor_name = DEFAULT_PREDICTORS[model_type]

        dataset_reader_params = config["dataset_reader"]
        dataset_reader = DatasetReader.from_params(dataset_reader_params)

        model = archive.model
        model.eval()

        return Predictor.by_name(predictor_name)(model, dataset_reader)
def from_archive ( cls , archive : Archive , predictor_name : str = None ) -> 'Predictor' : config = archive . config . duplicate ( ) if not predictor_name : model_type = config . get ( "model" ) . get ( "type" ) if not model_type in DEFAULT_PREDICTORS : raise ConfigurationError ( f"No default predictor for model type {model_type}.\n" f"Please specify a predictor explicitly." ) predictor_name = DEFAULT_PREDICTORS [ model_type ] dataset_reader_params = config [ "dataset_reader" ] dataset_reader = DatasetReader . from_params ( dataset_reader_params ) model = archive . model model . eval ( ) return Predictor . by_name ( predictor_name ) ( model , dataset_reader )
Instantiate a :class:`Predictor` from an :class:`~allennlp.models.archival.Archive`;
        that is, from the result of training a model. Optionally specify which `Predictor`
        subclass; otherwise, the default one for the model will be used.