def _run_test_repeat(self, tmpdir: str, fake_input: FakeInput):
        outfile = os.path.join(tmpdir, 'log.jsonl')
        pp = interactive.setup_args()
        opt = pp.parse_args(['-m', 'repeat_query', '--outfile', outfile])
        interactive.interactive(opt)

        log = conversations.Conversations(outfile)
        self.assertEqual(len(log), fake_input.max_episodes)
        for entry in log:
            self.assertEqual(len(entry), 2 * fake_input.max_turns)
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Basic example which allows local human keyboard input to talk to a trained model.

For documentation, see parlai.scripts.interactive.
"""
from parlai.scripts.interactive import setup_args, interactive
import random


if __name__ == '__main__':
    random.seed(42)
    parser = setup_args()
    opt = parser.parse_args()
    interactive(opt, print_parser=parser)
Beispiel #3
0
from parlai.core.build_data import download_models
from parlai.core.params import ParlaiParser
from parlai.scripts.interactive import interactive
from projects.personachat.persona_seq2seq import PersonachatSeqseqAgentBasic
'''Interact with pre-trained model
Generative model trained on personachat using persona 'self'
Run from ParlAI directory
'''

if __name__ == '__main__':
    parser = ParlaiParser(add_model_args=True)
    parser.add_argument('-d', '--display-examples', type='bool', default=False)
    PersonachatSeqseqAgentBasic.add_cmdline_args(parser)
    parser.set_defaults(
        dict_file='models:personachat/profile_memory/fulldict.dict',
        interactive_mode=True,
        task='parlai.agents.local_human.local_human:LocalHumanAgent',
        model=
        'projects.personachat.persona_seq2seq:PersonachatSeqseqAgentBasic',
        model_file=
        'models:personachat/seq2seq_personachat/seq2seq_no_dropout0.2_lstm_1024_1e-3'
    )

    opt = parser.parse_args()
    opt['model_type'] = 'seq2seq_personachat'  # for builder
    # build all profile memory models
    fnames = ['seq2seq_no_dropout0.2_lstm_1024_1e-3', 'fulldict.dict']
    download_models(opt, fnames, 'personachat')

    interactive(opt)
Beispiel #4
0
 def test_repeat(self):
     pp = interactive.setup_args()
     opt = pp.parse_args(
         ['-m', 'repeat_query', '-t', 'convai2', '-dt', 'valid'],
         print_args=False)
     interactive.interactive(opt)
Beispiel #5
0
 def test_repeat(self):
     pp = interactive.setup_args()
     opt = pp.parse_args(['-m', 'repeat_query'], print_args=False)
     interactive.interactive(opt)
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from parlai.scripts.interactive import setup_args, interactive

import random

if __name__ == '__main__':
    random.seed(42)
    parser = setup_args()

    parser.set_params(batchsize=1, beam_size=20, beam_min_n_best=10)

    print('\n' + '*' * 80)
    print(
        'WARNING: This dialogue model is a research project that was trained on a'
    )
    print(
        'large amount of open-domain Twitter data. It may generate offensive content.'
    )
    print('*' * 80 + '\n')

    interactive(parser.parse_args(print_args=False), print_parser=parser)
Beispiel #7
0
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from parlai.scripts.interactive import setup_args, interactive

import random

if __name__ == '__main__':
    random.seed(42)
    parser = setup_args()

    parser.set_params(batchsize=1, beam_size=20, beam_min_n_best=10)

    print('\n' + '*' * 80)
    print(
        'WARNING: This dialogue model is a research project that was trained on a'
    )
    print(
        'large amount of open-domain Twitter data. It may generate offensive content.'
    )
    print('*' * 80 + '\n')

    interactive(parser.parse_args())