facebookresearch / ParlAI

A framework for training and evaluating AI models on a variety of openly available dialogue datasets.
https://parl.ai
MIT License
10.48k stars 2.09k forks source link

trained a attention lstm model, how to save it and using it? #52

Closed lucasjinreal closed 7 years ago

lucasjinreal commented 7 years ago

I just run this command:

python3 examples/drqa/train.py -t squad -b 32 

to train a attention based lstm model, using squad dataset, its runing, but I how do I using it, and evalue it?

ajfisch commented 7 years ago

Hi, the full list of options for the drqa agent is here: https://github.com/facebookresearch/ParlAI/blob/master/parlai/agents/drqa/config.py#L16-L73 (can also be shown by running --help).

To save the best valid model, pass --model_file /path/to/saved/model. To start with a trained model and its saved options, pass --pretrained_model /path/to/saved/model.

In the example, the model is validated as it trains (after every --train_interval updates). To only run evaluation in a script, you can follow the logic of the validate function here: https://github.com/facebookresearch/ParlAI/blob/master/examples/drqa/train.py#L54-L70

lucasjinreal commented 7 years ago

Many thanks for the reply!

lucasjinreal commented 7 years ago

BTW, if I want using this trained seq2seq model, to test a sentence and get reply, how do I preprocess it and send it into model and eventually get a reply sentence? Or ParlAI only supports large scale test.

ajfisch commented 7 years ago

Hi,

We are planning to include a 'Human Agent' in the near future, which would allow you to easily get an interactive session running.

In the meantime, you can hack the agent by using a script like this: https://gist.github.com/ajfisch/d447b9fd610b1d9868843350145fc6e3

lucasjinreal commented 7 years ago

Thanks! This seems exactly what I want! Help you guys make parlai more powerful and useful!