DSPy: The framework for programming—not prompting—language models
Python
Notebook working
Isaac Miller74ca08316814
diff --git a/dsp/modules/lm.py b/dsp/modules/lm.pyindex 7bd89ceed..9aff1478f 100644--- a/dsp/modules/lm.py+++ b/dsp/modules/lm.py@@ -1,6 +1,5 @@from abc import ABC, abstractmethod-from asyncio import Future-from concurrent.futures import ThreadPoolExecutor+from concurrent.futures import ThreadPoolExecutor, Futurefrom copy import deepcopyfrom enum import Enumfrom typing import Optional, Union, List@@ -227,7 +226,7 @@ class TrainableLM(LM, ABC):self,future: Future['TrainableLM'],train_path: str,- val_path: Optional[str],+ eval_path: Optional[str],method: TrainingMethod,**kwargs):# TODO: add docstringdiff --git a/dsp/modules/trainable_openai.py b/dsp/modules/trainable_openai.pyindex a1e6a4589..fccd8f561 100644--- a/dsp/modules/trainable_openai.py+++ b/dsp/modules/trainable_openai.py@@ -1,6 +1,6 @@-from asyncio import Future+from concurrent.futures import Futureimport time-from typing import Any, List, Optional, Literal, Union+from typing import Any, List, Optional, Literal, Tuple, Unionimport ujsonimport openaifrom dsp.modules.lm import TrainableLM, TrainingMethod@@ -176,8 +176,9 @@ class TrainableOpenAI(GPT3, TrainableLM):):super().__init__(model, api_key=api_key, api_provider=api_provider, api_base=api_base, model_type=model_type, system_prompt=system_prompt, **kwargs)assert self.provider == "openai", "You must use an OpenAI model with this class."+ self.fine_tuning_file_ids = {}- def _verify_training_arguments(self, dataset: dict[str, Any], valset: Optional[dict[str, Any]], **kwargs) -> bool:+ def _verify_training_arguments(self, dataset: List[dict[str, Any]], valset: Optional[List[dict[str, Any]]], **kwargs) -> bool:"""Verify the training arguments before starting training.More information on dataset verification can be found here: https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset@@ -211,7 +212,7 @@ class TrainableOpenAI(GPT3, TrainableLM):valid_hparams = ["n_epochs", "learning_rate_multiplier", "batch_size"]training_arguments = kwargs.get("hyperparameters", {})training_arguments = {- k: v for k, v in training_arguments if k in valid_hparams}+ k: v for k, v in training_arguments.items() if k in valid_hparams}# NOTE: Not validating seed or suffix or integration@@ -220,16 +221,22 @@ class TrainableOpenAI(GPT3, TrainableLM):return True- def _format_data_for_vanilla_finetuning(self, data: list[dict[str, str]]) -> list[dict[str, Any]]:+ def _format_data_for_vanilla_finetuning(self, data_path: str) -> List[dict[str, Any]]:+ """Convert the data from prompt completion to OAI compatible messages."""+ with open(data_path, "r", encoding="utf-8") as file:+ data = ujson.load(file)+def format_single_item(item):- messages = [{"role": "user", "content": item["prompt"]}, {- "role": "assistant", "content": item["completion"]}]- # NOTE: System prompt is required for the OpenAI API- if messages[0]["role"] != "system" and self.system_prompt:- messages.insert(- 0, {"role": "system", "content": self.system_prompt})- wrapped_messages = {"messages": messages}- return wrapped_messages+ messages = [+ {"role": "user", "content": item["prompt"]},+ {"role": "assistant", "content": item["completion"]}+ ]+ # Always prepend the system prompt if available+ if self.system_prompt:+ messages.insert(0, {"role": "system", "content": self.system_prompt})++ return {"messages": messages}+return list(map(format_single_item, data))def _submit_data(self, train_path: str, eval_path: Optional[str]):@@ -251,6 +258,7 @@ class TrainableOpenAI(GPT3, TrainableLM):file=open(f"{path}", "rb"),purpose="fine-tune")+ print(f"Uploaded {name} data to OpenAI")self.fine_tuning_file_ids[name] = file.id# TODO: support OAI wandb integration@@ -300,10 +308,11 @@ class TrainableOpenAI(GPT3, TrainableLM):return Truedef stop_training(self) -> None:- for file in self.fine_tuning_file_ids.values():- openai.files.delete(file)+ if self.fine_tuning_file_ids:+ for file in self.fine_tuning_file_ids.values():+ openai.files.delete(file)- self.fine_tuning_file_ids = {}+ self.fine_tuning_file_ids = {}if self.fine_tuning_job_id:openai.fine_tuning.jobs.cancel(self.fine_tuning_job_id)@@ -343,10 +352,24 @@ class TrainableOpenAI(GPT3, TrainableLM):try:if method not in self.SUPPORTED_TRAINING_METHODS:raise NotImplementedError(f"TrainableOpenAI can only support {TrainingMethod.SFT} for the time being")-- traindataset = ujson.load(open(train_path))- valdataset = ujson.load(open(eval_path)) if eval_path else None- self._verify_training_arguments(traindataset, valdataset, kwargs)++ # Convert the data from prompt completion to OAI compatible messages+ train_dataset = self._format_data_for_vanilla_finetuning(train_path)+ val_dataset = self._format_data_for_vanilla_finetuning(eval_path) if eval_path else None++ if not self._verify_training_arguments(train_dataset, val_dataset, **kwargs):+ print("Unable to verify arguments")+ raise RuntimeError("Unable to verify argument")++ if method != TrainingMethod.SFT:+ raise NotImplementedError("Only SFT finetuning is supported at the moment.")++ for path, dataset in [(train_path, train_dataset), (eval_path, val_dataset)]:+ if not (path and dataset):+ continue+ with open(path, "w") as f:+ for item in dataset:+ f.write(ujson.dumps(item) + "\n")self._submit_data(train_path, eval_path)@@ -364,6 +387,7 @@ class TrainableOpenAI(GPT3, TrainableLM):future.set_exception(e)def wait_for_training(self):+ print("Waiting for training to complete")while not self.check_training_status():time.sleep(60)@@ -382,7 +406,7 @@ class TrainableOpenAI(GPT3, TrainableLM):model.fine_tuning_job_id = job_idreturn model- def get_finetune(self, train_path: str, val_path: Optional[str], method: TrainingMethod, **kwargs) -> Future[TrainableLM]:+ def get_finetune(self, train_path: str, eval_path: Optional[str], method: TrainingMethod, **kwargs) -> Future[TrainableLM]:"""Does everything required to finetune an OpenAI model.@@ -411,4 +435,4 @@ class TrainableOpenAI(GPT3, TrainableLM):Returns:Future[TrainableLM]: A Future object that will hold the fine-tuned model"""- return super().get_finetune(train_path, val_path, method, **kwargs)+ return super().get_finetune(train_path=train_path, eval_path=eval_path, method=method, **kwargs)diff --git a/examples/finetuning/openai_finetuning_hpqa.ipynb b/examples/finetuning/openai_finetuning_hpqa.ipynbindex f77e6affb..677712494 100644--- a/examples/finetuning/openai_finetuning_hpqa.ipynb+++ b/examples/finetuning/openai_finetuning_hpqa.ipynb@@ -63,7 +63,9 @@"name": "stderr","output_type": "stream","text": [- "/scr-ssd/dilara/.miniconda3/envs/dspyprod/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",+ "/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n",+ " warnings.warn(\n",+ "/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n"," from .autonotebook import tqdm as notebook_tqdm\n"]}@@ -187,36 +189,35 @@},{"cell_type": "code",- "execution_count": 12,+ "execution_count": 9,"metadata": {},"outputs": [{"name": "stderr","output_type": "stream","text": [- "Average Metric: 257 / 500 (51.4): 100%|██████████| 500/500 [00:01<00:00, 493.06it/s]\n"+ "Average Metric: 113 / 200 (56.5): 100%|██████████| 200/200 [00:00<00:00, 296.95it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Writing dataset with length 771 to trainset_data.jsonl\n"+ "Writing dataset with length 10 to trainset_data.jsonl\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 106 / 183 (57.9): 37%|███▋ | 183/500 [06:26<11:09, 2.11s/it]\n",- "Average Metric: 70 / 125 (56.0): 100%|██████████| 125/125 [01:00<00:00, 2.07it/s]"+ "Average Metric: 30 / 50 (60.0): 100%|██████████| 50/50 [00:00<00:00, 308.83it/s]"]},{"name": "stdout","output_type": "stream","text": [- "Writing dataset with length 210 to devset_data.jsonl\n"+ "Writing dataset with length 10 to devset_data.jsonl\n"]},{@@ -231,7 +232,7 @@"from dspy.teleprompt.finetune_teleprompter import bootstrap_data_for_round, convert_to_prompt_completion_data\n","import ujson\n","\n",- "samples = 500\n",+ "samples = 200\n","\n","dspy.settings.configure(experimental=True)\n","dc_kwargs = {\n",@@ -250,14 +251,12 @@" filtered_data = [d for d in data if d[\"score\"]]\n","\n"," # Convert the data to prompt completion format\n",- " dataset = convert_to_prompt_completion_data(filtered_data, program=basicmh_bs, exclude_demos=True)\n",+ " dataset = convert_to_prompt_completion_data(filtered_data, program=basicmh_bs, exclude_demos=True)[:10]\n"," \n"," # Format the data for finetuning using the LM\n",- " dataset = lm._format_data_for_vanilla_finetuning(dataset)\n"," print(\"Writing dataset with length\", len(dataset), \"to\", filename)\n"," with open(filename, \"w\") as f:\n",- " for line in dataset:\n",- " f.write(ujson.dumps(line) + \"\\n\")\n",+ " ujson.dump(dataset, f)\n","\n","for key, data in dataset_filenames.items():\n"," write_data(data, key)"@@ -267,10 +266,29 @@"cell_type": "code","execution_count": 10,"metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "No errors found\n",+ "\n",+ "10 examples are missing a system message\n",+ "Dataset has ~4375 tokens that will be charged for during training\n",+ "By default, you'll train for 10 epochs on this dataset\n",+ "By default, you'll be charged for ~43750 tokens\n",+ "No errors found\n",+ "Uploaded train data to OpenAI\n",+ "Uploaded val data to OpenAI\n",+ "Waiting for training to complete\n"+ ]+ }+ ],"source": [- "future_lm = dspy.OpenAIModel.load_from_job_id(\"ftjob-tmccSJv170p4gNFJUYwXdCSq\")\n",- "finetuned_lm = future_lm\n",+ "from dsp.modules.lm import TrainingMethod\n",+ "\n",+ "future_lm = lm.get_finetune(method=TrainingMethod.SFT, train_path=\"trainset_data.jsonl\", eval_path=\"devset_data.jsonl\", hyperparameters={\"n_epochs\": 1})\n",+ "finetuned_lm = future_lm.result()\n","finetuned_lm.kwargs[\"temperature\"] = 0.0"]},@@ -295,7 +313,7 @@},{"cell_type": "code",- "execution_count": 15,+ "execution_count": 13,"metadata": {},"outputs": [{@@ -310,106 +328,78 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 106 / 250 (42.4): 100%|██████████| 250/250 [00:03<00:00, 71.56it/s] \n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 42.4 for set: [0, 0, 0]\n",- "New best score: 42.4 for seed -3\n",- "Scores so far: [42.4]\n",- "Best score: 42.4\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 134 / 250 (53.6): 100%|██████████| 250/250 [00:29<00:00, 8.54it/s]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 53.6 for set: [16, 16, 16]\n",- "New best score: 53.6 for seed -2\n",- "Scores so far: [42.4, 53.6]\n",- "Best score: 53.6\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- " 6%|▌ | 6/100 [00:26<07:02, 4.50s/it]\n"+ "Average Metric: 103 / 250 (41.2): 100%|██████████| 250/250 [01:44<00:00, 2.38it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Bootstrapped 3 full traces after 7 examples in round 0.\n"+ "Score: 41.2 for set: [0, 0, 0]\n",+ "New best score: 41.2 for seed -3\n",+ "Scores so far: [41.2]\n",+ "Best score: 41.2\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 89 / 162 (54.9): 64%|██████▍ | 161/250 [01:00<00:34, 2.62it/s]"+ "Average Metric: 135 / 250 (54.0): 100%|██████████| 250/250 [00:32<00:00, 7.76it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Average Metric: 4 / 8 (50.0): 3%|▎ | 8/250 [10:14<5:10:00, 76.86s/it]"+ "Score: 54.0 for set: [16, 16, 16]\n",+ "New best score: 54.0 for seed -2\n",+ "Scores so far: [41.2, 54.0]\n",+ "Best score: 54.0\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 90 / 163 (55.2): 65%|██████▌ | 163/250 [01:00<00:26, 3.30it/s]"+ " 5%|▌ | 5/100 [00:22<07:06, 4.49s/it]\n"]},{"name": "stdout","output_type": "stream","text": [- "\n"+ "Bootstrapped 3 full traces after 6 examples in round 0.\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 142 / 250 (56.8): 100%|██████████| 250/250 [01:31<00:00, 2.74it/s]\n"+ "Average Metric: 144 / 250 (57.6): 100%|██████████| 250/250 [01:37<00:00, 2.57it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Score: 56.8 for set: [16, 16, 16]\n",- "New best score: 56.8 for seed -1\n",- "Scores so far: [42.4, 53.6, 56.8]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",- "Average of max per entry across top 2 scores: 0.64\n",- "Average of max per entry across top 3 scores: 0.656\n",- "Average of max per entry across top 5 scores: 0.656\n",- "Average of max per entry across top 8 scores: 0.656\n",- "Average of max per entry across top 9999 scores: 0.656\n"+ "Score: 57.6 for set: [16, 16, 16]\n",+ "New best score: 57.6 for seed -1\n",+ "Scores so far: [41.2, 54.0, 57.6]\n",+ "Best score: 57.6\n",+ "Average of max per entry across top 1 scores: 0.576\n",+ "Average of max per entry across top 2 scores: 0.628\n",+ "Average of max per entry across top 3 scores: 0.64\n",+ "Average of max per entry across top 5 scores: 0.64\n",+ "Average of max per entry across top 8 scores: 0.64\n",+ "Average of max per entry across top 9999 scores: 0.64\n"]},{"name": "stderr","output_type": "stream","text": [- " 3%|▎ | 3/100 [00:15<08:17, 5.13s/it]\n"+ " 3%|▎ | 3/100 [00:14<08:02, 4.98s/it]\n"]},{@@ -423,55 +413,55 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 133 / 250 (53.2): 100%|██████████| 250/250 [01:49<00:00, 2.28it/s]\n"+ "Average Metric: 140 / 250 (56.0): 100%|██████████| 250/250 [01:50<00:00, 2.26it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Score: 53.2 for set: [16, 16, 16]\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",+ "Score: 56.0 for set: [16, 16, 16]\n",+ "Scores so far: [41.2, 54.0, 57.6, 56.0]\n",+ "Best score: 57.6\n",+ "Average of max per entry across top 1 scores: 0.576\n","Average of max per entry across top 2 scores: 0.64\n","Average of max per entry across top 3 scores: 0.664\n",- "Average of max per entry across top 5 scores: 0.676\n",- "Average of max per entry across top 8 scores: 0.676\n",- "Average of max per entry across top 9999 scores: 0.676\n"+ "Average of max per entry across top 5 scores: 0.672\n",+ "Average of max per entry across top 8 scores: 0.672\n",+ "Average of max per entry across top 9999 scores: 0.672\n"]},{"name": "stderr","output_type": "stream","text": [- " 1%| | 1/100 [00:04<07:14, 4.39s/it]\n"+ " 3%|▎ | 3/100 [00:12<06:36, 4.08s/it]\n"]},{"name": "stdout","output_type": "stream","text": [- "Bootstrapped 1 full traces after 2 examples in round 0.\n"+ "Bootstrapped 1 full traces after 4 examples in round 0.\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 136 / 250 (54.4): 100%|██████████| 250/250 [01:49<00:00, 2.29it/s]\n"+ "Average Metric: 137 / 250 (54.8): 100%|██████████| 250/250 [01:39<00:00, 2.53it/s]\n"]},{"name": "stdout","output_type": "stream","text": [- "Score: 54.4 for set: [16, 16, 16]\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2, 54.4]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",- "Average of max per entry across top 2 scores: 0.624\n",- "Average of max per entry across top 3 scores: 0.664\n",+ "Score: 54.8 for set: [16, 16, 16]\n",+ "Scores so far: [41.2, 54.0, 57.6, 56.0, 54.8]\n",+ "Best score: 57.6\n",+ "Average of max per entry across top 1 scores: 0.576\n",+ "Average of max per entry across top 2 scores: 0.64\n",+ "Average of max per entry across top 3 scores: 0.668\n","Average of max per entry across top 5 scores: 0.684\n","Average of max per entry across top 8 scores: 0.684\n","Average of max per entry across top 9999 scores: 0.684\n"@@ -481,43 +471,7 @@"name": "stderr","output_type": "stream","text": [- " 2%|▏ | 2/100 [00:06<05:32, 3.39s/it]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Bootstrapped 1 full traces after 3 examples in round 0.\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 135 / 250 (54.0): 100%|██████████| 250/250 [01:46<00:00, 2.34it/s]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 54.0 for set: [16, 16, 16]\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2, 54.4, 54.0]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",- "Average of max per entry across top 2 scores: 0.624\n",- "Average of max per entry across top 3 scores: 0.648\n",- "Average of max per entry across top 5 scores: 0.68\n",- "Average of max per entry across top 8 scores: 0.688\n",- "Average of max per entry across top 9999 scores: 0.688\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- " 2%|▏ | 2/100 [00:10<08:25, 5.16s/it]\n"+ " 2%|▏ | 2/100 [00:05<04:15, 2.60s/it]\n"]},{@@ -531,122 +485,25 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 125 / 250 (50.0): 100%|██████████| 250/250 [13:00<00:00, 3.12s/it]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 50.0 for set: [16, 16, 16]\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2, 54.4, 54.0, 50.0]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",- "Average of max per entry across top 2 scores: 0.624\n",- "Average of max per entry across top 3 scores: 0.648\n",- "Average of max per entry across top 5 scores: 0.68\n",- "Average of max per entry across top 8 scores: 0.688\n",- "Average of max per entry across top 9999 scores: 0.688\n"+ "Average Metric: 73 / 139 (52.5): 55%|█████▌ | 138/250 [00:54<00:29, 3.82it/s]WARNING:dspy.evaluate.evaluate:\u001b[2m2024-08-15T01:50:04.428079Z\u001b[0m [\u001b[33m\u001b[1mwarning \u001b[0m] \u001b[1mReceived SIGINT. Cancelling evaluation.\u001b[0m [\u001b[0m\u001b[1m\u001b[34mdspy.evaluate.evaluate\u001b[0m]\u001b[0m \u001b[36mfilename\u001b[0m=\u001b[35mevaluate.py\u001b[0m \u001b[36mlineno\u001b[0m=\u001b[35m91\u001b[0m\n"]},{- "name": "stderr",- "output_type": "stream",- "text": [- " 1%| | 1/100 [17:22<28:40:26, 1042.69s/it]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Bootstrapped 1 full traces after 2 examples in round 0.\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 133 / 250 (53.2): 100%|██████████| 250/250 [01:35<00:00, 2.61it/s]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 53.2 for set: [16, 16, 16]\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2, 54.4, 54.0, 50.0, 53.2]\n",- "Best score: 56.8\n",- "Average of max per entry across top 1 scores: 0.568\n",- "Average of max per entry across top 2 scores: 0.624\n",- "Average of max per entry across top 3 scores: 0.648\n",- "Average of max per entry across top 5 scores: 0.68\n",- "Average of max per entry across top 8 scores: 0.688\n",- "Average of max per entry across top 9999 scores: 0.688\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- " 8%|▊ | 8/100 [00:44<08:35, 5.60s/it]\n"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Bootstrapped 3 full traces after 9 examples in round 0.\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 143 / 250 (57.2): 100%|██████████| 250/250 [01:47<00:00, 2.33it/s]"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Score: 57.2 for set: [16, 16, 16]\n",- "New best score: 57.2 for seed 5\n",- "Scores so far: [42.4, 53.6, 56.8, 53.2, 54.4, 54.0, 50.0, 53.2, 57.2]\n",- "Best score: 57.2\n",- "Average of max per entry across top 1 scores: 0.572\n",- "Average of max per entry across top 2 scores: 0.64\n",- "Average of max per entry across top 3 scores: 0.66\n",- "Average of max per entry across top 5 scores: 0.688\n",- "Average of max per entry across top 8 scores: 0.692\n",- "Average of max per entry across top 9999 scores: 0.692\n",- "9 candidate programs found.\n",- "[('retrieve', <dspy.retrieve.retrieve.Retrieve object at 0x12e43f670>), ('generate_query[0]', Predict(StringSignature(context, question -> rationale, search_query\n",- " instructions='Given the fields `context`, `question`, produce the fields `search_query`.'\n",- " context = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Context:', 'desc': '${context}'})\n",- " question = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Question:', 'desc': '${question}'})\n",- " rationale = Field(annotation=str required=True json_schema_extra={'prefix': \"Reasoning: Let's think step by step in order to\", 'desc': '${produce the output fields}. We ...', '__dspy_field_type': 'output'})\n",- " search_query = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'output', 'prefix': 'Search Query:', 'desc': '${search_query}'})\n",- "))), ('generate_query[1]', Predict(StringSignature(context, question -> rationale, search_query\n",- " instructions='Given the fields `context`, `question`, produce the fields `search_query`.'\n",- " context = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Context:', 'desc': '${context}'})\n",- " question = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Question:', 'desc': '${question}'})\n",- " rationale = Field(annotation=str required=True json_schema_extra={'prefix': \"Reasoning: Let's think step by step in order to\", 'desc': '${produce the output fields}. We ...', '__dspy_field_type': 'output'})\n",- " search_query = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'output', 'prefix': 'Search Query:', 'desc': '${search_query}'})\n",- "))), ('generate_answer', Predict(StringSignature(context, question -> rationale, answer\n",- " instructions='Given the fields `context`, `question`, produce the fields `answer`.'\n",- " context = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Context:', 'desc': '${context}'})\n",- " question = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'input', 'prefix': 'Question:', 'desc': '${question}'})\n",- " rationale = Field(annotation=str required=True json_schema_extra={'prefix': \"Reasoning: Let's think step by step in order to\", 'desc': '${produce the output fields}. We ...', '__dspy_field_type': 'output'})\n",- " answer = Field(annotation=str required=True json_schema_extra={'__dspy_field_type': 'output', 'prefix': 'Answer:', 'desc': '${answer}'})\n",- ")))]\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "\n"+ "ename": "KeyboardInterrupt",+ "evalue": "",+ "output_type": "error",+ "traceback": [+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",+ "Cell \u001b[0;32mIn[13], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m config \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mdict\u001b[39m(max_bootstrapped_demos\u001b[38;5;241m=\u001b[39mmax_bootstrapped_demos, num_candidate_programs\u001b[38;5;241m=\u001b[39mnum_candidate_programs, num_threads\u001b[38;5;241m=\u001b[39mNUM_THREADS)\n\u001b[1;32m 6\u001b[0m bsfsrs_teleprompter \u001b[38;5;241m=\u001b[39m BootstrapFewShotWithRandomSearch(metric\u001b[38;5;241m=\u001b[39mmetric, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mconfig)\n\u001b[0;32m----> 7\u001b[0m basicmh_bs_ft_bs \u001b[38;5;241m=\u001b[39m \u001b[43mbsfsrs_teleprompter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstudent\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbasicmh_bs_ft\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrainset\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrainset\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m100\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalset\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdevset\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m250\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 8\u001b[0m basicmh_bs_ft_bs\u001b[38;5;241m.\u001b[39msave(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmini_bs_ft_bs_hpqa_100.json\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 9\u001b[0m basicmh_bs_ft_bs\u001b[38;5;241m.\u001b[39m_set_all_predictor_lms(finetuned_lm)\n",+ "File \u001b[0;32m~/projects/dspy-finetuning/dilara-dspy/dspy/teleprompt/random_search.py:123\u001b[0m, in \u001b[0;36mBootstrapFewShotWithRandomSearch.compile\u001b[0;34m(self, student, teacher, trainset, valset, restrict, labeled_sample)\u001b[0m\n\u001b[1;32m 112\u001b[0m program2 \u001b[38;5;241m=\u001b[39m teleprompter\u001b[38;5;241m.\u001b[39mcompile(student, teacher\u001b[38;5;241m=\u001b[39mteacher, trainset\u001b[38;5;241m=\u001b[39mtrainset2)\n\u001b[1;32m 114\u001b[0m evaluate \u001b[38;5;241m=\u001b[39m Evaluate(\n\u001b[1;32m 115\u001b[0m devset\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalset,\n\u001b[1;32m 116\u001b[0m metric\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmetric,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 120\u001b[0m display_progress\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 121\u001b[0m )\n\u001b[0;32m--> 123\u001b[0m score, subscores \u001b[38;5;241m=\u001b[39m \u001b[43mevaluate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprogram2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreturn_all_scores\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 125\u001b[0m all_subscores\u001b[38;5;241m.\u001b[39mappend(subscores)\n\u001b[1;32m 127\u001b[0m \u001b[38;5;66;03m############ Assertion-aware Optimization ############\u001b[39;00m\n",+ "File \u001b[0;32m~/projects/dspy-finetuning/dilara-dspy/dspy/evaluate/evaluate.py:193\u001b[0m, in \u001b[0;36mEvaluate.__call__\u001b[0;34m(self, program, metric, devset, num_threads, display_progress, display_table, return_all_scores, return_outputs)\u001b[0m\n\u001b[1;32m 191\u001b[0m reordered_devset, ncorrect, ntotal \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_execute_single_thread(wrapped_program, devset, display_progress)\n\u001b[1;32m 192\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 193\u001b[0m reordered_devset, ncorrect, ntotal \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_execute_multi_thread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 194\u001b[0m \u001b[43m \u001b[49m\u001b[43mwrapped_program\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 195\u001b[0m \u001b[43m \u001b[49m\u001b[43mdevset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 196\u001b[0m \u001b[43m \u001b[49m\u001b[43mnum_threads\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 197\u001b[0m \u001b[43m \u001b[49m\u001b[43mdisplay_progress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 198\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 200\u001b[0m dspy\u001b[38;5;241m.\u001b[39mlogger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAverage Metric: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mncorrect\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m / \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mntotal\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m (\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mround\u001b[39m(\u001b[38;5;241m100\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;250m \u001b[39mncorrect\u001b[38;5;250m \u001b[39m\u001b[38;5;241m/\u001b[39m\u001b[38;5;250m \u001b[39mntotal,\u001b[38;5;250m \u001b[39m\u001b[38;5;241m1\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m%)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 202\u001b[0m predicted_devset \u001b[38;5;241m=\u001b[39m \u001b[38;5;28msorted\u001b[39m(reordered_devset)\n",+ "File \u001b[0;32m~/projects/dspy-finetuning/dilara-dspy/dspy/evaluate/evaluate.py:109\u001b[0m, in \u001b[0;36mEvaluate._execute_multi_thread\u001b[0;34m(self, wrapped_program, devset, num_threads, display_progress)\u001b[0m\n\u001b[1;32m 106\u001b[0m futures \u001b[38;5;241m=\u001b[39m {executor\u001b[38;5;241m.\u001b[39msubmit(cancellable_wrapped_program, idx, arg) \u001b[38;5;28;01mfor\u001b[39;00m idx, arg \u001b[38;5;129;01min\u001b[39;00m devset}\n\u001b[1;32m 107\u001b[0m pbar \u001b[38;5;241m=\u001b[39m tqdm\u001b[38;5;241m.\u001b[39mtqdm(total\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mlen\u001b[39m(devset), dynamic_ncols\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, disable\u001b[38;5;241m=\u001b[39m\u001b[38;5;129;01mnot\u001b[39;00m display_progress)\n\u001b[0;32m--> 109\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m future \u001b[38;5;129;01min\u001b[39;00m as_completed(futures):\n\u001b[1;32m 110\u001b[0m example_idx, example, prediction, score \u001b[38;5;241m=\u001b[39m future\u001b[38;5;241m.\u001b[39mresult()\n\u001b[1;32m 112\u001b[0m \u001b[38;5;66;03m# use the cancelled_job literal to check if the job was cancelled - use \"is\" not \"==\"\u001b[39;00m\n\u001b[1;32m 113\u001b[0m \u001b[38;5;66;03m# in case the prediction is \"cancelled\" for some reason.\u001b[39;00m\n",+ "File \u001b[0;32m/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py:245\u001b[0m, in \u001b[0;36mas_completed\u001b[0;34m(fs, timeout)\u001b[0m\n\u001b[1;32m 240\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m wait_timeout \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 241\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTimeoutError\u001b[39;00m(\n\u001b[1;32m 242\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m (of \u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m) futures unfinished\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m%\u001b[39m (\n\u001b[1;32m 243\u001b[0m \u001b[38;5;28mlen\u001b[39m(pending), total_futures))\n\u001b[0;32m--> 245\u001b[0m \u001b[43mwaiter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mevent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwait\u001b[49m\u001b[43m(\u001b[49m\u001b[43mwait_timeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 247\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m waiter\u001b[38;5;241m.\u001b[39mlock:\n\u001b[1;32m 248\u001b[0m finished \u001b[38;5;241m=\u001b[39m waiter\u001b[38;5;241m.\u001b[39mfinished_futures\n",+ "File \u001b[0;32m/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py:574\u001b[0m, in \u001b[0;36mEvent.wait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 572\u001b[0m signaled \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_flag\n\u001b[1;32m 573\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m signaled:\n\u001b[0;32m--> 574\u001b[0m signaled \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_cond\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwait\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 575\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m signaled\n",+ "File \u001b[0;32m/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py:312\u001b[0m, in \u001b[0;36mCondition.wait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 310\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \u001b[38;5;66;03m# restore state no matter what (e.g., KeyboardInterrupt)\u001b[39;00m\n\u001b[1;32m 311\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m timeout \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 312\u001b[0m \u001b[43mwaiter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43macquire\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 313\u001b[0m gotit \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m 314\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",+ "File \u001b[0;32m~/projects/dspy-finetuning/dilara-dspy/dspy/evaluate/evaluate.py:92\u001b[0m, in \u001b[0;36mEvaluate._execute_multi_thread.<locals>.interrupt_handler_manager.<locals>.interrupt_handler\u001b[0;34m(sig, frame)\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcancel_jobs\u001b[38;5;241m.\u001b[39mset()\n\u001b[1;32m 91\u001b[0m dspy\u001b[38;5;241m.\u001b[39mlogger\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mReceived SIGINT. Cancelling evaluation.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 92\u001b[0m \u001b[43mdefault_handler\u001b[49m\u001b[43m(\u001b[49m\u001b[43msig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mframe\u001b[49m\u001b[43m)\u001b[49m\n",+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "]}],@@ -668,72 +525,9 @@},{"cell_type": "code",- "execution_count": 16,+ "execution_count": null,"metadata": {},- "outputs": [- {- "name": "stderr",- "output_type": "stream",- "text": [- "[autoreload of dsp.modules.lm failed: Traceback (most recent call last):\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 276, in check\n",- " superreload(m, reload, self.old_objects)\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 475, in superreload\n",- " module = reload(module)\n",- " File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py\", line 169, in reload\n",- " _bootstrap._exec(spec, module)\n",- " File \"<frozen importlib._bootstrap>\", line 613, in _exec\n",- " File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n",- " File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/dilara-dspy/dsp/modules/lm.py\", line 152, in <module>\n",- " class TrainableLM(LM, ABC):\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/dilara-dspy/dsp/modules/lm.py\", line 153, in TrainableLM\n",- " def get_finetune(self, train_path: str, val_path: Optional[str], method: FinetuningMethod, **kwargs) -> Future['TrainableLM']:\n",- "NameError: name 'FinetuningMethod' is not defined\n",- "]\n",- "[autoreload of dsp.modules.openai failed: Traceback (most recent call last):\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 276, in check\n",- " superreload(m, reload, self.old_objects)\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 475, in superreload\n",- " module = reload(module)\n",- " File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py\", line 169, in reload\n",- " _bootstrap._exec(spec, module)\n",- " File \"<frozen importlib._bootstrap>\", line 613, in _exec\n",- " File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n",- " File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/dilara-dspy/dsp/modules/openai.py\", line 6, in <module>\n",- " from dsp.modules.lm import TrainableLM, FinetuningMethod\n",- "ImportError: cannot import name 'TrainableLM' from 'dsp.modules.lm' (/Users/isaac.miller/projects/dspy-finetuning/dilara-dspy/dsp/modules/lm.py)\n",- "]\n",- "[autoreload of dspy failed: Traceback (most recent call last):\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 276, in check\n",- " superreload(m, reload, self.old_objects)\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/.venv/lib/python3.9/site-packages/IPython/extensions/autoreload.py\", line 475, in superreload\n",- " module = reload(module)\n",- " File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py\", line 169, in reload\n",- " _bootstrap._exec(spec, module)\n",- " File \"<frozen importlib._bootstrap>\", line 613, in _exec\n",- " File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n",- " File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n",- " File \"/Users/isaac.miller/projects/dspy-finetuning/dilara-dspy/dspy/__init__.py\", line 42, in <module>\n",- " OpenAIModel = dsp.TrainableOpenAI\n",- "AttributeError: module 'dsp' has no attribute 'TrainableOpenAI'\n",- "]\n",- "Average Metric: 130 / 300 (43.3): 100%|██████████| 300/300 [00:24<00:00, 12.29it/s] \n"- ]- },- {- "ename": "AttributeError",- "evalue": "'float' object has no attribute '_get_lm_info_str'",- "output_type": "error",- "traceback": [- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",- "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",- "Cell \u001b[0;32mIn[16], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m TEST_SIZE \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m300\u001b[39m\n\u001b[1;32m 2\u001b[0m baseline_eval \u001b[38;5;241m=\u001b[39m evaluate(BasicMH(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mprogram_params), devset\u001b[38;5;241m=\u001b[39mdevset[:TEST_SIZE])\n\u001b[0;32m----> 3\u001b[0m \u001b[43mbaseline_eval\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_lm_info_str\u001b[49m()\n\u001b[1;32m 4\u001b[0m bs_eval \u001b[38;5;241m=\u001b[39m evaluate(basicmh_bs, devset\u001b[38;5;241m=\u001b[39mdevset[:TEST_SIZE])\n\u001b[1;32m 5\u001b[0m bs_eval\u001b[38;5;241m.\u001b[39m_get_lm_info_str()\n",- "\u001b[0;31mAttributeError\u001b[0m: 'float' object has no attribute '_get_lm_info_str'"- ]- }- ],+ "outputs": [],"source": ["TEST_SIZE = 300\n","baseline_eval = evaluate(BasicMH(**program_params), devset=devset[:TEST_SIZE])\n",