Closed LLLLLLoki closed 4 years ago
@LLLLLLoki Do you want to predict in python script or command line? Predictor
is usually used in allennlp predict command such as below:
allennlp predict \
--predictor rewrite \
--include-package data_reader \
--include-package model \
--include-package predictor \
--dataset-reader-choice validation \
--batch-size 24 \
--cuda-device 0 \
--output-file predict_test.jsonl \
BTW, this requires developers to convert the txt file into .jsonl
format.
Which one do you need? A in-code function
or just a command
? I will prepare one for your convenience.
Could you provide A in-code function for me ? thank you
@LLLLLLoki I will update in 2 days. (since it's also new for me to write an in-code function lol)
@LLLLLLoki Hi, I have uploaded an in-code predict function here. Please check and enjoy it :)
I learned a lot from your code and your papers,Thank you very much.
@LLLLLLoki Very pleased to hear that ☕
I'm not very familiar with AllenNLP api,How do you use the prediction code? I write the following code that reports an " TypeError: is_bidirectional() missing 1 required positional argument: 'self'" error
@Predictor.register("rewrite") class RewritePredictor(Predictor):
inputs = { "context":'浙 江 省 温 州 市 鹿 城 区 有 好 天 气 这 种 天 气 最 适 合 出 门 了 骑 骑 车 兜 兜 风', "current":'明 天 天 气 咋 样', "restate_utt":'hi' } model = UnifiedFollowUp( Vocabulary, Seq2SeqEncoder, TextFieldEmbedder ) dataset_reader = RewriteDatasetReader()
pred_fun = RewritePredictor(model = model,dataset_reader = dataset_reader) result = pred_fun._json_to_instance(inputs)