Example #1
0
    def __init__(self, model, device, maxlen=-1):
        self.check_agent(model)
        maxlen = maxlen if maxlen > 0 else self.default_maxlen()

        if "wizard_of_wikipedia.context_and_label" in model:
            name = "rep_wiki_ctxt_and_label"
        elif "wizard_of_wikipedia.context" in model:
            name = "rep_wiki_ctxt"
        elif "wizard_of_wikipedia.label" in model:
            name = "rep_label_ctxt"
        elif "convai2.context_and_label" in model:
            name = "rep_convai2_ctxt_and_label"
        elif "convai2.context" in model:
            name = "rep_convai2_ctxt"
        elif "convai2.label" in model:
            name = "rep_convai2_label"
        elif "convai2.vocab.alpha.1e-0" in model:
            name = "vocab_alpha1e0"
        elif "convai2.vocab.alpha.1e-1" in model:
            name = "vocab_alpha1e1"
        elif "convai2.vocab.alpha.1e-2" in model:
            name = "vocab_alpha1e2"
        elif "convai2.vocab.alpha.1e-3" in model:
            name = "vocab_alpha1e3"
        elif "eli5.context_and_label" in model:
            name = "rep_eli5_ctxt_and_label"
        elif "eli5.context" in model:
            name = "rep_eli5_ctxt"
        elif "eli5.label" in model:
            name = "rep_eli5_label"
        else:
            raise Exception(f"wrong model: {model}")

        option, model_class = self.set_options(
            name=f"zoo:dialogue_unlikelihood/{name}/model",
            path="projects.dialogue_unlikelihood.agents",
            class_name="RepetitionUnlikelihoodAgent",
            device=device,
        )

        super().__init__(
            device=device,
            name=model,
            maxlen=maxlen,
            suffix="\n",
            model=create_agent_from_opt_file_and_model_class(
                opt=option,
                model_class=model_class,
            ),
        )

        if "wizard_of_wikipedia" in model:
            inherit(self, (WizardOfWikipediaAgent, Seq2SeqLM))
            self.build_wizard_of_wikipedia()

        elif "convai2" in model:
            inherit(self, (ConvAI2Agent, Seq2SeqLM))
Example #2
0
    def __init__(self, model, device, maxlen):
        model = self.check_agent(model)
        maxlen = maxlen if maxlen > 0 else self.default_maxlen()

        model = model + "_ft" if model != "all_tasks_mt" else model
        name = f"zoo:dodecadialogue/{model.split('.')[-1]}/model"
        option = self.set_options(name, device)

        super().__init__(
            name=model,
            suffix="\n",
            device=device,
            maxlen=maxlen,
            model=create_agent_from_opt_file(option),
        )

        if "wizard_of_wikipedia" in name:
            inherit(self, (WizardOfWikipediaAgent, Seq2SeqLM))
            self.build_wizard_of_wikipedia()

        elif "convai2" in name:
            inherit(self, (ConvAI2Agent, Seq2SeqLM))