Example #1
0
    def run_selfchat(self):
        """
        Run selfchat for each model.
        """
        for model in self.models:
            try:
                torch.cuda.empty_cache()
            except Exception:
                pass
            self._print_progress(f'Running self-chat for {model}')
            outfile = self._get_selfchat_log_path(model)

            if not os.path.exists(outfile):
                config = self._get_selfchat_config(model)

                with capture_output():
                    parser = self_chat_setup_args()
                    parser.set_params(**config)
                    opt = parser.parse_args(args=[])
                self_chat(opt)

                if os.path.exists(outfile):
                    self._print_progress(f'Chats saved to {outfile} for {model}')

            self._print_progress(f'Chats already exist in {outfile}, moving on...')
            self.chat_files[model] = outfile
Example #2
0
    def _run_selfchat(self, config_id: str):
        """
        Run self-chat for model.

        :param config_id:
            id in config
        """
        self._print_progress(f'Running self-chat for {config_id}')
        config = self._get_selfchat_config(config_id)

        with capture_output():
            parser = self_chat_setup_args()
            parser.set_params(**config)
            opt = parser.parse_args(args=[])
        self_chat(opt)
Example #3
0
    def compile_chat_logs(self):
        """
        Compile chat logs.

        Logs are generated depending on what is specified in the config for the model:
        1. If a `model` is provided, run selfchat for model
        2. If a `log_path` is provided, simply load the log path
        3. If a `task` is provided, convert the task to ACUTE format and load that.
        """
        for model in self.models:
            try:
                torch.cuda.empty_cache()
            except Exception:
                pass
            self._print_progress(f'Running self-chat for {model}')
            outfile = self._get_log_path(model)

            if not os.path.exists(outfile):
                if 'model' in self.model_config[model]:
                    config = self._get_selfchat_config(model)
                    with capture_output():
                        parser = self_chat_setup_args()
                        parser.set_params(**config)
                        opt = parser.parse_args(args=[])
                    self_chat(opt)
                elif 'task' in self.model_config[model]:
                    self._convert_task_to_conversations(model)
                else:
                    raise RuntimeError(
                        f'Path must exist if log_path specified for {model}')

                if os.path.exists(outfile):
                    self._print_progress(
                        f'Chats saved to {outfile} for {model}')

            self._print_progress(
                f'Chats already exist in {outfile}, moving on...')
            self.chat_files[model] = outfile