Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

How to load custom reader and predictor using code #5250

Answered by skasim
skasim asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out a solution. The crf_tagger Model was not loading from the serialization_dir when running with custom code, so now I am loading the model directly from archive:

import allennlp_models.tagging as tagging

raw_reader = AllenNLPRawTextReader()
instance = Instance(list(raw_reader.read(file_path=article))[0])
model = tagging.CrfTagger.from_archive(archive_file="https://storage.googleapis.com/allennlp-public-models/fine-grained-ner.2021-02-11.tar.gz")
predictor = AllenNLPRawTextPredictor(model=model, dataset_reader=raw_reader, frozen=False)
outputs = predictor.predict_instance(instance=instance)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@epwalsh
Comment options

Answer selected by skasim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants