The main pipeline for optimization. The pipeline is composed of 4 main components: 1. dataset - The dataset handle the data including the annotation and the prediction 2. annotator - The annotator is responsible generate the GT 3. predictor - The predictor is responsible to generate
| 13 | |
| 14 | |
| 15 | class OptimizationPipeline: |
| 16 | """ |
| 17 | The main pipeline for optimization. The pipeline is composed of 4 main components: |
| 18 | 1. dataset - The dataset handle the data including the annotation and the prediction |
| 19 | 2. annotator - The annotator is responsible generate the GT |
| 20 | 3. predictor - The predictor is responsible to generate the prediction |
| 21 | 4. eval - The eval is responsible to calculate the score and the large errors |
| 22 | """ |
| 23 | |
| 24 | def __init__(self, config, task_description: str = None, initial_prompt: str = None, output_path: str = ''): |
| 25 | """ |
| 26 | Initialize a new instance of the ClassName class. |
| 27 | :param config: The configuration file (EasyDict) |
| 28 | :param task_description: Describe the task that needed to be solved |
| 29 | :param initial_prompt: Provide an initial prompt to solve the task |
| 30 | :param output_path: The output dir to save dump, by default the dumps are not saved |
| 31 | """ |
| 32 | |
| 33 | if config.use_wandb: # In case of using W&B |
| 34 | wandb.login() |
| 35 | self.wandb_run = wandb.init( |
| 36 | project="AutoGPT", |
| 37 | config=config, |
| 38 | ) |
| 39 | if output_path == '': |
| 40 | self.output_path = None |
| 41 | else: |
| 42 | if not os.path.isdir(output_path): |
| 43 | os.makedirs(output_path) |
| 44 | self.output_path = Path(output_path) |
| 45 | logging.basicConfig(filename=self.output_path / 'info.log', level=logging.DEBUG, |
| 46 | format='%(asctime)s - %(levelname)s - %(message)s', force=True) |
| 47 | |
| 48 | self.dataset = None |
| 49 | self.config = config |
| 50 | self.meta_chain = MetaChain(config) |
| 51 | self.initialize_dataset() |
| 52 | |
| 53 | self.task_description = task_description |
| 54 | self.cur_prompt = initial_prompt |
| 55 | |
| 56 | self.predictor = give_estimator(config.predictor) |
| 57 | self.annotator = give_estimator(config.annotator) |
| 58 | self.eval = Eval(config.eval, self.meta_chain.error_analysis, self.dataset.label_schema) |
| 59 | self.batch_id = 0 |
| 60 | self.patient = 0 |
| 61 | |
| 62 | @staticmethod |
| 63 | def log_and_print(message): |
| 64 | print(message) |
| 65 | logging.info(message) |
| 66 | |
| 67 | def initialize_dataset(self): |
| 68 | """ |
| 69 | Initialize the dataset: Either empty dataset or loading an existing dataset |
| 70 | """ |
| 71 | logging.info('Initialize dataset') |
| 72 | self.dataset = DatasetBase(self.config.dataset) |
no outgoing calls
no test coverage detected