sogou / SogouMRCToolkit

This toolkit was designed for the fast and efficient development of modern machine comprehension models, including both published models and original prototypes.
Apache License 2.0
746 stars 164 forks source link

After the model training, I want to input a paragraph and a question, and then get the output answer, how to do #22

Open hl0929 opened 5 years ago

ronaktanna1 commented 5 years ago

I have a similar concern. Is there any boilerplate code that can be used to get inference on new paragraph and questions?

yylun commented 5 years ago

If you want a interactive or data-streaming way to do inference with a trained model, unfortunately there is no boilerplate code yet. A simple idea to implement it is to modify the BatchGenerator class.

In examples, you have to feed the instance list to BatchGenerator because BatchGenerator need to do type detection for all fields(https://github.com/sogou/SMRCToolkit/blob/master/sogou_mrc/data/batch_generator.py#L49). If types of all fields are known, you can simply pass a generator of you data to inner Dataset(https://github.com/sogou/SMRCToolkit/blob/master/sogou_mrc/data/batch_generator.py#L108-L116). Then use it as other examples and run inference with you model.

Maybe will add a StreamBatchGenerator

hl0929 commented 5 years ago

If you want a interactive or data-streaming way to do inference with a trained model, unfortunately there is no boilerplate code yet. A simple idea to implement it is to modify the BatchGenerator class.

In examples, you have to feed the instance list to BatchGenerator because BatchGenerator need to do type detection for all fields(https://github.com/sogou/SMRCToolkit/blob/master/sogou_mrc/data/batch_generator.py#L49). If types of all fields are known, you can simply pass a generator of you data to inner Dataset(https://github.com/sogou/SMRCToolkit/blob/master/sogou_mrc/data/batch_generator.py#L108-L116). Then use it as other examples and run inference with you model.

Maybe will add a StreamBatchGenerator

thank you